Skip to content
Snippets Groups Projects
Commit c22a2abc authored by Peter Törnstrand's avatar Peter Törnstrand Committed by Mattias Axelsson
Browse files

Issue #3382255 by Peter Törnstrand: Cache error

parent 2f991947
No related branches found
No related tags found
No related merge requests found
......@@ -17,8 +17,8 @@ use Drupal\node\NodeInterface;
function toolbar_edit_page_button_toolbar() {
$node = \Drupal::routeMatch()->getParameter('node');
$permission = \Drupal::currentUser()->hasPermission('access toolbar edit page button');
$items = [];
if ($permission && $node instanceof NodeInterface) {
$items = [];
$nid = $node->id();
$items['toolbar_edit_page_button'] = [
'#type' => 'toolbar_item',
......@@ -40,6 +40,25 @@ function toolbar_edit_page_button_toolbar() {
],
],
];
return $items;
}
else {
$items['toolbar_edit_page_button'] = [
'#type' => 'toolbar_item',
'tab' => [
'#type' => 'link',
'#title' => t('Edit page'),
'#url' => Url::fromRoute('<front>'),
'#cache' => [
'contexts' => [
'url.path',
],
],
],
'#wrapper_attributes' => [
'class' => ['edit-toolbar-tab', 'visually-hidden'],
],
];
}
return $items;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment