Skip to content
Snippets Groups Projects
Commit 6099ebeb authored by Sorin Dediu's avatar Sorin Dediu
Browse files

Issue #3392780 by john.oltman, viren18febs, mauhg, carlos romero, rajab...

Issue #3392780 by john.oltman, viren18febs, mauhg, carlos romero, rajab natshah: Fix not valid context for entity context when editing the default layout entity types or bundles
parent 7fc2ce6e
Branches
Tags
No related merge requests found
......@@ -32,6 +32,7 @@ function layout_builder_perms_element_info_alter(array &$info) {
function layout_builder_perms_preprocess_links(&$variables) {
// Only act on the inline blocks link list. Check is a bit hacky. We might
// want to improve on this later.
if (isset($variables['attributes'], $variables['attributes']['class'])) {
if (!in_array('inline-block-list', $variables['attributes']['class'])) {
return;
}
......@@ -41,6 +42,7 @@ function layout_builder_perms_preprocess_links(&$variables) {
$link['link']['#access'] = LayoutBuilderElement::elementAccess($link['link']);
}
}
}
/**
* Implements hook_preprocess_HOOK() for item_list.
......
......@@ -101,7 +101,14 @@ class AccessManager implements AccessManagerInterface {
// Create a list of filters to only load plugins we need.
[$component, $action] = explode('_', $operation);
$layout = $route_match ? $this->getLayoutFromRouteMatch($route_match, $section_storage) : NULL;
try {
$entity = $section_storage->getContextValue('entity');
}
catch (ContextException $e) {
$entity = NULL;
}
if ($entity) {
$filters = [
'operation' => $operation,
'component' => $component,
......@@ -122,6 +129,7 @@ class AccessManager implements AccessManagerInterface {
$result = $result->andIf($permission_plugin->access($operation, $account));
}
}
}
return $return_as_object ? $result : $result->isAllowed();
}
......@@ -204,7 +212,7 @@ class AccessManager implements AccessManagerInterface {
// Allow other modules to add additional contexts.
if ($plugin instanceof LayoutBuilderPermissionInterface) {
$event = new LayoutBuilderPermissionPluginContexts($plugin, $operation, $route_match, $section_storage);
\Drupal::service('event_dispatcher')->dispatch($event);
\Drupal::service('event_dispatcher')->dispatch($event, LayoutBuilderPermissionPluginContexts::EVENT_NAME);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment