Skip to content

Commit

Permalink
8.1.34
Browse files Browse the repository at this point in the history
- 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
pookmish authored Mar 17, 2022
2 parents f499135 + e81d601 commit 020f5e3
Show file tree
Hide file tree
Showing 20 changed files with 635 additions and 391 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Stanford Profile Helper


8.x-1.34
--------------------------------------------------------------------------------
_Release Date: 2022-03-17_

- 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)


8.x-1.33
--------------------------------------------------------------------------------
_Release Date: 2022-03-08_
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"drupal/paragraphs": "^1.11",
"drupal/pdb": "^1.0@alpha",
"drupal/ui_patterns": "~1.0",
"drupal/views_custom_cache_tag": "^1.2",
"drupal/xmlsitemap": "~1.0",
"su-sws/jumpstart_ui": "^8.1",
"su-sws/react_paragraphs": "^8.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'Stanford Basic Page Types'
description: 'Provides support for basic page types in stanford_page nodes'
version: 8.x-1.33
version: 8.x-1.34
core_version_requirement: '^8.8 || ^9'
type: module
project: Stanford
Expand Down
2 changes: 1 addition & 1 deletion modules/stanford_intranet/stanford_intranet.info.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'Stanford Intranet'
description: 'Locks down access to the entire site if configured.'
version: 8.x-1.33
version: 8.x-1.34
core_version_requirement: '^8.8 || ^9'
type: module
project: Stanford
Expand Down
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'Stanford Profile Drush'
description: 'A collection of Drush commands since commands in the profile are not discoverable.'
version: 8.x-1.33
version: 8.x-1.34
core_version_requirement: '^8 || ^9'
type: module
project: Stanford
Expand Down
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
55 changes: 55 additions & 0 deletions src/MenuActiveTrailsCacheContextOverride.php
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);
}

}
94 changes: 94 additions & 0 deletions src/MenuLinkTreeOverride.php
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);
}

}
42 changes: 0 additions & 42 deletions src/StanfordPreRenderer.php

This file was deleted.

63 changes: 63 additions & 0 deletions src/StanfordProfileHelper.php
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;
}

}
2 changes: 1 addition & 1 deletion stanford_profile_helper.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type: module
description: 'Stanford Profile Helper Module.'
core_version_requirement: ^8.8 || ^9
package: Stanford
version: 8.x-1.33
version: 8.x-1.34
dependencies:
- 'admin_toolbar:admin_toolbar'
- 'admin_toolbar:admin_toolbar_tools'
Expand Down
15 changes: 15 additions & 0 deletions stanford_profile_helper.install
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,18 @@ function stanford_profile_helper_update_8191() {
function stanford_profile_helper_update_8192() {
module_set_weight('stanford_profile_helper', 10);
}

/**
* Enable views_custom_cache_tag module.
*/
function stanford_profile_helper_update_8193() {
\Drupal::service('module_installer')->install(['views_custom_cache_tag']);
}

/**
* Enable minimally_branded_subtheme theme & 2 modules.
*/
function stanford_profile_helper_update_8194() {
\Drupal::service('module_installer')->install(['ctools_views', 'views_custom_cache_tag']);
\Drupal::service('theme_installer')->install(['minimally_branded_subtheme']);
}
Loading

0 comments on commit 020f5e3

Please sign in to comment.