Issue #1946318 by kim.pepper: Convert confirm_form() in action.admin.inc to the new form interface.
parent
139ba19155
commit
6a6c0654c7
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\action\Form\DeleteForm.
|
||||
*/
|
||||
|
||||
namespace Drupal\action\Form;
|
||||
|
||||
use Drupal\Core\Form\ConfirmFormBase;
|
||||
|
||||
/**
|
||||
* Builds a form to delete an action.
|
||||
*/
|
||||
class DeleteForm extends ConfirmFormBase {
|
||||
|
||||
/**
|
||||
* The action to be deleted.
|
||||
*
|
||||
* @var \stdClass
|
||||
*/
|
||||
protected $action;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getQuestion() {
|
||||
return t('Are you sure you want to delete the action %action?', array('%action' => $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';
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue