diff --git a/core/modules/action/action.admin.inc b/core/modules/action/action.admin.inc index 2f94445..822284c 100644 --- a/core/modules/action/action.admin.inc +++ b/core/modules/action/action.admin.inc @@ -168,10 +168,3 @@ function action_admin_delete_orphans_post($orphaned) { } } -/** - * Removes actions that are in the database but not supported by any enabled module. - */ -function action_admin_remove_orphans() { - action_synchronize(TRUE); - drupal_goto('admin/config/system/actions/manage'); -} diff --git a/core/modules/action/action.module b/core/modules/action/action.module index 1f9c77b..f669441 100644 --- a/core/modules/action/action.module +++ b/core/modules/action/action.module @@ -60,15 +60,13 @@ function action_menu() { $items['admin/config/system/actions'] = array( 'title' => 'Actions', 'description' => 'Manage the actions defined for your site.', - 'access arguments' => array('administer actions'), - 'page callback' => 'action_admin_manage', - 'file' => 'action.admin.inc', + 'route_name' => 'action_admin_manage', ); $items['admin/config/system/actions/manage'] = array( 'title' => 'Manage actions', 'description' => 'Manage the actions defined for your site.', - 'route_name' => 'action_admin_manage', 'type' => MENU_DEFAULT_LOCAL_TASK, + 'route_name' => 'action_admin_manage', ); $items['admin/config/system/actions/configure'] = array( 'title' => 'Configure an advanced action', @@ -88,10 +86,9 @@ function action_menu() { ); $items['admin/config/system/actions/orphan'] = array( 'title' => 'Remove orphans', - 'page callback' => 'action_admin_remove_orphans', - 'access arguments' => array('administer actions'), + 'description' => 'Remove actions that are in the database but not supported by any enabled module.', + 'route_name' => 'action_admin_orphans_remove', 'type' => MENU_CALLBACK, - 'file' => 'action.admin.inc', ); return $items; } diff --git a/core/modules/action/action.routing.yml b/core/modules/action/action.routing.yml index bca4b36..43f24c2 100644 --- a/core/modules/action/action.routing.yml +++ b/core/modules/action/action.routing.yml @@ -1,6 +1,13 @@ action_admin_manage: - pattern: '/admin/config/system/actions/manage' + pattern: '/admin/config/system/actions' defaults: _content: '\Drupal\action\Controller\ActionController::adminManage' requirements: _permission: 'administer actions' + +action_admin_orphans_remove: + pattern: '/admin/config/system/actions/orphan' + defaults: + _content: '\Drupal\action\Controller\ActionController::adminRemoveOrphans' + requirements: + _permission: 'administer actions' diff --git a/core/modules/action/lib/Drupal/action/Controller/ActionController.php b/core/modules/action/lib/Drupal/action/Controller/ActionController.php index 93e2990..1f3de51 100644 --- a/core/modules/action/lib/Drupal/action/Controller/ActionController.php +++ b/core/modules/action/lib/Drupal/action/Controller/ActionController.php @@ -1,19 +1,31 @@ get('database')); } + public function __construct(Connection $database) { + $this->database = $database; + } /** * Displays an overview of available and configured actions. */ @@ -34,13 +46,13 @@ public function adminManage() { } $row = array(); - $instances_present = db_query("SELECT aid FROM {actions} WHERE parameters <> ''")->fetchField(); + $instances_present = $this->database->query("SELECT aid FROM {actions} WHERE parameters <> ''")->fetchField(); $header = array( array('data' => t('Action type'), 'field' => 'type'), array('data' => t('Label'), 'field' => 'label'), $instances_present ? t('Operations') : '', ); - $query = db_select('actions') + $query = $this->database->select('actions') ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->extend('Drupal\Core\Database\Query\TableSortExtender'); $result = $query @@ -84,9 +96,18 @@ public function adminManage() { } if ($actions_map) { - $build['action_admin_manage_form'] = drupal_get_form(new \Drupal\action\ActionAdminManageForm(), $options); + $build['action_admin_manage_form'] = drupal_get_form(new ActionAdminManageForm(), $options); } return $build; } + + /** + * Removes actions that are in the database but not supported by any enabled module. + */ + public function adminRemoveOrphans() { + action_synchronize(TRUE); + return new RedirectResponse(url('admin/config/system/actions')); + } + }