diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index d0d59fd..2bae45e 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -49,9 +49,7 @@ function config_test_menu() { ); $items['admin/structure/config_test/manage/%config_test/delete'] = array( 'title' => 'Delete', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('config_test_delete_form', 4), - 'access callback' => TRUE, + 'route_name' => 'config_test_delete', 'type' => MENU_LOCAL_TASK, ); $items['admin/structure/config_test/manage/%config_test/enable'] = array( diff --git a/core/modules/config/tests/config_test/config_test.routing.yml b/core/modules/config/tests/config_test/config_test.routing.yml new file mode 100644 index 0000000..92bb0a9 --- /dev/null +++ b/core/modules/config/tests/config_test/config_test.routing.yml @@ -0,0 +1,6 @@ +config_test_delete: + pattern: 'admin/structure/config_test/manage/{config_test}/delete' + defaults: + _form: '\Drupal\config_test\ConfigTestDeleteForm' + requirements: + _access: 'TRUE' diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestDeleteForm.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestDeleteForm.php new file mode 100644 index 0000000..9739cd0 --- /dev/null +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestDeleteForm.php @@ -0,0 +1,75 @@ + $this->configTest->label())); + } + + /** + * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). + */ + protected function getCancelPath() { + return 'admin/structure/config_test'; + } + + /** + * Overrides \Drupal\Core\Form\ConfirmFormBase::getConfirmText(). + */ + protected function getConfirmText() { + return t('Delete'); + } + + /** + * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm(). + * + * @param \Drupal\config_test\Plugin\Core\Entity\ConfigTest $config_test + * (optional) The ConfigTest object to delete. If NULL, your form is + * probably broken, but the interface gets pissy otherwise. + */ + public function buildForm(array $form, array &$form_state, ConfigTest $config_test = NULL) { + $this->configTest = $config_test; + parent::buildForm($form, $form_state); + } + + /** + * Implements \Drupal\Core\Form\FormInterface::submitForm(). + */ + public function submitForm(array &$form, array &$form_state) { + $label = $this->configTest->label(); + $this->configTest->delete(); + drupal_set_message(format_string('%label configuration has been deleted.', array('%label' => $label))); + } + +} +