Skip to content
Snippets Groups Projects
Unverified Commit e2ca63a2 authored by Doug Green's avatar Doug Green Committed by Doug Green
Browse files

Issue #3347677 by douggreen: Bubble up cache contexts & tags from the rendered menu

parent 718f6c51
Branches
Tags 8.x-1.4
No related merge requests found
......@@ -3,6 +3,7 @@
namespace Drupal\smartmenus\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -253,8 +254,8 @@ class SmartMenusBlock extends BlockBase implements ContainerFactoryPluginInterfa
$build['#menu_tree'] = $this->renderer->renderPlain($rendered_menu);
$build['#cache'] = [
'contexts' => ['url.path'],
'tags' => $tree['#cache']['tags'],
'contexts' => Cache::mergeContexts(['url.path'], $rendered_menu['#cache']['contexts'] ?? []),
'tags' => Cache::mergeTags($tree['#cache']['tags'], $rendered_menu['#cache']['tags'] ?? []),
];
return $build;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment