public function OverridesSectionStorage::access in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::access()
- 9 core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::access()
File
- core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php, line 339
Class
- OverridesSectionStorage
- Defines the 'overrides' section storage type.
Namespace
Drupal\layout_builder\Plugin\SectionStorage
Code
public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) {
if ($account === NULL) {
$account = $this->currentUser;
}
$entity = $this
->getEntity();
$any_access = AccessResult::allowedIfHasPermission($account, 'configure any layout');
$bundle_access = AccessResult::allowedIfHasPermission($account, "configure all {$entity->bundle()} {$entity->getEntityTypeId()} layout overrides");
$edit_only_bundle_access = AccessResult::allowedIfHasPermission($account, "configure editable {$entity->bundle()} {$entity->getEntityTypeId()} layout overrides");
$edit_only_bundle_access = $edit_only_bundle_access
->andIf($entity
->access('update', $account, TRUE));
$result = $any_access
->orIf($bundle_access)
->orIf($edit_only_bundle_access);
$result = $result
->andIf($this
->getDefaultSectionStorage()
->access($operation, $account, TRUE));
$result = $this
->handleTranslationAccess($result, $operation, $account);
return $return_as_object ? $result : $result
->isAllowed();
}