diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Access/SetDeleteAccessCheck.php b/core/modules/shortcut/lib/Drupal/shortcut/Access/SetDeleteAccessCheck.php index d3790de..738c071 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Access/SetDeleteAccessCheck.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Access/SetDeleteAccessCheck.php @@ -28,8 +28,9 @@ public function applies(Route $route) { */ public function access(Route $route, Request $request) { if ($shortcut = $request->attributes->get('shortcut')) { - return $shortcut->id() !== 'default'; + return $shortcut->access('delete'); } return FALSE; } + } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php b/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php index fd72e3c..010a220 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php @@ -20,6 +20,7 @@ * module = "shortcut", * controller_class = "Drupal\shortcut\ShortcutStorageController", * list_controller_class = "Drupal\shortcut\ShortcutListController", + * access_controller_class = "Drupal\shortcut\ShortcutAccessController", * form_controller_class = { * "default" = "Drupal\shortcut\ShortcutFormController" * }, diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php new file mode 100644 index 0000000..9c57a39 --- /dev/null +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php @@ -0,0 +1,30 @@ +id() != 'default'; + } + +} diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php index 059de38..db600fd 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php @@ -53,7 +53,7 @@ public function form(array $form, array &$form_state, EntityInterface $entity) { protected function actions(array $form, array &$form_state) { // Disable delete of default shortcut set. $actions = parent::actions($form, $form_state); - $actions['delete']['#access'] = shortcut_set_delete_access($this->getEntity($form_state)); + $actions['delete']['#access'] = $this->getEntity($form_state)->access('delete'); return $actions; } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php index 6cf8f9d8..f1aaa60 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php @@ -38,7 +38,7 @@ public function getOperations(EntityInterface $entity) { 'options' => $uri['options'], 'weight' => 10, ); - if (shortcut_set_delete_access($entity)) { + if ($entity->access('delete')) { $operations['delete'] = array( 'title' => t('Delete set'), 'href' => $uri['path'] . '/delete', diff --git a/core/modules/shortcut/shortcut.routing.yml b/core/modules/shortcut/shortcut.routing.yml index 522431e..f653b5b 100644 --- a/core/modules/shortcut/shortcut.routing.yml +++ b/core/modules/shortcut/shortcut.routing.yml @@ -10,5 +10,4 @@ shortcut_set_delete: defaults: _form: 'Drupal\shortcut\Form\SetDelete' requirements: - _permission: 'administer shortcuts' _access_shortcut_set_delete: 'TRUE'