diff --git a/core/lib/Drupal/Core/Entity/EntityAccessController.php b/core/lib/Drupal/Core/Entity/EntityAccessController.php index ad1c8be..128c28f 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessController.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php @@ -33,39 +33,30 @@ class EntityAccessController implements EntityAccessControllerInterface { protected $entityType; /** - * The module handler service. + * The entity info array. * - * @var \Drupal\Core\Extension\ModuleHandlerInterface + * @var array */ - protected $moduleHandler; + protected $entityInfo; /** - * The entity manager used to get the access plugin definition. + * The module handler service. * - * @var \Drupal\Core\Entity\EntityManager + * @var \Drupal\Core\Extension\ModuleHandlerInterface */ - protected $entityManager; + protected $moduleHandler; /** * Constructs an access controller instance. * * @param string $entity_type * The entity type of the access controller instance. + * @param array $entity_info + * An array of entity info for the entity type. */ - public function __construct($entity_type) { + public function __construct($entity_type, array $entity_info) { $this->entityType = $entity_type; - } - - /** - * Returns the entity manager. - * - * @return \Drupal\Core\Entity\EntityManager - */ - protected function entityManager() { - if (!isset($this->entityManager)) { - $this->entityManager = \Drupal::entityManager(); - } - return $this->entityManager; + $this->entityInfo = $entity_info; } /** @@ -146,9 +137,8 @@ protected function processAccessHookResults(array $access) { * could not be determined. */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { - $entity_info = $this->entityManager()->getDefinition($entity->entityType()); - if (!empty($entity_info['access_permission'])) { - return $account->hasPermission($entity_info['access_permission']); + if (!empty($this->entityInfo['admin_permission'])) { + return $account->hasPermission($this->entityInfo['admin_permission']); } else { return NULL; @@ -268,9 +258,8 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account = * could not be determined. */ protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) { - $entity_info = $this->entityManager()->getDefinition($entity->entityType()); - if (!empty($entity_info['access_permission'])) { - return $account->hasPermission($entity_info['access_permission']); + if (!empty($this->entityInfo['admin_permission'])) { + return $account->hasPermission($this->entityInfo['admin_permission']); } else { return NULL; diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index e9808d2..90bf5d1 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -354,7 +354,7 @@ protected function getController($entity_type, $controller_type) { $this->controllers[$controller_type][$entity_type] = $class::createInstance($this->container, $entity_type, $this->getDefinition($entity_type)); } else { - $this->controllers[$controller_type][$entity_type] = new $class($entity_type); + $this->controllers[$controller_type][$entity_type] = new $class($entity_type, $this->getDefinition($entity_type)); } } return $this->controllers[$controller_type][$entity_type]; diff --git a/core/modules/block/lib/Drupal/block/BlockAccessController.php b/core/modules/block/lib/Drupal/block/BlockAccessController.php index 7c61bc6..61bf3a1 100644 --- a/core/modules/block/lib/Drupal/block/BlockAccessController.php +++ b/core/modules/block/lib/Drupal/block/BlockAccessController.php @@ -32,11 +32,13 @@ class BlockAccessController extends EntityAccessController implements EntityCont * * @param string $entity_type * The entity type of the access controller instance. + * @param array $entity_info + * An array of entity info for the entity type. * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager * The alias manager. */ - public function __construct($entity_type, AliasManagerInterface $alias_manager) { - parent::__construct($entity_type); + public function __construct($entity_type, array $entity_info, AliasManagerInterface $alias_manager) { + parent::__construct($entity_type, $entity_info); $this->aliasManager = $alias_manager; } @@ -46,6 +48,7 @@ public function __construct($entity_type, AliasManagerInterface $alias_manager) public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( $entity_type, + $entity_info, $container->get('path.alias_manager') ); } diff --git a/core/modules/language/lib/Drupal/language/Entity/Language.php b/core/modules/language/lib/Drupal/language/Entity/Language.php index d400773..c1c1006 100644 --- a/core/modules/language/lib/Drupal/language/Entity/Language.php +++ b/core/modules/language/lib/Drupal/language/Entity/Language.php @@ -31,7 +31,7 @@ * "delete" = "Drupal\language\Form\LanguageDeleteForm" * } * }, - * access_permission = "administer languages", + * admin_permission = "administer languages", * config_prefix = "language.entity", * entity_keys = { * "id" = "id", diff --git a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php index 258edb2..616755f 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php @@ -33,7 +33,7 @@ * "default" = "Drupal\menu_link\MenuLinkFormController" * } * }, - * access_permission = "administer menu", + * admin_permission = "administer menu", * static_cache = FALSE, * base_table = "menu_links", * uri_callback = "menu_link_uri", diff --git a/core/modules/node/lib/Drupal/node/NodeAccessController.php b/core/modules/node/lib/Drupal/node/NodeAccessController.php index 0f06917..944b411 100644 --- a/core/modules/node/lib/Drupal/node/NodeAccessController.php +++ b/core/modules/node/lib/Drupal/node/NodeAccessController.php @@ -35,11 +35,13 @@ class NodeAccessController extends EntityAccessController implements NodeAccessC * * @param string $entity_type * The entity type of the access controller instance. + * @param array $entity_info + * An array of entity info for the entity type. * @param \Drupal\node\NodeGrantDatabaseStorageInterface $grant_storage * The node grant storage. */ - public function __construct($entity_type, NodeGrantDatabaseStorageInterface $grant_storage) { - parent::__construct($entity_type); + public function __construct($entity_type, array $entity_info, NodeGrantDatabaseStorageInterface $grant_storage) { + parent::__construct($entity_type, $entity_info); $this->grantStorage = $grant_storage; } @@ -49,6 +51,7 @@ public function __construct($entity_type, NodeGrantDatabaseStorageInterface $gra public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( $entity_type, + $entity_info, $container->get('node.grant_storage') ); } diff --git a/core/modules/system/lib/Drupal/system/Entity/Action.php b/core/modules/system/lib/Drupal/system/Entity/Action.php index f1176f0..e12ce4a 100644 --- a/core/modules/system/lib/Drupal/system/Entity/Action.php +++ b/core/modules/system/lib/Drupal/system/Entity/Action.php @@ -26,7 +26,7 @@ * "storage" = "Drupal\Core\Config\Entity\ConfigStorageController", * "access" = "\Drupal\Core\Entity\EntityAccessController" * }, - * access_permission = "administer actions", + * admin_permission = "administer actions", * config_prefix = "system.action", * entity_keys = { * "id" = "id", diff --git a/core/modules/user/lib/Drupal/user/Entity/Role.php b/core/modules/user/lib/Drupal/user/Entity/Role.php index 97269c9..d51ef15 100644 --- a/core/modules/user/lib/Drupal/user/Entity/Role.php +++ b/core/modules/user/lib/Drupal/user/Entity/Role.php @@ -27,7 +27,7 @@ * "delete" = "Drupal\user\Form\UserRoleDelete" * } * }, - * access_permission = "administer permission", + * admin_permission = "administer permission", * config_prefix = "user.role", * entity_keys = { * "id" = "id", diff --git a/core/modules/user/lib/Drupal/user/Entity/User.php b/core/modules/user/lib/Drupal/user/Entity/User.php index 8bd7e3a..074cd9b 100644 --- a/core/modules/user/lib/Drupal/user/Entity/User.php +++ b/core/modules/user/lib/Drupal/user/Entity/User.php @@ -30,7 +30,7 @@ * }, * "translation" = "Drupal\user\ProfileTranslationController" * }, - * access_permission = "administer user", + * admin_permission = "administer user", * base_table = "users", * uri_callback = "user_uri", * route_base_path = "admin/config/people/accounts", diff --git a/core/modules/views/lib/Drupal/views/Entity/View.php b/core/modules/views/lib/Drupal/views/Entity/View.php index 2b20f09..ceb423e 100644 --- a/core/modules/views/lib/Drupal/views/Entity/View.php +++ b/core/modules/views/lib/Drupal/views/Entity/View.php @@ -25,7 +25,7 @@ * "storage" = "Drupal\views\ViewStorageController", * "access" = "Drupal\views\ViewAccessController" * }, - * access_permission = "administer views", + * admin_permission = "administer views", * config_prefix = "views.view", * entity_keys = { * "id" = "id",