-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Changed order of module & theme enabling - Enable minimally branded theme for easier switching (#185) - D8CORE-3345 Update hook to update paths for terms and content. (#183) - D8CORE-5574 D8CORE-5575 D8CORE-5576 Adjustments to the schedule module form displays (#184) - D8CORE-5583 Improve menu tree cache tags (#179) - Switch to conditional fields instead of form alter (#182)
- Loading branch information
Showing
20 changed files
with
635 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
modules/stanford_basic_page_types/stanford_basic_page_types.info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
modules/stanford_paragraph_card/stanford_paragraph_card.info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: 'Stanford Paragraph Card' | ||
description: 'Adds helpers and modifications to the card paragraph type.' | ||
version: 8.x-1.33 | ||
version: 8.x-1.34 | ||
core_version_requirement: '^8 || ^9' | ||
type: module | ||
project: Stanford |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
modules/stanford_profile_styles/stanford_profile_styles.info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: 'Stanford Profile Styles' | ||
description: 'A module for theming' | ||
version: 8.x-1.33 | ||
version: 8.x-1.34 | ||
core_version_requirement: '^8 || ^9' | ||
type: module | ||
project: Stanford |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Drupal\stanford_profile_helper; | ||
|
||
use Drupal\Core\Cache\CacheableMetadata; | ||
use Drupal\Core\Cache\Context\CalculatedCacheContextInterface; | ||
use Drupal\Core\Cache\Context\MenuActiveTrailsCacheContext; | ||
|
||
/** | ||
* Service decorator for core `cache_context.route.menu_active_trails` service. | ||
*/ | ||
class MenuActiveTrailsCacheContextOverride implements CalculatedCacheContextInterface { | ||
|
||
/** | ||
* Original service. | ||
* | ||
* @var \Drupal\Core\Cache\Context\CalculatedCacheContextInterface | ||
*/ | ||
protected $cacheContext; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public static function getLabel() { | ||
return MenuActiveTrailsCacheContext::getLabel(); | ||
} | ||
|
||
/** | ||
* Service decorator constructor. | ||
* | ||
* @param \Drupal\Core\Cache\Context\CalculatedCacheContextInterface $cache_context | ||
* Original service. | ||
*/ | ||
public function __construct(CalculatedCacheContextInterface $cache_context) { | ||
$this->cacheContext = $cache_context; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getCacheableMetadata($parameter = NULL) { | ||
// Remove the cache tags from the original service. | ||
// | ||
// @see Drupal\Core\Cache\Context\MenuActiveTrailsCacheContext::getCacheableMetadata() | ||
return new CacheableMetadata(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getContext($parameter = NULL) { | ||
return $this->cacheContext->getContext($parameter); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
namespace Drupal\stanford_profile_helper; | ||
|
||
use Drupal\Core\Menu\MenuLinkTreeInterface; | ||
use Drupal\Core\Menu\MenuTreeParameters; | ||
|
||
/** | ||
* Service decorator for the menu.link_tree service. | ||
*/ | ||
class MenuLinkTreeOverride implements MenuLinkTreeInterface { | ||
|
||
/** | ||
* Original Menu Tree service. | ||
* | ||
* @var \Drupal\Core\Menu\MenuLinkTreeInterface | ||
*/ | ||
protected $menuTree; | ||
|
||
/** | ||
* Menu Tree service override constructor. | ||
* | ||
* @param \Drupal\Core\Menu\MenuLinkTreeInterface $menu_tree | ||
* Original Menu Tree service. | ||
*/ | ||
public function __construct(MenuLinkTreeInterface $menu_tree) { | ||
$this->menuTree = $menu_tree; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function build(array $tree) { | ||
$build = $this->menuTree->build($tree); | ||
$build['#cache']['tags'][] = 'stanford_profile_helper:menu_links'; | ||
// Remove node cache tags since we'll use our own cache tag above. | ||
StanfordProfileHelper::removeCacheTags($build, [ | ||
'^node:*', | ||
'^config:system.menu.*', | ||
]); | ||
return $build; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getCurrentRouteMenuTreeParameters($menu_name) { | ||
return $this->menuTree->getCurrentRouteMenuTreeParameters($menu_name); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function load($menu_name, MenuTreeParameters $parameters) { | ||
return $this->menuTree->load($menu_name, $parameters); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
public function transform(array $tree, array $manipulators) { | ||
return $this->menuTree->transform($tree, $manipulators); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function maxDepth() { | ||
return $this->menuTree->maxDepth(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getSubtreeHeight($id) { | ||
return $this->menuTree->getSubtreeHeight($id); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getExpanded($menu_name, array $parents) { | ||
return $this->menuTree->getExpanded($menu_name, $parents); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Drupal\stanford_profile_helper; | ||
|
||
use Drupal\Core\Security\TrustedCallbackInterface; | ||
|
||
/** | ||
* Module helper methods and service. | ||
*/ | ||
class StanfordProfileHelper implements TrustedCallbackInterface { | ||
|
||
/** | ||
* Remove some cache tags from a render array. | ||
* | ||
* @param array|mixed $item | ||
* Render array. | ||
* @param array $tags | ||
* Cache tags to be removed from the render array using regex. | ||
*/ | ||
public static function removeCacheTags(&$item, array $tags = []) { | ||
if (!is_array($item) || empty($item['#cache']['tags'])) { | ||
return; | ||
} | ||
$item['#cache']['tags'] = array_filter($item['#cache']['tags'], function ($tag) use ($tags) { | ||
foreach ($tags as $search_tag) { | ||
if (preg_match("/$search_tag/", $tag)) { | ||
return FALSE; | ||
} | ||
} | ||
return TRUE; | ||
}); | ||
$item['#cache']['tags'] = array_values($item['#cache']['tags']); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public static function trustedCallbacks(): array { | ||
return ['preRenderDsEntity']; | ||
} | ||
|
||
/** | ||
* PreRender the ds entity to add contextual links. | ||
* | ||
* @param array $element | ||
* Entity render array. | ||
* | ||
* @return array | ||
* Altered render array. | ||
*/ | ||
public static function preRenderDsEntity(array $element): array { | ||
$module_handler = \Drupal::moduleHandler(); | ||
if (isset($element['#contextual_links']) && $module_handler->moduleExists('contextual')) { | ||
$placeholder = [ | ||
'#type' => 'contextual_links_placeholder', | ||
'#id' => _contextual_links_to_id($element['#contextual_links']), | ||
]; | ||
$element['#prefix'] = \Drupal::service('renderer')->render($placeholder); | ||
} | ||
return $element; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.