Commit 62eebd61 authored by alexpott's avatar alexpott

Issue #1978964 by sanchiz: Convert...

Issue #1978964 by sanchiz: Convert admin/config/user-interface/shortcut/manage/%shortcut_set()/edit to a Controller.
parent 77b4b22a
......@@ -24,7 +24,8 @@
* "access" = "Drupal\shortcut\ShortcutAccessController",
* "list" = "Drupal\shortcut\ShortcutListController",
* "form" = {
* "default" = "Drupal\shortcut\ShortcutFormController"
* "default" = "Drupal\shortcut\ShortcutFormController",
* "edit" = "Drupal\shortcut\ShortcutFormController"
* }
* },
* config_prefix = "shortcut.set",
......
......@@ -20,12 +20,22 @@ class ShortcutAccessController extends EntityAccessController {
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, User $account) {
if ($operation == 'delete') {
if (!user_access('administer shortcuts', $account)) {
switch ($operation) {
case 'edit':
if (user_access('administer shortcuts', $account)) {
return TRUE;
}
if (user_access('customize shortcut links', $account)) {
return !isset($entity) || $entity == shortcut_current_displayed_set($account);
}
return FALSE;
}
return $entity->id() != 'default';
break;
case 'delete':
if (!user_access('administer shortcuts', $account)) {
return FALSE;
}
return $entity->id() != 'default';
break;
}
}
}
......@@ -89,12 +89,8 @@ function shortcut_menu() {
);
$items['admin/config/user-interface/shortcut/manage/%shortcut_set/edit'] = array(
'title' => 'Edit set name',
'page callback' => 'entity_get_form',
'page arguments' => array(5),
'access callback' => 'shortcut_set_edit_access',
'access arguments' => array(5),
'route_name' => 'shortcut_set_edit',
'type' => MENU_LOCAL_TASK,
'file' => 'shortcut.admin.inc',
'weight' => 10,
);
$items['admin/config/user-interface/shortcut/manage/%shortcut_set/delete'] = array(
......
......@@ -18,3 +18,9 @@ shortcut_set_admin:
_content: 'Drupal\shortcut\Controller\ShortcutController::shortcutSetAdmin'
requirements:
_permission: 'administer shortcuts'
shortcut_set_edit:
pattern: '/admin/config/user-interface/shortcut/manage/{shortcut}/edit'
defaults:
_entity_form: 'shortcut.edit'
requirements:
_entity_access: 'shortcut.edit'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment