diff --git a/core/lib/Drupal/Core/Entity/EntityAccessController.php b/core/lib/Drupal/Core/Entity/EntityAccessController.php index 833f292..5e24912 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessController.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php @@ -58,7 +58,7 @@ public function access(EntityInterface $entity, $operation, $langcode = Language // - At least one module says to grant access. $access = module_invoke_all($entity->entityType() . '_access', $entity->getBCEntity(), $operation, $account, $langcode); - if ($return = $this->processAccessHookResults($access) === NULL) { + if (($return = $this->processAccessHookResults($access)) === NULL) { // No module had an opinion about the access, so let's the access // controller check create access. $return = (bool) $this->checkAccess($entity, $operation, $langcode, $account); @@ -178,7 +178,7 @@ public function resetCache() { /** * {@inheritdoc} */ - public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, $context = array()) { + public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array()) { $account = $this->prepareUser($account); $context += array( 'langcode' => Language::LANGCODE_DEFAULT, @@ -200,10 +200,10 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account = // - At least one module says to grant access. $access = module_invoke_all($this->entity_type . '_create_access', $account, $context['langcode']); - if ($return = $this->processAccessHookResults($access) === NULL) { + if (($return = $this->processAccessHookResults($access)) === NULL) { // No module had an opinion about the access, so let's the access // controller check create access. - $return = (bool) $this->checkCreateAccess($account, $context, $entity_bundle = NULL); + $return = (bool) $this->checkCreateAccess($account, $context, $entity_bundle); } return $this->setCache($return, $cid, 'create', $context['langcode'], $account); } diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php index c8c77c1..7db038a 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php @@ -45,9 +45,10 @@ public function access(EntityInterface $entity, $operation, $langcode = Language * (optional) The user session for which to check access, or NULL to check * access for the current user. Defaults to NULL. * @param array $context - * An array of key-value pairs to pass additional context when needed. + * (optional) An array of key-value pairs to pass additional context when + * needed. */ - public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, $context = array()); + public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array()); /** * Clears all cached access checks. diff --git a/core/modules/node/lib/Drupal/node/NodeAccessController.php b/core/modules/node/lib/Drupal/node/NodeAccessController.php index 8d976ee..2b402ba 100644 --- a/core/modules/node/lib/Drupal/node/NodeAccessController.php +++ b/core/modules/node/lib/Drupal/node/NodeAccessController.php @@ -34,7 +34,7 @@ public function access(EntityInterface $entity, $operation, $langcode = Language /** * {@inheritdoc} */ - public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, $context = array()) { + public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array()) { $account = $this->prepareUser($account); if (user_access('bypass node access', $account)) { @@ -44,20 +44,7 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account = return FALSE; } - $access = module_invoke_all('node_create_access', $account, $context); - - $configured_types = node_permissions_get_configured_types(); - if (isset($configured_types[$entity_bundle])) { - if (user_access('create ' . $entity_bundle . ' content', $account)) { - $access[] = NODE_ACCESS_ALLOW; - } - } - - if ($return = $this->processAccessHookResults($access) !== NULL) { - return $return; - } - - return NODE_ACCESS_DENY; + return parent::createAccess($entity_bundle, $account, $context); } /** @@ -95,6 +82,16 @@ protected function checkAccess(EntityInterface $node, $operation, $langcode, Acc } /** + * {@inheritdoc} + */ + protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) { + $configured_types = node_permissions_get_configured_types(); + if (isset($configured_types[$entity_bundle])) { + return user_access('create ' . $entity_bundle . ' content', $account); + } + } + + /** * Determines access to nodes based on node grants. * * @param \Drupal\Core\Entity\EntityInterface $node diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 33c0379..cba08c7 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -2164,6 +2164,9 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) { elseif ($node instanceof NodeTypeInterface) { $bundle = $node->id(); } + else { + $bundle = $node->bundle(); + } } else { @@ -2186,7 +2189,7 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) { } if ($op == 'create') { - return $access_controller->createAccess($bundle, $langcode, $account); + return $access_controller->createAccess($bundle, $account, array('langcode' => $langcode)); } else { return $access_controller->access($node, $op, $langcode, $account);