diff --git a/core/lib/Drupal/Core/Entity/EntityAccessController.php b/core/lib/Drupal/Core/Entity/EntityAccessController.php index b358690477915cf84d8f85b0864b7d443a0d5e08..4658d50f19741cebc067e15a6f9de8860c7f00aa 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessController.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php @@ -7,15 +7,13 @@ namespace Drupal\Core\Entity; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines a default implementation for entity access controllers. */ -class EntityAccessController implements EntityAccessControllerInterface, EntityControllerInterface { +class EntityAccessController implements EntityAccessControllerInterface { /** * Stores calculcated access check results. @@ -31,34 +29,14 @@ class EntityAccessController implements EntityAccessControllerInterface, EntityC */ protected $entityType; - /** - * The module handler - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - /** * Constructs an access controller instance. * * @param string $entity_type * The entity type of the access controller instance. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke access hooks with. - */ - public function __construct($entity_type, ModuleHandlerInterface $module_handler) { - $this->entityType = $entity_type; - $this->moduleHandler = $module_handler; - } - - /** - * {@inheritdoc} */ - public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { - return new static( - $entity_type, - $container->get('module_handler') - ); + public function __construct($entity_type) { + $this->entity_type = $entity_type; } /** @@ -80,7 +58,7 @@ public function access(EntityInterface $entity, $operation, $langcode = Language // We grant access to the entity if both of these conditions are met: // - No modules say to deny access. // - At least one module says to grant access. - $access = $this->moduleHandler->invokeAll($entity->entityType() . '_access', array($entity, $operation, $account, $langcode)); + $access = module_invoke_all($entity->entityType() . '_access', $entity, $operation, $account, $langcode); if (($return = $this->processAccessHookResults($access)) === NULL) { // No module had an opinion about the access, so let's the access @@ -218,7 +196,7 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account = // We grant access to the entity if both of these conditions are met: // - No modules say to deny access. // - At least one module says to grant access. - $access = $this->moduleHandler->invokeAll($this->entityType . '_create_access', array($account, $context['langcode'])); + $access = module_invoke_all($this->entity_type . '_create_access', $account, $context['langcode']); if (($return = $this->processAccessHookResults($access)) === NULL) { // No module had an opinion about the access, so let's the access diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index c6df9c1615061a65ce0035ac75cf61264456561e..ac975d1095033a3a81396ec5e00e03703edb1a4d 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -413,12 +413,14 @@ public function isEmpty() { * {@inheritdoc} */ public function access($operation = 'view', AccountInterface $account = NULL) { - $access_controller = \Drupal::entityManager()->getAccessController($this->entityType); - if ($operation == 'create') { - return $access_controller->createAccess($this->bundle(), $account); + return \Drupal::entityManager() + ->getAccessController($this->entityType) + ->createAccess($this->bundle(), $account); } - return $access_controller->access($this, $operation, $this->activeLangcode, $account); + return \Drupal::entityManager() + ->getAccessController($this->entityType) + ->access($this, $operation, $this->activeLangcode, $account); } /** diff --git a/core/modules/block/lib/Drupal/block/BlockAccessController.php b/core/modules/block/lib/Drupal/block/BlockAccessController.php index 8d29e01c640e490ea01e2533aede6cfbb1de4b5f..85f449e46ef24a7e1184e80ba9418837c2888b0f 100644 --- a/core/modules/block/lib/Drupal/block/BlockAccessController.php +++ b/core/modules/block/lib/Drupal/block/BlockAccessController.php @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityAccessController; use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Path\AliasManagerInterface; use Drupal\Component\Utility\Unicode; @@ -33,14 +32,11 @@ class BlockAccessController extends EntityAccessController implements EntityCont * * @param string $entity_type * The entity type of the access controller instance. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke access hooks with. * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager * The alias manager. */ - public function __construct($entity_type, ModuleHandlerInterface $module_handler, AliasManagerInterface $alias_manager) { - parent::__construct($entity_type, $module_handler); - + public function __construct($entity_type, AliasManagerInterface $alias_manager) { + parent::__construct($entity_type); $this->aliasManager = $alias_manager; } @@ -50,7 +46,6 @@ public function __construct($entity_type, ModuleHandlerInterface $module_handler public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( $entity_type, - $container->get('module_handler'), $container->get('path.alias_manager') ); } diff --git a/core/modules/node/lib/Drupal/node/NodeAccessController.php b/core/modules/node/lib/Drupal/node/NodeAccessController.php index 4dcb911a25f29ba3edb16d799467d7e53b98c77c..b1f120aeeb4ffc8a7ef32db657b05dd395652486 100644 --- a/core/modules/node/lib/Drupal/node/NodeAccessController.php +++ b/core/modules/node/lib/Drupal/node/NodeAccessController.php @@ -31,20 +31,27 @@ class NodeAccessController extends EntityAccessController implements NodeAccessC */ protected $grantStorage; + /** + * The module handler. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + /** * Constructs a NodeAccessController object. * * @param string $entity_type * The entity type of the access controller instance. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke access hooks with. * @param \Drupal\node\NodeGrantDatabaseStorageInterface $grant_storage * The node grant storage. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler to invoke the alter hook with. */ - public function __construct($entity_type, ModuleHandlerInterface $module_handler, NodeGrantDatabaseStorageInterface $grant_storage) { - parent::__construct($entity_type, $module_handler); - + public function __construct($entity_type, NodeGrantDatabaseStorageInterface $grant_storage, ModuleHandlerInterface $module_handler) { + parent::__construct($entity_type); $this->grantStorage = $grant_storage; + $this->moduleHandler = $module_handler; } /** @@ -53,8 +60,8 @@ public function __construct($entity_type, ModuleHandlerInterface $module_handler public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( $entity_type, - $container->get('module_handler'), - $container->get('node.grant_storage') + $container->get('node.grant_storage'), + $container->get('module_handler') ); }