diff --git a/core/lib/Drupal/Core/Entity/EntityAccessCheck.php b/core/lib/Drupal/Core/Entity/EntityAccessCheck.php index 391db5b..f55567e 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessCheck.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessCheck.php @@ -28,21 +28,22 @@ public function applies(Route $route) { * Implements \Drupal\Core\Access\AccessCheckInterface::access(). * * The value of the '_entity_access' key must be in the pattern - * 'slug.operation.' The slug corresponds to the named param {slug}. - * This will check a node for 'update' access: + * 'entity_type.operation.' The entity type must match the {entity_type} + * parameter in the route pattern. This will check a node for 'update' access: * @code * pattern: '/foo/{node}/bar' * requirements: * _entity_access: 'node.update' * @endcode + * Available operations are 'view', 'update', 'create', and 'delete'. */ public function access(Route $route, Request $request) { - // Split the slug and the operation. + // Split the entity type and the operation. $requirement = $route->getRequirement('_entity_access'); - list($slug, $operation) = explode('.', $requirement); - // If this slug is in the request, and it is an entity, check its access. - if ($request->attributes->has($slug)) { - $entity = $request->attributes->get($slug); + list($entity_type, $operation) = explode('.', $requirement); + // If there is valid entity of the given entity type, check its access. + if ($request->attributes->has($entity_type)) { + $entity = $request->attributes->get($entity_type); if ($entity instanceof EntityInterface) { return $entity->access($operation); } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Access/SetDeleteAccessCheck.php b/core/modules/shortcut/lib/Drupal/shortcut/Access/SetDeleteAccessCheck.php deleted file mode 100644 index 738c071..0000000 --- a/core/modules/shortcut/lib/Drupal/shortcut/Access/SetDeleteAccessCheck.php +++ /dev/null @@ -1,36 +0,0 @@ -getRequirements()); - } - - /** - * Implements AccessCheckInterface::access(). - */ - public function access(Route $route, Request $request) { - if ($shortcut = $request->attributes->get('shortcut')) { - return $shortcut->access('delete'); - } - return FALSE; - } - -} diff --git a/core/modules/shortcut/shortcut.routing.yml b/core/modules/shortcut/shortcut.routing.yml index f653b5b..277853f 100644 --- a/core/modules/shortcut/shortcut.routing.yml +++ b/core/modules/shortcut/shortcut.routing.yml @@ -10,4 +10,4 @@ shortcut_set_delete: defaults: _form: 'Drupal\shortcut\Form\SetDelete' requirements: - _access_shortcut_set_delete: 'TRUE' + _entity_access: 'shortcut.delete' diff --git a/core/modules/shortcut/shortcut.services.yml b/core/modules/shortcut/shortcut.services.yml index 75f5395..bb95f49 100644 --- a/core/modules/shortcut/shortcut.services.yml +++ b/core/modules/shortcut/shortcut.services.yml @@ -3,7 +3,3 @@ services: class: Drupal\shortcut\Access\LinkDeleteAccessCheck tags: - { name: access_check } - access_check.shortcut.set: - class: Drupal\shortcut\Access\SetDeleteAccessCheck - tags: - - { name: access_check }