diff --git a/core/modules/action/action.admin.inc b/core/modules/action/action.admin.inc index c9db258..ec1a197 100644 --- a/core/modules/action/action.admin.inc +++ b/core/modules/action/action.admin.inc @@ -6,82 +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 diff --git a/core/modules/action/action.module b/core/modules/action/action.module index 6396caf..2e787a2 100644 --- a/core/modules/action/action.module +++ b/core/modules/action/action.module @@ -67,7 +67,7 @@ function action_menu() { $items['admin/config/system/actions/manage'] = array( 'title' => 'Manage actions', 'description' => 'Manage the actions defined for your site.', - 'page callback' => 'action_admin_manage', + 'route_name' => 'action_admin_manage', 'type' => MENU_DEFAULT_LOCAL_TASK, 'file' => 'action.admin.inc', ); diff --git a/core/modules/action/action.routing.yml b/core/modules/action/action.routing.yml new file mode 100644 index 0000000..bca4b36 --- /dev/null +++ b/core/modules/action/action.routing.yml @@ -0,0 +1,6 @@ +action_admin_manage: + pattern: '/admin/config/system/actions/manage' + defaults: + _content: '\Drupal\action\Controller\ActionController::adminManage' + 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 new file mode 100644 index 0000000..2257cf9 --- /dev/null +++ b/core/modules/action/lib/Drupal/action/Controller/ActionController.php @@ -0,0 +1,93 @@ + $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) { + module_load_include('inc', 'action', 'action.admin'); + $build['action_admin_manage_form'] = drupal_get_form('action_admin_manage_form', $options); + } + + return $build; + } +}