diff --git a/core/modules/action/action.admin.inc b/core/modules/action/action.admin.inc index 4ce7418b5a8..89202c300a6 100644 --- a/core/modules/action/action.admin.inc +++ b/core/modules/action/action.admin.inc @@ -5,38 +5,6 @@ * Admin page callbacks for the Action module. */ -/** - * Creates the form for confirmation of deleting an action. - * - * @see action_admin_delete_form_submit() - * @ingroup forms - */ -function action_admin_delete_form($form, &$form_state, $action) { - $form['aid'] = array( - '#type' => 'hidden', - '#value' => $action->aid, - ); - return confirm_form($form, - t('Are you sure you want to delete the action %action?', array('%action' => $action->label)), - 'admin/config/system/actions', - t('This cannot be undone.'), - t('Delete'), - t('Cancel') - ); -} - -/** - * Form submission handler for action_admin_delete_form(). - */ -function action_admin_delete_form_submit($form, &$form_state) { - $aid = $form_state['values']['aid']; - $action = action_load($aid); - action_delete($aid); - watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $aid, '%action' => $action->label)); - drupal_set_message(t('Action %action was deleted', array('%action' => $action->label))); - $form_state['redirect'] = 'admin/config/system/actions'; -} - /** * Post-deletion operations for deleting action orphans. * @@ -48,4 +16,3 @@ function action_admin_delete_orphans_post($orphaned) { drupal_set_message(t("Deleted orphaned action (%action).", array('%action' => $callback))); } } - diff --git a/core/modules/action/action.module b/core/modules/action/action.module index 24436ea85fe..a4e259f2115 100644 --- a/core/modules/action/action.module +++ b/core/modules/action/action.module @@ -75,10 +75,7 @@ function action_menu() { $items['admin/config/system/actions/delete/%action'] = array( 'title' => 'Delete action', 'description' => 'Delete an action.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('action_admin_delete_form', 5), - 'access arguments' => array('administer actions'), - 'file' => 'action.admin.inc', + 'route_name' => 'action_delete', ); return $items; } diff --git a/core/modules/action/action.routing.yml b/core/modules/action/action.routing.yml index 46f575e989a..a7ed7b900bc 100644 --- a/core/modules/action/action.routing.yml +++ b/core/modules/action/action.routing.yml @@ -18,3 +18,11 @@ action_admin_configure: _form: '\Drupal\action\Form\ActionAdminConfigureForm' requirements: _permission: 'administer actions' + +action_delete: + pattern: 'admin/config/system/actions/delete/{action}' + defaults: + _form: '\Drupal\action\Form\DeleteForm' + requirements: + _permission: 'administer actions' + diff --git a/core/modules/action/lib/Drupal/action/Form/DeleteForm.php b/core/modules/action/lib/Drupal/action/Form/DeleteForm.php new file mode 100644 index 00000000000..1d1885a3bdb --- /dev/null +++ b/core/modules/action/lib/Drupal/action/Form/DeleteForm.php @@ -0,0 +1,76 @@ + $this->action->label)); + } + + /** + * {@inheritdoc} + */ + protected function getConfirmText() { + return t('Delete'); + } + + + /** + * {@inheritdoc} + */ + protected function getCancelPath() { + return 'admin/config/system/actions/manage'; + } + + /** + * {@inheritdoc} + */ + public function getFormID() { + return 'action_admin_delete_form'; + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, array &$form_state, $action = NULL) { + + $this->action = action_load($action); + + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, array &$form_state) { + + action_delete($this->action->aid); + + watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $this->action->aid, '%action' => $this->action->label)); + drupal_set_message(t('Action %action was deleted', array('%action' => $this->action->label))); + + $form_state['redirect'] = 'admin/config/system/actions/manage'; + } + +}