diff --git a/core/modules/action/action.admin.inc b/core/modules/action/action.admin.inc
index c9db258..822284c 100644
--- a/core/modules/action/action.admin.inc
+++ b/core/modules/action/action.admin.inc
@@ -6,125 +6,6 @@
*/
/**
- * Menu callback; Displays an overview of available and configured actions.
- */
-function action_admin_manage() {
- action_synchronize();
- $actions = action_list();
- $actions_map = action_actions_map($actions);
- $options = array();
- $unconfigurable = array();
-
- foreach ($actions_map as $key => $array) {
- if ($array['configurable']) {
- $options[$key] = $array['label'] . '...';
- }
- else {
- $unconfigurable[] = $array;
- }
- }
-
- $row = array();
- $instances_present = db_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')
- ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
- ->extend('Drupal\Core\Database\Query\TableSortExtender');
- $result = $query
- ->fields('actions')
- ->limit(50)
- ->orderByHeader($header)
- ->execute();
-
- foreach ($result as $action) {
- $row = array();
- $row[] = $action->type;
- $row[] = check_plain($action->label);
- $links = array();
- if ($action->parameters) {
- $links['configure'] = array(
- 'title' => t('configure'),
- 'href' => "admin/config/system/actions/configure/$action->aid",
- );
- $links['delete'] = array(
- 'title' => t('delete'),
- 'href' => "admin/config/system/actions/delete/$action->aid",
- );
- }
- $row[] = array(
- 'data' => array(
- '#type' => 'operations',
- '#links' => $links,
- ),
- );
-
- $rows[] = $row;
- }
-
- if ($rows) {
- $pager = theme('pager');
- if (!empty($pager)) {
- $rows[] = array(array('data' => $pager, 'colspan' => '3'));
- }
- $build['action_header'] = array('#markup' => '
' . t('Available actions:') . '
');
- $build['action_table'] = array('#markup' => theme('table', array('header' => $header, 'rows' => $rows)));
- }
-
- if ($actions_map) {
- $build['action_admin_manage_form'] = drupal_get_form('action_admin_manage_form', $options);
- }
-
- return $build;
-}
-
-/**
- * Define the form for the actions overview page.
- *
- * @param $form_state
- * An associative array containing the current state of the form; not used.
- * @param $options
- * An array of configurable actions.
- * @return
- * Form definition.
- *
- * @ingroup forms
- * @see action_admin_manage_form_submit()
- */
-function action_admin_manage_form($form, &$form_state, $options = array()) {
- $form['parent'] = array(
- '#type' => 'details',
- '#title' => t('Create an advanced action'),
- '#attributes' => array('class' => array('container-inline')),
- );
- $form['parent']['action'] = array(
- '#type' => 'select',
- '#title' => t('Action'),
- '#title_display' => 'invisible',
- '#options' => $options,
- '#empty_option' => t('Choose an advanced action'),
- );
- $form['parent']['actions'] = array('#type' => 'actions');
- $form['parent']['actions']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Create'),
- );
- return $form;
-}
-
-/**
- * Form submission handler for action_admin_manage_form().
- */
-function action_admin_manage_form_submit($form, &$form_state) {
- if ($form_state['values']['action']) {
- $form_state['redirect'] = 'admin/config/system/actions/configure/' . $form_state['values']['action'];
- }
-}
-
-/**
* Form constructor for the configuration of a single action.
*
* We provide the "Description" field. The rest of the form is provided by the
@@ -287,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 6396caf..4d8fc04 100644
--- a/core/modules/action/action.module
+++ b/core/modules/action/action.module
@@ -60,16 +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',
);
$items['admin/config/system/actions/manage'] = array(
'title' => 'Manage actions',
'description' => 'Manage the actions defined for your site.',
- 'page callback' => 'action_admin_manage',
'type' => MENU_DEFAULT_LOCAL_TASK,
- 'file' => 'action.admin.inc',
+ 'route_name' => 'action_admin_manage',
);
$items['admin/config/system/actions/configure'] = array(
'title' => 'Configure an advanced action',
@@ -89,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
new file mode 100644
index 0000000..c4a2c0a
--- /dev/null
+++ b/core/modules/action/action.routing.yml
@@ -0,0 +1,20 @@
+action_admin:
+ pattern: '/admin/config/system/actions'
+ defaults:
+ _content: '\Drupal\action\Controller\ActionController::adminManage'
+ requirements:
+ _permission: 'administer actions'
+
+action_admin_manage:
+ pattern: '/admin/config/system/actions/manage'
+ 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/ActionAdminManageForm.php b/core/modules/action/lib/Drupal/action/ActionAdminManageForm.php
new file mode 100644
index 0000000..74a61ad
--- /dev/null
+++ b/core/modules/action/lib/Drupal/action/ActionAdminManageForm.php
@@ -0,0 +1,66 @@
+ 'details',
+ '#title' => t('Create an advanced action'),
+ '#attributes' => array('class' => array('container-inline')),
+ );
+ $form['parent']['action'] = array(
+ '#type' => 'select',
+ '#title' => t('Action'),
+ '#title_display' => 'invisible',
+ '#options' => $options,
+ '#empty_option' => t('Choose an advanced action'),
+ );
+ $form['parent']['actions'] = array('#type' => 'actions');
+ $form['parent']['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Create'),
+ );
+ return $form;
+ }
+
+ /**
+ * Implements \Drupal\Core\Form\FormInterface::validateForm().
+ */
+ public function validateForm(array &$form, array &$form_state) { }
+
+ /**
+ * Implements \Drupal\Core\Form\FormInterface::submitForm().
+ */
+ public function submitForm(array &$form, array &$form_state) {
+ if ($form_state['values']['action']) {
+ $form_state['redirect'] = 'admin/config/system/actions/configure/' . $form_state['values']['action'];
+ }
+ }
+}
diff --git a/core/modules/action/lib/Drupal/action/Controller/ActionController.php b/core/modules/action/lib/Drupal/action/Controller/ActionController.php
new file mode 100644
index 0000000..e4b5d92
--- /dev/null
+++ b/core/modules/action/lib/Drupal/action/Controller/ActionController.php
@@ -0,0 +1,127 @@
+get('database'));
+ }
+
+ /**
+ * Constructs a new ActionController.
+ *
+ * @param \Drupal\Core\Database\Connection $database
+ */
+ public function __construct(Connection $database) {
+ $this->database = $database;
+ }
+ /**
+ * Displays an overview of available and configured actions.
+ */
+ public function adminManage() {
+ action_synchronize();
+ $actions = action_list();
+ $actions_map = action_actions_map($actions);
+ $options = array();
+ $unconfigurable = array();
+
+ foreach ($actions_map as $key => $array) {
+ if ($array['configurable']) {
+ $options[$key] = $array['label'] . '...';
+ }
+ else {
+ $unconfigurable[] = $array;
+ }
+ }
+
+ $row = array();
+ $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 = $this->database->select('actions')
+ ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
+ ->extend('Drupal\Core\Database\Query\TableSortExtender');
+ $result = $query
+ ->fields('actions')
+ ->limit(50)
+ ->orderByHeader($header)
+ ->execute();
+
+ foreach ($result as $action) {
+ $row = array();
+ $row[] = $action->type;
+ $row[] = check_plain($action->label);
+ $links = array();
+ if ($action->parameters) {
+ $links['configure'] = array(
+ 'title' => t('configure'),
+ 'href' => "admin/config/system/actions/configure/$action->aid",
+ );
+ $links['delete'] = array(
+ 'title' => t('delete'),
+ 'href' => "admin/config/system/actions/delete/$action->aid",
+ );
+ }
+ $row[] = array(
+ 'data' => array(
+ '#type' => 'operations',
+ '#links' => $links,
+ ),
+ );
+
+ $rows[] = $row;
+ }
+
+ if ($rows) {
+ $pager = theme('pager');
+ if (!empty($pager)) {
+ $rows[] = array(array('data' => $pager, 'colspan' => '3'));
+ }
+ $build['action_header'] = array('#markup' => '' . t('Available actions:') . '
');
+ $build['action_table'] = array('#markup' => theme('table', array('header' => $header, 'rows' => $rows)));
+ }
+
+ if ($actions_map) {
+ $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'));
+ }
+
+}