diff --git a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php new file mode 100644 index 0000000..8e0292b --- /dev/null +++ b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php @@ -0,0 +1,108 @@ +request = $request; + $form = parent::buildForm($form, $form_state); + + $form['#attributes']['class'][] = 'confirmation'; + $form['description'] = array('#markup' => $this->getDescription()); + $form[$this->getFormName()] = array('#type' => 'hidden', '#value' => 1); + + // By default, render the form using theme_confirm_form(). + if (!isset($form['#theme'])) { + $form['#theme'] = 'confirm_form'; + } + return $form; + } + + /** + * {@inheritdoc} + */ + protected function init(array &$form_state) { + parent::init($form_state); + + drupal_set_title($this->getQuestion(), PASS_THROUGH); + } + + /** + * {@inheritdoc} + */ + protected function actions(array $form, array &$form_state) { + $actions = parent::actions($form, $form_state); + $actions['submit']['#value'] = $this->getConfirmText(); + unset($actions['delete']); + + $path = $this->getCancelPath(); + // Prepare cancel link. + if ($this->request->query->has('destination')) { + $options = drupal_parse_url($this->request->query->get('destination')); + } + elseif (is_array($path)) { + $options = $path; + } + else { + $options = array('path' => $path); + } + $actions['cancel'] = array( + '#type' => 'link', + '#title' => $this->getCancelText(), + '#href' => $options['path'], + '#options' => $options, + ); + return $actions; + } + +} diff --git a/core/lib/Drupal/Core/Entity/EntityNGConfirmFormBase.php b/core/lib/Drupal/Core/Entity/EntityNGConfirmFormBase.php new file mode 100644 index 0000000..1c345a0 --- /dev/null +++ b/core/lib/Drupal/Core/Entity/EntityNGConfirmFormBase.php @@ -0,0 +1,108 @@ +request = $request; + $form = parent::buildForm($form, $form_state); + + $form['#attributes']['class'][] = 'confirmation'; + $form['description'] = array('#markup' => $this->getDescription()); + $form[$this->getFormName()] = array('#type' => 'hidden', '#value' => 1); + + // By default, render the form using theme_confirm_form(). + if (!isset($form['#theme'])) { + $form['#theme'] = 'confirm_form'; + } + return $form; + } + + /** + * {@inheritdoc} + */ + protected function init(array &$form_state) { + parent::init($form_state); + + drupal_set_title($this->getQuestion(), PASS_THROUGH); + } + + /** + * {@inheritdoc} + */ + protected function actions(array $form, array &$form_state) { + $actions = parent::actions($form, $form_state); + $actions['submit']['#value'] = $this->getConfirmText(); + unset($actions['delete']); + + $path = $this->getCancelPath(); + // Prepare cancel link. + if ($this->request->query->has('destination')) { + $options = drupal_parse_url($this->request->query->get('destination')); + } + elseif (is_array($path)) { + $options = $path; + } + else { + $options = array('path' => $path); + } + $actions['cancel'] = array( + '#type' => 'link', + '#title' => $this->getCancelText(), + '#href' => $options['path'], + '#options' => $options, + ); + return $actions; + } + +} diff --git a/core/lib/Drupal/Core/Form/ConfirmFormBase.php b/core/lib/Drupal/Core/Form/ConfirmFormBase.php index 2aedb41..e5899c5 100644 --- a/core/lib/Drupal/Core/Form/ConfirmFormBase.php +++ b/core/lib/Drupal/Core/Form/ConfirmFormBase.php @@ -7,80 +7,49 @@ namespace Drupal\Core\Form; +use Symfony\Component\HttpFoundation\Request; + /** * Provides an generic base class for a confirmation form. */ -abstract class ConfirmFormBase implements FormInterface { +abstract class ConfirmFormBase implements ConfirmFormInterface { /** - * Returns the question to ask the user. - * - * @return string - * The form question. The page title will be set to this value. + * {@inheritdoc} */ - abstract protected function getQuestion(); - - /** - * Returns the page to go to if the user cancels the action. - * - * @return string|array - * This can be either: - * - A string containing a Drupal path. - * - An associative array with a 'path' key. Additional array values are - * passed as the $options parameter to l(). - * If the 'destination' query parameter is set in the URL when viewing a - * confirmation form, that value will be used instead of this path. - */ - abstract protected function getCancelPath(); - - /** - * Returns additional text to display as a description. - * - * @return string - * The form description. - */ - protected function getDescription() { + public function getDescription() { return t('This action cannot be undone.'); } /** - * Returns a caption for the button that confirms the action. - * - * @return string - * The form confirmation text. + * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Confirm'); } /** - * Returns a caption for the link which cancels the action. - * - * @return string - * The form cancellation text. + * {@inheritdoc} */ - protected function getCancelText() { + public function getCancelText() { return t('Cancel'); } /** - * Returns the internal name used to refer to the confirmation item. - * - * @return string - * The internal form name. + * {@inheritdoc} */ - protected function getFormName() { + public function getFormName() { return 'confirm'; } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, array &$form_state, Request $request = NULL) { $path = $this->getCancelPath(); // Prepare cancel link. - if (isset($_GET['destination'])) { - $options = drupal_parse_url($_GET['destination']); + if ($request->query->has('destination')) { + $options = drupal_parse_url($request->query->get('destination')); } elseif (is_array($path)) { $options = $path; @@ -114,7 +83,7 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::validateForm(). + * {@inheritdoc} */ public function validateForm(array &$form, array &$form_state) { } diff --git a/core/lib/Drupal/Core/Form/ConfirmFormInterface.php b/core/lib/Drupal/Core/Form/ConfirmFormInterface.php new file mode 100644 index 0000000..5c34f9a --- /dev/null +++ b/core/lib/Drupal/Core/Form/ConfirmFormInterface.php @@ -0,0 +1,68 @@ + $this->entity->label())); + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return t('Delete'); + } + + /** + * {@inheritdoc} + */ + public function getCancelPath() { + return 'admin/config/system/actions'; + } + + /** + * {@inheritdoc} + */ + public function submit(array $form, array &$form_state) { + $this->entity->delete(); + + watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $this->entity->id(), '%action' => $this->entity->label())); + drupal_set_message(t('Action %action was deleted', array('%action' => $this->entity->label()))); + + $form_state['redirect'] = 'admin/config/system/actions'; + } + +} diff --git a/core/modules/action/lib/Drupal/action/Form/DeleteForm.php b/core/modules/action/lib/Drupal/action/Form/DeleteForm.php deleted file mode 100644 index a3d2b3c..0000000 --- a/core/modules/action/lib/Drupal/action/Form/DeleteForm.php +++ /dev/null @@ -1,75 +0,0 @@ - $this->action->label())); - } - - /** - * {@inheritdoc} - */ - protected function getConfirmText() { - return t('Delete'); - } - - - /** - * {@inheritdoc} - */ - protected function getCancelPath() { - return 'admin/config/system/actions'; - } - - /** - * {@inheritdoc} - */ - public function getFormID() { - return 'action_admin_delete_form'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, array &$form_state, ActionConfigEntityInterface $action = NULL) { - $this->action = $action; - - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - $this->action->delete(); - - watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $this->action->id(), '%action' => $this->action->label())); - drupal_set_message(t('Action %action was deleted', array('%action' => $this->action->label()))); - - $form_state['redirect'] = 'admin/config/system/actions'; - } - -} diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 6bb3089..ebc45bd 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -371,27 +371,6 @@ function aggregator_save_category($edit) { } /** - * Removes all items from a feed. - * - * @param \Drupal\aggregator\Plugin\Core\Entity\Feed $feed - * An object describing the feed to be cleared. - */ -function aggregator_remove(Feed $feed) { - // Call \Drupal\aggregator\Plugin\ProcessorInterface::remove() on all - // processors. - $manager = Drupal::service('plugin.manager.aggregator.processor'); - foreach ($manager->getDefinitions() as $id => $definition) { - $manager->createInstance($id)->remove($feed); - } - // Reset feed. - $feed->checked->value = 0; - $feed->hash->value = ''; - $feed->etag->value = ''; - $feed->modified->value = 0; - $feed->save(); -} - -/** * Checks a news feed for new items. * * @param \Drupal\aggregator\Plugin\Core\Entity\Feed $feed diff --git a/core/modules/aggregator/aggregator.routing.yml b/core/modules/aggregator/aggregator.routing.yml index 311ff42..e25527c 100644 --- a/core/modules/aggregator/aggregator.routing.yml +++ b/core/modules/aggregator/aggregator.routing.yml @@ -15,14 +15,14 @@ aggregator_admin_settings: aggregator_feed_items_delete: pattern: '/admin/config/services/aggregator/remove/{aggregator_feed}' defaults: - _form: '\Drupal\aggregator\Form\FeedItemsDelete' + _entity_form: 'aggregator_feed.remove_items' requirements: _permission: 'administer news feeds' aggregator_feed_delete: pattern: '/admin/config/services/aggregator/delete/feed/{aggregator_feed}' defaults: - _form: '\Drupal\aggregator\Form\FeedDelete' + _entity_form: 'aggregator_feed.delete' requirements: _permission: 'administer news feeds' diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedInterface.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedInterface.php index 1f56021..be2dcac 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedInterface.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedInterface.php @@ -14,4 +14,11 @@ */ interface FeedInterface extends ContentEntityInterface { + /** + * Removes all items from a feed. + * + * @return self + */ + public function removeItems(); + } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDelete.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDelete.php deleted file mode 100644 index d613c39..0000000 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDelete.php +++ /dev/null @@ -1,75 +0,0 @@ - $this->feed->label())); - } - - /** - * {@inheritdoc} - */ - protected function getCancelPath() { - return 'admin/config/services/aggregator'; - } - - /** - * {@inheritdoc} - */ - protected function getConfirmText() { - return t('Delete'); - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, array &$form_state, Feed $aggregator_feed = NULL) { - $this->feed = $aggregator_feed; - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - $this->feed->delete(); - watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $this->feed->label())); - drupal_set_message(t('The feed %feed has been deleted.', array('%feed' => $this->feed->label()))); - if (arg(0) == 'admin') { - $form_state['redirect'] = 'admin/config/services/aggregator'; - } - else { - $form_state['redirect'] = 'aggregator/sources'; - } - } -} diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php new file mode 100644 index 0000000..cda6539 --- /dev/null +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php @@ -0,0 +1,52 @@ + $this->entity->label())); + } + + /** + * {@inheritdoc} + */ + public function getCancelPath() { + return 'admin/config/services/aggregator'; + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return t('Delete'); + } + + /** + * {@inheritdoc} + */ + public function submit(array $form, array &$form_state) { + $this->entity->delete(); + watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $this->entity->label())); + drupal_set_message(t('The feed %feed has been deleted.', array('%feed' => $this->entity->label()))); + if (arg(0) == 'admin') { + $form_state['redirect'] = 'admin/config/services/aggregator'; + } + else { + $form_state['redirect'] = 'aggregator/sources'; + } + } + +} diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsDelete.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsDelete.php deleted file mode 100644 index dbb79cd..0000000 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsDelete.php +++ /dev/null @@ -1,70 +0,0 @@ - $this->feed->label())); - } - - /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). - */ - protected function getCancelPath() { - return 'admin/config/services/aggregator'; - } - - /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getConfirmText(). - */ - protected function getConfirmText() { - return t('Remove items'); - } - - /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). - */ - public function buildForm(array $form, array &$form_state, Feed $aggregator_feed = NULL) { - $this->feed = $aggregator_feed; - return parent::buildForm($form, $form_state); - } - - /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). - */ - public function submitForm(array &$form, array &$form_state) { - // @todo Remove once http://drupal.org/node/1930274 is fixed. - aggregator_remove($this->feed); - $form_state['redirect'] = 'admin/config/services/aggregator'; - } - -} diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsRemoveForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsRemoveForm.php new file mode 100644 index 0000000..e374ca8 --- /dev/null +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsRemoveForm.php @@ -0,0 +1,47 @@ + $this->entity->label())); + } + + /** + * {@inheritdoc} + */ + public function getCancelPath() { + return 'admin/config/services/aggregator'; + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return t('Remove items'); + } + + /** + * {@inheritdoc} + */ + public function submit(array $form, array &$form_state) { + $this->entity->removeItems(); + + $form_state['redirect'] = 'admin/config/services/aggregator'; + } + +} diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php index f915caa..2754e37 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php @@ -23,7 +23,9 @@ * "storage" = "Drupal\aggregator\FeedStorageController", * "render" = "Drupal\aggregator\FeedRenderController", * "form" = { - * "default" = "Drupal\aggregator\FeedFormController" + * "default" = "Drupal\aggregator\FeedFormController", + * "delete" = "Drupal\aggregator\Form\FeedDeleteForm", + * "remove_items" = "Drupal\aggregator\Form\FeedItemsRemoveForm" * } * }, * base_table = "aggregator_feed", @@ -173,4 +175,21 @@ public function id() { public function label($langcode = NULL) { return $this->get('title')->value; } + + /** + * {@inheritdoc} + */ + public function removeItems() { + $manager = \Drupal::service('plugin.manager.aggregator.processor'); + foreach ($manager->getDefinitions() as $id => $definition) { + $manager->createInstance($id)->remove($this); + } + // Reset feed. + $this->checked->value = 0; + $this->hash->value = ''; + $this->etag->value = ''; + $this->modified->value = 0; + $this->save(); + } + } diff --git a/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php b/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php index 24655df..ac1aa91 100644 --- a/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php +++ b/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php @@ -11,6 +11,7 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\ban\BanIpManager; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -53,21 +54,21 @@ public function getFormID() { /** * {@inheritdoc} */ - protected function getQuestion() { + public function getQuestion() { return t('Are you sure you want to unblock %ip?', array('%ip' => $this->banIp)); } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/config/people/ban'; } @@ -77,11 +78,11 @@ protected function getCancelPath() { * @param string $ban_id * The IP address record ID to unban. */ - public function buildForm(array $form, array &$form_state, $ban_id = '') { + public function buildForm(array $form, array &$form_state, $ban_id = '', Request $request = NULL) { if (!$this->banIp = $this->ipManager->findById($ban_id)) { throw new NotFoundHttpException(); } - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** diff --git a/core/modules/block/block.routing.yml b/core/modules/block/block.routing.yml index af247b0..c867bca 100644 --- a/core/modules/block/block.routing.yml +++ b/core/modules/block/block.routing.yml @@ -1,6 +1,6 @@ block_admin_block_delete: pattern: '/admin/structure/block/manage/{block}/delete' defaults: - _form: '\Drupal\block\Form\AdminBlockDeleteForm' + _entity_form: 'block.delete' requirements: _permission: 'administer blocks' diff --git a/core/modules/block/lib/Drupal/block/Form/AdminBlockDeleteForm.php b/core/modules/block/lib/Drupal/block/Form/AdminBlockDeleteForm.php deleted file mode 100644 index ba6206a..0000000 --- a/core/modules/block/lib/Drupal/block/Form/AdminBlockDeleteForm.php +++ /dev/null @@ -1,73 +0,0 @@ - $this->block->label())); - } - - /** - * {@inheritdoc} - */ - protected function getCancelPath() { - return 'admin/structure/block'; - } - - /** - * {@inheritdoc} - */ - protected function getConfirmText() { - return t('Delete'); - } - - /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). - * - * @param \Drupal\block\Plugin\Core\Entity\Block $block - * The block instance. - */ - public function buildForm(array $form, array &$form_state, Block $block = null) { - $this->block = $block; - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - $this->block->delete(); - drupal_set_message(t('The block %name has been removed.', array('%name' => $this->block->label()))); - $form_state['redirect'] = 'admin/structure/block'; - } - -} diff --git a/core/modules/block/lib/Drupal/block/Form/BlockDeleteForm.php b/core/modules/block/lib/Drupal/block/Form/BlockDeleteForm.php new file mode 100644 index 0000000..3cc4a46 --- /dev/null +++ b/core/modules/block/lib/Drupal/block/Form/BlockDeleteForm.php @@ -0,0 +1,47 @@ + $this->entity->label())); + } + + /** + * {@inheritdoc} + */ + public function getCancelPath() { + return 'admin/structure/block'; + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return t('Delete'); + } + + /** + * {@inheritdoc} + */ + public function submit(array $form, array &$form_state) { + $this->entity->delete(); + drupal_set_message(t('The block %name has been removed.', array('%name' => $this->entity->label()))); + $form_state['redirect'] = 'admin/structure/block'; + } + +} diff --git a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php index 3c8b14c..78dddd6 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php @@ -26,7 +26,8 @@ * "render" = "Drupal\block\BlockRenderController", * "list" = "Drupal\block\BlockListController", * "form" = { - * "default" = "Drupal\block\BlockFormController" + * "default" = "Drupal\block\BlockFormController", + * "delete" = "Drupal\block\Form\BlockDeleteForm" * } * }, * config_prefix = "block.block", diff --git a/core/modules/config/tests/config_test/config_test.routing.yml b/core/modules/config/tests/config_test/config_test.routing.yml index 61221c6..3a0fddb 100644 --- a/core/modules/config/tests/config_test/config_test.routing.yml +++ b/core/modules/config/tests/config_test/config_test.routing.yml @@ -48,7 +48,7 @@ config_test_entity_disable: config_test_entity_delete: pattern: 'admin/structure/config_test/manage/{config_test}/delete' defaults: - _form: '\Drupal\config_test\Form\ConfigTestDeleteForm' + _entity_form: 'config_test.delete' entity_type: 'config_test' requirements: _access: 'TRUE' diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Form/ConfigTestDeleteForm.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Form/ConfigTestDeleteForm.php index 5679803..c4e3d53 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Form/ConfigTestDeleteForm.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Form/ConfigTestDeleteForm.php @@ -7,67 +7,40 @@ namespace Drupal\config_test\Form; use Drupal\Component\Utility\String; -use Drupal\Core\Form\ConfirmFormBase; -use Drupal\config_test\ConfigTestInterface; +use Drupal\Core\Entity\EntityConfirmFormBase; /** * Delete confirmation form for config_test entities. */ -class ConfigTestDeleteForm extends ConfirmFormBase { - - /** - * The config_test entity to be deleted. - * - * @var \Drupal\config_test\Plugin\Core\Entity\ConfigTest. - */ - protected $configTest; +class ConfigTestDeleteForm extends EntityConfirmFormBase { /** * {@inheritdoc} */ - protected function getQuestion() { - return t('Are you sure you want to delete %label', array('%label' => $this->configTest->label())); + public function getQuestion() { + return t('Are you sure you want to delete %label', array('%label' => $this->entity->label())); } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/structure/config_test'; } /** * {@inheritdoc} */ - public function getFormID() { - return 'config_test_delete_form'; - } - - /** - * Implements \Drupal\Drupal\Core\Form\ConfirmFormBase::buildForm(). - * - * @param \Drupal\config_test\ConfigTestInterface $config_test - * (optional) The ConfigTestInterface object to delete. - */ - public function buildForm(array $form, array &$form_state, ConfigTestInterface $config_test = NULL) { - $this->configTest = $config_test; - - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - $this->configTest->delete(); - drupal_set_message(String::format('%label configuration has been deleted.', array('%label' => $this->configTest->label()))); + public function submit(array $form, array &$form_state) { + $this->entity->delete(); + drupal_set_message(String::format('%label configuration has been deleted.', array('%label' => $this->entity->label()))); $form_state['redirect'] = 'admin/structure/config_test'; } diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php index 7afb306..12a033b 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php @@ -23,7 +23,8 @@ * "storage" = "Drupal\config_test\ConfigTestStorageController", * "list" = "Drupal\Core\Config\Entity\ConfigEntityListController", * "form" = { - * "default" = "Drupal\config_test\ConfigTestFormController" + * "default" = "Drupal\config_test\ConfigTestFormController", + * "delete" = "Drupal\config_test\Form\ConfigTestDeleteForm" * } * }, * uri_callback = "config_test_uri", diff --git a/core/modules/contact/contact.routing.yml b/core/modules/contact/contact.routing.yml index b46305b..c8ab42c 100644 --- a/core/modules/contact/contact.routing.yml +++ b/core/modules/contact/contact.routing.yml @@ -1,7 +1,7 @@ contact_category_delete: pattern: 'admin/structure/contact/manage/{contact_category}/delete' defaults: - _form: '\Drupal\contact\Form\DeleteForm' + _entity_form: contact_category.delete requirements: _entity_access: contact_category.delete diff --git a/core/modules/contact/lib/Drupal/contact/Form/CategoryDeleteForm.php b/core/modules/contact/lib/Drupal/contact/Form/CategoryDeleteForm.php new file mode 100644 index 0000000..75988a7 --- /dev/null +++ b/core/modules/contact/lib/Drupal/contact/Form/CategoryDeleteForm.php @@ -0,0 +1,48 @@ + $this->entity->label())); + } + + /** + * {@inheritdoc} + */ + public function getCancelPath() { + return 'admin/structure/contact'; + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return t('Delete'); + } + + /** + * {@inheritdoc} + */ + public function submit(array $form, array &$form_state) { + $this->entity->delete(); + drupal_set_message(t('Category %label has been deleted.', array('%label' => $this->entity->label()))); + watchdog('contact', 'Category %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); + $form_state['redirect'] = 'admin/structure/contact'; + } + +} diff --git a/core/modules/contact/lib/Drupal/contact/Form/DeleteForm.php b/core/modules/contact/lib/Drupal/contact/Form/DeleteForm.php deleted file mode 100644 index 237d32e..0000000 --- a/core/modules/contact/lib/Drupal/contact/Form/DeleteForm.php +++ /dev/null @@ -1,72 +0,0 @@ - $this->contactCategory->label())); - } - - /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). - */ - protected function getCancelPath() { - return 'admin/structure/contact'; - } - - /** - * Overrides \Drupal\Core\Form\ConfirmFormBase::getConfirmText(). - */ - protected function getConfirmText() { - return t('Delete'); - } - - /** - * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm(). - */ - public function buildForm(array $form, array &$form_state, Category $contact_category = NULL) { - $this->contactCategory = $contact_category; - - return parent::buildForm($form, $form_state); - } - - /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). - */ - public function submitForm(array &$form, array &$form_state) { - $this->contactCategory->delete(); - drupal_set_message(t('Category %label has been deleted.', array('%label' => $this->contactCategory->label()))); - watchdog('contact', 'Category %label has been deleted.', array('%label' => $this->contactCategory->label()), WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/contact'; - } - -} diff --git a/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php b/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php index 12a9fc0..afabe44 100644 --- a/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php +++ b/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php @@ -25,7 +25,8 @@ * "list" = "Drupal\contact\CategoryListController", * "form" = { * "add" = "Drupal\contact\CategoryFormController", - * "edit" = "Drupal\contact\CategoryFormController" + * "edit" = "Drupal\contact\CategoryFormController", + * "delete" = "Drupal\contact\Form\CategoryDeleteForm" * } * }, * uri_callback = "contact_category_uri", diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index d115b7f..fefd9a1 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -244,6 +244,13 @@ function field_ui_element_info() { } /** + * Implements hook_entity_info(). + */ +function field_ui_entity_info(&$entity_info) { + $entity_info['field_instance']['controllers']['form']['delete'] = 'Drupal\field_ui\Form\FieldDeleteForm'; +} + +/** * Implements hook_entity_bundle_create(). */ function field_ui_entity_bundle_create($entity_type, $bundle) { diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php index d5a42af..481cf7c 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php @@ -7,23 +7,15 @@ namespace Drupal\field_ui\Form; -use Drupal\Core\Form\ConfirmFormBase; -use Drupal\Core\Controller\ControllerInterface; +use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityManager; -use Drupal\field\Plugin\Core\Entity\FieldInstance; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a form for removing a field instance from a bundle. */ -class FieldDeleteForm extends ConfirmFormBase implements ControllerInterface { - - /** - * The field instance being deleted. - * - * @var \Drupal\field\Plugin\Core\Entity\FieldInstance - */ - protected $instance; +class FieldDeleteForm extends EntityConfirmFormBase implements EntityControllerInterface { /** * The entity manager. @@ -45,7 +37,7 @@ public function __construct(EntityManager $entity_manager) { /** * {@inheritdoc} */ - public static function create(ContainerInterface $container) { + public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( $container->get('plugin.manager.entity') ); @@ -54,59 +46,43 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function getFormID() { - return 'field_ui_field_delete_form'; + public function getQuestion() { + return t('Are you sure you want to delete the field %field?', array('%field' => $this->entity->label())); } /** * {@inheritdoc} */ - protected function getQuestion() { - return t('Are you sure you want to delete the field %field?', array('%field' => $this->instance->label())); - } - - /** - * {@inheritdoc} - */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } /** * {@inheritdoc} */ - protected function getCancelPath() { - return $this->entityManager->getAdminPath($this->instance->entity_type, $this->instance->bundle) . '/fields'; + public function getCancelPath() { + return $this->entityManager->getAdminPath($this->entity->entity_type, $this->entity->bundle) . '/fields'; } /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, FieldInstance $field_instance = NULL) { - $this->instance = $form_state['instance'] = $field_instance; - - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { + public function submit(array $form, array &$form_state) { form_load_include($form_state, 'inc', 'field_ui', 'field_ui.admin'); - $field = $this->instance->getField(); + $field = $this->entity->getField(); $bundles = entity_get_bundles(); - $bundle_label = $bundles[$this->instance->entity_type][$this->instance->bundle]['label']; + $bundle_label = $bundles[$this->entity->entity_type][$this->entity->bundle]['label']; if ($field && !$field['locked']) { - $this->instance->delete(); - drupal_set_message(t('The field %field has been deleted from the %type content type.', array('%field' => $this->instance->label(), '%type' => $bundle_label))); + $this->entity->delete(); + drupal_set_message(t('The field %field has been deleted from the %type content type.', array('%field' => $this->entity->label(), '%type' => $bundle_label))); } else { - drupal_set_message(t('There was a problem removing the %field from the %type content type.', array('%field' => $this->instance->label(), '%type' => $bundle_label)), 'error'); + drupal_set_message(t('There was a problem removing the %field from the %type content type.', array('%field' => $this->entity->label(), '%type' => $bundle_label)), 'error'); } - $admin_path = $this->entityManager->getAdminPath($this->instance->entity_type, $this->instance->bundle); + $admin_path = $this->entityManager->getAdminPath($this->entity->entity_type, $this->entity->bundle); $form_state['redirect'] = "$admin_path/fields"; // Fields are purged on cron. However field module prevents disabling modules diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php b/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php index 934a56e..55477a0 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php @@ -76,7 +76,7 @@ public function routes(RouteBuildEvent $event) { $route = new Route( "$path/fields/{field_instance}/delete", - array('_form' => '\Drupal\field_ui\Form\FieldDeleteForm'), + array('_entity_form' => 'field_instance.delete'), array('_permission' => 'administer ' . $entity_type . ' fields') ); $collection->add("field_ui.delete.$entity_type", $route); diff --git a/core/modules/filter/filter.routing.yml b/core/modules/filter/filter.routing.yml index a8f4186..0b9d357 100644 --- a/core/modules/filter/filter.routing.yml +++ b/core/modules/filter/filter.routing.yml @@ -1,7 +1,7 @@ filter_admin_disable: pattern: '/admin/config/content/formats/{filter_format}/disable' defaults: - _form: '\Drupal\filter\Form\DisableForm' + _entity_form: 'filter_format.disable' requirements: _filter_disable_format_access: 'TRUE' diff --git a/core/modules/filter/lib/Drupal/filter/Form/DisableForm.php b/core/modules/filter/lib/Drupal/filter/Form/DisableForm.php deleted file mode 100644 index 49b71c8..0000000 --- a/core/modules/filter/lib/Drupal/filter/Form/DisableForm.php +++ /dev/null @@ -1,79 +0,0 @@ - $this->format->name)); - } - - /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). - */ - protected function getCancelPath() { - return 'admin/config/content/formats'; - } - - /** - * Overrides \Drupal\Core\Form\ConfirmFormBase::getConfirmText(). - */ - public function getConfirmText() { - return t('Disable'); - } - - /** - * Overrides \Drupal\Core\Form\ConfirmFormBase::getDescription(). - */ - public function getDescription() { - return t('Disabled text formats are completely removed from the administrative interface, and any content stored with that format will not be displayed. This action cannot be undone.'); - } - - /** - * Overrides \Drupal\Core\Form\FormInterface::buildForm(). - */ - public function buildForm(array $form, array &$form_state, FilterFormat $filter_format = NULL) { - $this->format = $filter_format; - - return parent::buildForm($form, $form_state); - } - - /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). - */ - public function submitForm(array &$form, array &$form_state) { - $this->format->disable()->save(); - drupal_set_message(t('Disabled text format %format.', array('%format' => $this->format->name))); - - $form_state['redirect'] = 'admin/config/content/formats'; - } - -} diff --git a/core/modules/filter/lib/Drupal/filter/Form/FilterDisableForm.php b/core/modules/filter/lib/Drupal/filter/Form/FilterDisableForm.php new file mode 100644 index 0000000..2759b2b --- /dev/null +++ b/core/modules/filter/lib/Drupal/filter/Form/FilterDisableForm.php @@ -0,0 +1,55 @@ + $this->entity->label())); + } + + /** + * {@inheritdoc} + */ + public function getCancelPath() { + return 'admin/config/content/formats'; + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return t('Disable'); + } + + /** + * {@inheritdoc} + */ + public function getDescription() { + return t('Disabled text formats are completely removed from the administrative interface, and any content stored with that format will not be displayed. This action cannot be undone.'); + } + + /** + * {@inheritdoc} + */ + public function submit(array $form, array &$form_state) { + $this->entity->disable()->save(); + drupal_set_message(t('Disabled text format %format.', array('%format' => $this->entity->label()))); + + $form_state['redirect'] = 'admin/config/content/formats'; + } + +} diff --git a/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php b/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php index d6b1fe6..bd56236 100644 --- a/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php +++ b/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php @@ -21,6 +21,9 @@ * label = @Translation("Text format"), * module = "filter", * controllers = { + * "form" = { + * "disable" = "Drupal\filter\Form\FilterDisableForm" + * }, * "storage" = "Drupal\filter\FilterFormatStorageController" * }, * config_prefix = "filter.format", diff --git a/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php b/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php index 46df2b9..7c4ba56 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php +++ b/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\taxonomy\Plugin\Core\Entity\Term; +use Symfony\Component\HttpFoundation\Request; /** * Builds the form to delete a forum term. @@ -32,31 +33,31 @@ public function getFormID() { /** * {@inheritdoc} */ - protected function getQuestion() { + public function getQuestion() { return t('Are you sure you want to delete the forum %label?', array('%label' => $this->taxonomyTerm->label())); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/structure/forum'; } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Term $taxonomy_term = NULL) { + public function buildForm(array $form, array &$form_state, Term $taxonomy_term = NULL, Request $request = NULL) { $this->taxonomyTerm = $taxonomy_term; - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** diff --git a/core/modules/image/image.routing.yml b/core/modules/image/image.routing.yml index 0aa23ba..b178d33 100644 --- a/core/modules/image/image.routing.yml +++ b/core/modules/image/image.routing.yml @@ -1,7 +1,7 @@ image_style_delete: pattern: 'admin/config/media/image-styles/manage/{image_style}/delete' defaults: - _form: '\Drupal\image\Form\ImageStyleDeleteForm' + _entity_form: 'image_style.delete' requirements: _permission: 'administer image styles' diff --git a/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php b/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php index c3832c2..50bf2bb 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\image\Plugin\Core\Entity\ImageStyle; +use Symfony\Component\HttpFoundation\Request; /** * Form for deleting an image effect. @@ -32,21 +33,21 @@ class ImageEffectDeleteForm extends ConfirmFormBase { /** * {@inheritdoc} */ - protected function getQuestion() { + public function getQuestion() { return t('Are you sure you want to delete the @effect effect from the %style style?', array('%style' => $this->imageStyle->label(), '@effect' => $this->imageEffect['label'])); } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/config/media/image-styles/manage/' . $this->imageStyle->id(); } @@ -60,11 +61,11 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $image_style = NULL, $image_effect = NULL) { + public function buildForm(array $form, array &$form_state, $image_style = NULL, $image_effect = NULL, Request $request = NULL) { $this->imageStyle = $image_style; $this->imageEffect = image_effect_load($image_effect, $this->imageStyle->id()); - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php index 9719d38..eb2f9aa 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php @@ -7,64 +7,46 @@ namespace Drupal\image\Form; -use Drupal\Core\Form\ConfirmFormBase; -use Drupal\image\Plugin\Core\Entity\ImageStyle; +use Drupal\Core\Entity\EntityConfirmFormBase; /** * Creates a form to delete an image style. */ -class ImageStyleDeleteForm extends ConfirmFormBase { - - /** - * The image style to be deleted. - * - * @var \Drupal\image\Plugin\Core\Entity\ImageStyle $imageStyle - */ - protected $imageStyle; +class ImageStyleDeleteForm extends EntityConfirmFormBase { /** * {@inheritdoc} */ - protected function getQuestion() { - return t('Optionally select a style before deleting %style', array('%style' => $this->imageStyle->label())); + public function getQuestion() { + return t('Optionally select a style before deleting %style', array('%style' => $this->entity->label())); } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/config/media/image-styles'; } /** * {@inheritdoc} */ - public function getFormID() { - return 'image_style_delete_form'; - } - - /** - * {@inheritdoc} - */ - protected function getDescription() { + public function getDescription() { return t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted.'); } /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, ImageStyle $image_style = NULL) { - - $this->imageStyle = $image_style; - - $replacement_styles = array_diff_key(image_style_options(), array($this->imageStyle->id() => '')); + public function form(array $form, array &$form_state) { + $replacement_styles = array_diff_key(image_style_options(), array($this->entity->id() => '')); $form['replacement'] = array( '#title' => t('Replacement style'), '#type' => 'select', @@ -72,16 +54,16 @@ public function buildForm(array $form, array &$form_state, ImageStyle $image_sty '#empty_option' => t('No replacement, just delete'), ); - return parent::buildForm($form, $form_state); + return $form; } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { - $this->imageStyle->set('replacementID', $form_state['values']['replacement']); - $this->imageStyle->delete(); - drupal_set_message(t('Style %name was deleted.', array('%name' => $this->imageStyle->label()))); + public function submit(array $form, array &$form_state) { + $this->entity->set('replacementID', $form_state['values']['replacement']); + $this->entity->delete(); + drupal_set_message(t('Style %name was deleted.', array('%name' => $this->entity->label()))); $form_state['redirect'] = 'admin/config/media/image-styles'; } diff --git a/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php index 60f020e..d17a96e 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php @@ -20,6 +20,9 @@ * label = @Translation("Image style"), * module = "image", * controllers = { + * "form" = { + * "delete" = "Drupal\image\Form\ImageStyleDeleteForm" + * }, * "storage" = "Drupal\image\ImageStyleStorageController" * }, * uri_callback = "image_style_entity_uri", diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php new file mode 100644 index 0000000..60129fa --- /dev/null +++ b/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php @@ -0,0 +1,123 @@ +storageController = $storage_controller; + $this->connection = $connection; + } + + /** + * {@inheritdoc} + */ + public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { + return new static( + $container->get('plugin.manager.entity')->getStorageController('menu_link'), + $container->get('database') + ); + } + + /** + * {@inheritdoc} + */ + public function getQuestion() { + return t('Are you sure you want to delete the custom menu %title?', array('%title' => $this->entity->label())); + } + + /** + * {@inheritdoc} + */ + public function getCancelPath() { + return 'admin/structure/menu/manage/' . $this->entity->id(); + } + + /** + * {@inheritdoc} + */ + public function getDescription() { + $caption = ''; + $num_links = $this->storageController->countMenuLinks($this->entity->id()); + if ($num_links) { + $caption .= '

' . format_plural($num_links, 'Warning: There is currently 1 menu link in %title. It will be deleted (system-defined items will be reset).', 'Warning: There are currently @count menu links in %title. They will be deleted (system-defined links will be reset).', array('%title' => $this->entity->label())) . '

'; + } + $caption .= '

' . t('This action cannot be undone.') . '

'; + return $caption; + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return t('Delete'); + } + + /** + * {@inheritdoc} + */ + public function submit(array $form, array &$form_state) { + $form_state['redirect'] = 'admin/structure/menu'; + + // System-defined menus may not be deleted - only menus defined by this module. + $system_menus = menu_list_system_menus(); + if (isset($system_menus[$this->entity->id()])) { + return; + } + + // Reset all the menu links defined by the system via hook_menu(). + // @todo Convert this to an EFQ once we figure out 'ORDER BY m.number_parts'. + $result = $this->connection->query("SELECT mlid FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path WHERE ml.menu_name = :menu AND ml.module = 'system' ORDER BY m.number_parts ASC", array(':menu' => $this->entity->id()), array('fetch' => \PDO::FETCH_ASSOC))->fetchCol(); + $menu_links = $this->storageController->load($result); + foreach ($menu_links as $link) { + $link->reset(); + } + + // Delete all links to the overview page for this menu. + $menu_links = $this->storageController->loadByProperties(array('link_path' => 'admin/structure/menu/manage/' . $this->entity->id())); + menu_link_delete_multiple(array_keys($menu_links)); + + // Delete the custom menu and all its menu links. + $this->entity->delete(); + + $t_args = array('%title' => $this->entity->label()); + drupal_set_message(t('The custom menu %title has been deleted.', $t_args)); + watchdog('menu', 'Deleted custom menu %title and all its menu links.', $t_args, WATCHDOG_NOTICE); + } +} diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteMenuForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteMenuForm.php deleted file mode 100644 index 84d0e90..0000000 --- a/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteMenuForm.php +++ /dev/null @@ -1,107 +0,0 @@ - $this->menu->label())); - } - - /** - * {@inheritdoc} - */ - protected function getCancelPath() { - return 'admin/structure/menu/manage/' . $this->menu->id(); - } - - /** - * {@inheritdoc} - */ - protected function getDescription() { - $caption = ''; - $num_links = \Drupal::entityManager() - ->getStorageController('menu_link')->countMenuLinks($this->menu->id()); - if ($num_links) { - $caption .= '

' . format_plural($num_links, 'Warning: There is currently 1 menu link in %title. It will be deleted (system-defined items will be reset).', 'Warning: There are currently @count menu links in %title. They will be deleted (system-defined links will be reset).', array('%title' => $this->menu->label())) . '

'; - } - $caption .= '

' . t('This action cannot be undone.') . '

'; - return $caption; - } - - /** - * {@inheritdoc} - */ - protected function getConfirmText() { - return t('Delete'); - } - - /** - * {@inheritdoc} - */ - public function getFormID() { - return 'menu_delete_menu_confirm'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, array &$form_state, Menu $menu = NULL) { - $this->menu = $menu; - - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - $form_state['redirect'] = 'admin/structure/menu'; - - // System-defined menus may not be deleted - only menus defined by this module. - $system_menus = menu_list_system_menus(); - if (isset($system_menus[$this->menu->id()])) { - return; - } - - // Reset all the menu links defined by the system via hook_menu(). - // @todo Convert this to an EFQ once we figure out 'ORDER BY m.number_parts'. - $result = db_query("SELECT mlid FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path WHERE ml.menu_name = :menu AND ml.module = 'system' ORDER BY m.number_parts ASC", array(':menu' => $this->menu->id()), array('fetch' => \PDO::FETCH_ASSOC))->fetchCol(); - $menu_links = menu_link_load_multiple($result); - foreach ($menu_links as $link) { - $link->reset(); - } - - // Delete all links to the overview page for this menu. - $menu_links = entity_load_multiple_by_properties('menu_link', array('link_path' => 'admin/structure/menu/manage/' . $this->menu->id())); - menu_link_delete_multiple(array_keys($menu_links)); - - // Delete the custom menu and all its menu links. - $this->menu->delete(); - - $t_args = array('%title' => $this->menu->label()); - drupal_set_message(t('The custom menu %title has been deleted.', $t_args)); - watchdog('menu', 'Deleted custom menu %title and all its menu links.', $t_args, WATCHDOG_NOTICE); - } -} diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php index e00dbc7..ffb2af5 100644 --- a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php +++ b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php @@ -7,59 +7,36 @@ namespace Drupal\menu\Form; -use Drupal\Core\Form\ConfirmFormBase; -use Drupal\menu_link\Plugin\Core\Entity\MenuLink; +use Drupal\Core\Entity\EntityConfirmFormBase; /** * Defines a confirmation form for deletion of a single menu link. */ -class MenuLinkDeleteForm extends ConfirmFormBase { - - /** - * The menu link object to be deleted. - * - * @var \Drupal\menu_link\Plugin\Core\Entity\MenuLink - */ - protected $menuLink; +class MenuLinkDeleteForm extends EntityConfirmFormBase { /** * {@inheritdoc} */ - protected function getQuestion() { - return t('Are you sure you want to delete the custom menu link %item?', array('%item' => $this->menuLink->link_title)); + public function getQuestion() { + return t('Are you sure you want to delete the custom menu link %item?', array('%item' => $this->entity->link_title)); } /** * {@inheritdoc} */ - protected function getCancelPath() { - return 'admin/structure/menu/manage/' . $this->menuLink->menu_name; + public function getCancelPath() { + return 'admin/structure/menu/manage/' . $this->entity->menu_name; } /** * {@inheritdoc} */ - public function getFormID() { - return 'menu_link_delete_form'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, array &$form_state, MenuLink $menu_link = NULL) { - $this->menuLink = $menu_link; - - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - menu_link_delete($this->menuLink->id()); - $t_args = array('%title' => $this->menuLink->link_title); + public function submit(array $form, array &$form_state) { + menu_link_delete($this->entity->id()); + $t_args = array('%title' => $this->entity->link_title); drupal_set_message(t('The menu link %title has been deleted.', $t_args)); watchdog('menu', 'Deleted menu link %title.', $t_args, WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/menu/manage/' . $this->menuLink->menu_name; + $form_state['redirect'] = 'admin/structure/menu/manage/' . $this->entity->menu_name; } + } diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php index aa1165c..d079b51 100644 --- a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php +++ b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php @@ -7,71 +7,48 @@ namespace Drupal\menu\Form; -use Drupal\Core\Form\ConfirmFormBase; -use Drupal\menu_link\Plugin\Core\Entity\MenuLink; +use Drupal\Core\Entity\EntityConfirmFormBase; /** * Defines a confirmation form for resetting a single modified menu link. */ -class MenuLinkResetForm extends ConfirmFormBase { - - /** - * The menu link object to be deleted. - * - * @var \Drupal\menu_link\Plugin\Core\Entity\MenuLink - */ - protected $menuLink; +class MenuLinkResetForm extends EntityConfirmFormBase { /** * {@inheritdoc} */ - protected function getQuestion() { - return t('Are you sure you want to reset the link %item to its default values?', array('%item' => $this->menuLink->link_title)); + public function getQuestion() { + return t('Are you sure you want to reset the link %item to its default values?', array('%item' => $this->entity->link_title)); } /** * {@inheritdoc} */ - protected function getCancelPath() { - return 'admin/structure/menu/manage/' . $this->menuLink->menu_name; + public function getCancelPath() { + return 'admin/structure/menu/manage/' . $this->entity->menu_name; } /** * {@inheritdoc} */ - protected function getDescription() { + public function getDescription() { return t('Any customizations will be lost. This action cannot be undone.'); } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Reset'); } /** * {@inheritdoc} */ - public function getFormID() { - return 'menu_link_reset_form'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, array &$form_state, MenuLink $menu_link = NULL) { - $this->menuLink = $menu_link; - - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - $new_menu_link = $this->menuLink->reset(); + public function submit(array $form, array &$form_state) { + $new_menu_link = $this->entity->reset(); drupal_set_message(t('The menu link was reset to its default settings.')); $form_state['redirect'] = 'admin/structure/menu/manage/' . $new_menu_link->menu_name; } + } diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index 2884761..d5a2ff9 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -142,14 +142,18 @@ function menu_menu() { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_info(). */ -function menu_entity_info_alter(&$entity_info) { +function menu_entity_info(&$entity_info) { $entity_info['menu']['controllers']['list'] = 'Drupal\menu\MenuListController'; $entity_info['menu']['uri_callback'] = 'menu_uri'; $entity_info['menu']['controllers']['form'] = array( 'default' => 'Drupal\menu\MenuFormController', + 'delete' => 'Drupal\menu\Form\MenuDeleteForm', ); + + $entity_info['menu_link']['controllers']['form']['delete'] = 'Drupal\menu\Form\MenuLinkDeleteForm'; + $entity_info['menu_link']['controllers']['form']['reset'] = 'Drupal\menu\Form\MenuLinkResetForm'; } /** diff --git a/core/modules/menu/menu.routing.yml b/core/modules/menu/menu.routing.yml index aafe5c3..62c54f2 100644 --- a/core/modules/menu/menu.routing.yml +++ b/core/modules/menu/menu.routing.yml @@ -8,20 +8,20 @@ menu_settings: menu_link_reset: pattern: 'admin/structure/menu/item/{menu_link}/reset' defaults: - _form: '\Drupal\menu\Form\MenuLinkResetForm' + _entity_form: 'menu_link.reset' requirements: _permission: 'administer menu' menu_link_delete: pattern: 'admin/structure/menu/item/{menu_link}/delete' defaults: - _form: '\Drupal\menu\Form\MenuLinkDeleteForm' + _entity_form: 'menu_link.delete' requirements: _access_menu_delete_link: 'TRUE' menu_delete_menu: pattern: 'admin/structure/menu/manage/{menu}/delete' defaults: - _form: '\Drupal\menu\Form\MenuDeleteMenuForm' + _entity_form: 'menu.delete' requirements: _access_menu_delete_menu: 'TRUE' diff --git a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php index c47c683..3cb38bf 100644 --- a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php +++ b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php @@ -73,21 +73,21 @@ public function getFormID() { /** * {@inheritdoc} */ - protected function getQuestion() { + public function getQuestion() { return format_plural(count($this->nodes), 'Are you sure you want to delete this item?', 'Are you sure you want to delete these items?'); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/content'; } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 3245f24..7ab92e8 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1957,6 +1957,11 @@ function theme_node_recent_content($variables) { * Adds node-type specific visibility options to block configuration form. */ function node_form_block_form_alter(&$form, &$form_state) { + // These options should be added to most block forms, but not when deleting. + if ($form_state['controller']->getOperation() == 'delete') { + return; + } + $block = $form_state['controller']->getEntity(); $visibility = $block->get('visibility'); $form['visibility']['node_type'] = array( diff --git a/core/modules/path/lib/Drupal/path/Form/DeleteForm.php b/core/modules/path/lib/Drupal/path/Form/DeleteForm.php index a710090..2d4bcff 100644 --- a/core/modules/path/lib/Drupal/path/Form/DeleteForm.php +++ b/core/modules/path/lib/Drupal/path/Form/DeleteForm.php @@ -7,10 +7,11 @@ namespace Drupal\path\Form; -use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Controller\ControllerInterface; +use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Path\Path; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; /** * Builds the form to delete a path alias. @@ -60,24 +61,24 @@ public function getFormID() { /** * Implements \Drupal\Core\Form\ConfirmFormBase::getQuestion(). */ - protected function getQuestion() { + public function getQuestion() { return t('Are you sure you want to delete path alias %title?', array('%title' => $this->pathAlias['alias'])); } /** * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/config/search/path'; } /** * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm(). */ - public function buildForm(array $form, array &$form_state, $pid = NULL) { + public function buildForm(array $form, array &$form_state, $pid = NULL, Request $request = NULL) { $this->pathAlias = $this->path->load(array('pid' => $pid)); - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** diff --git a/core/modules/picture/lib/Drupal/picture/Form/PictureMappingActionConfirmForm.php b/core/modules/picture/lib/Drupal/picture/Form/PictureMappingActionConfirmForm.php deleted file mode 100644 index 1038700..0000000 --- a/core/modules/picture/lib/Drupal/picture/Form/PictureMappingActionConfirmForm.php +++ /dev/null @@ -1,68 +0,0 @@ - $this->pictureMapping->label())); - } - - /** - * {@inheritdoc} - */ - protected function getCancelPath() { - return 'admin/config/media/picturemapping'; - } - - /** - * {@inheritdoc} - */ - protected function getConfirmText() { - return t('Delete'); - } - - /** - * {@inheritdoc} - */ - public function getFormID() { - return 'picture_mapping_action_confirm'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, array &$form_state, EntityInterface $picture_mapping = NULL) { - $this->pictureMapping = $picture_mapping; - - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - $this->pictureMapping->delete(); - drupal_set_message(t('Picture mapping %label has been deleted.', array('%label' => $this->pictureMapping->label()))); - watchdog('picture', 'Picture mapping %label has been deleted.', array('%label' => $this->pictureMapping->label()), WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/config/media/picturemapping'; - } -} diff --git a/core/modules/picture/lib/Drupal/picture/Form/PictureMappingDeleteForm.php b/core/modules/picture/lib/Drupal/picture/Form/PictureMappingDeleteForm.php new file mode 100644 index 0000000..ef3389f --- /dev/null +++ b/core/modules/picture/lib/Drupal/picture/Form/PictureMappingDeleteForm.php @@ -0,0 +1,45 @@ + $this->entity->label())); + } + + /** + * {@inheritdoc} + */ + public function getCancelPath() { + return 'admin/config/media/picturemapping'; + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return t('Delete'); + } + + /** + * {@inheritdoc} + */ + public function submit(array $form, array &$form_state) { + $this->entity->delete(); + drupal_set_message(t('Picture mapping %label has been deleted.', array('%label' => $this->entity->label()))); + watchdog('picture', 'Picture mapping %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); + $form_state['redirect'] = 'admin/config/media/picturemapping'; + } + +} diff --git a/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php b/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php index 887dddf..98bfe6f 100644 --- a/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php +++ b/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php @@ -25,6 +25,7 @@ * "form" = { * "edit" = "Drupal\picture\PictureMappingFormController", * "add" = "Drupal\picture\PictureMappingFormController", + * "delete" = "Drupal\picture\Form\PictureMappingDeleteForm", * "duplicate" = "Drupal\picture\PictureMappingFormController" * } * }, diff --git a/core/modules/picture/picture.routing.yml b/core/modules/picture/picture.routing.yml index 408dd33..40627a2 100644 --- a/core/modules/picture/picture.routing.yml +++ b/core/modules/picture/picture.routing.yml @@ -30,6 +30,6 @@ picture_mapping_page_duplicate: picture_mapping_action_confirm: pattern: '/admin/config/media/picturemapping/{picture_mapping}/delete' defaults: - _form: '\Drupal\picture\Form\PictureMappingActionConfirmForm' + _entity_form: 'picture_mapping.delete' requirements: _permission: 'administer pictures' diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php index e61713b..9546e7d 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\menu_link\Plugin\Core\Entity\MenuLink; +use Symfony\Component\HttpFoundation\Request; /** * Builds the shortcut link deletion form. @@ -32,31 +33,31 @@ public function getFormID() { /** * {@inheritdoc} */ - protected function getQuestion() { + public function getQuestion() { return t('Are you sure you want to delete the shortcut %title?', array('%title' => $this->menuLink->link_title)); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/config/user-interface/shortcut/manage/' . $this->menuLink->menu_name; } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, MenuLink $menu_link = NULL) { + public function buildForm(array $form, array &$form_state, MenuLink $menu_link = NULL, Request $request = NULL) { $this->menuLink = $menu_link; - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetDelete.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutDeleteForm.php similarity index 66% rename from core/modules/shortcut/lib/Drupal/shortcut/Form/SetDelete.php rename to core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutDeleteForm.php index 2b24574..75bab80 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetDelete.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutDeleteForm.php @@ -2,22 +2,22 @@ /** * @file - * Contains \Drupal\shortcut\Form\SetDelete. + * Contains \Drupal\shortcut\Form\ShortcutDeleteForm. */ namespace Drupal\shortcut\Form; +use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Entity\EntityControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Controller\ControllerInterface; -use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Database\Connection; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\shortcut\Plugin\Core\Entity\Shortcut; +use Symfony\Component\HttpFoundation\Request; /** * Builds the shortcut set deletion form. */ -class SetDelete extends ConfirmFormBase implements ControllerInterface { +class ShortcutDeleteForm extends EntityConfirmFormBase implements EntityControllerInterface { /** * The database connection. @@ -34,17 +34,9 @@ class SetDelete extends ConfirmFormBase implements ControllerInterface { protected $moduleHandler; /** - * The shortcut set being deleted. - * - * @var \Drupal\shortcut\Plugin\Core\Entity\Shortcut - */ - protected $shortcut; - - /** - * Constructs a SetDelete object. + * Constructs a ShortcutDeleteForm object. */ public function __construct(Connection $database, ModuleHandlerInterface $module_handler) { - $this->database = $database; $this->moduleHandler = $module_handler; } @@ -52,7 +44,7 @@ public function __construct(Connection $database, ModuleHandlerInterface $module /** * {@inheritdoc} */ - public static function create(ContainerInterface $container) { + public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( $container->get('database'), $container->get('module_handler') @@ -62,40 +54,31 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function getFormID() { - return 'shortcut_set_delete_form'; + public function getQuestion() { + return t('Are you sure you want to delete the shortcut set %title?', array('%title' => $this->entity->label())); } /** * {@inheritdoc} */ - protected function getQuestion() { - return t('Are you sure you want to delete the shortcut set %title?', array('%title' => $this->shortcut->label())); + public function getCancelPath() { + return 'admin/config/user-interface/shortcut/manage/' . $this->entity->id(); } /** * {@inheritdoc} */ - protected function getCancelPath() { - return 'admin/config/user-interface/shortcut/manage/' . $this->shortcut->id(); - } - - /** - * {@inheritdoc} - */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Shortcut $shortcut = NULL) { - $this->shortcut = $shortcut; - + public function buildForm(array $form, array &$form_state, Request $request = NULL) { // Find out how many users are directly assigned to this shortcut set, and // make a message. - $number = $this->database->query('SELECT COUNT(*) FROM {shortcut_set_users} WHERE set_name = :name', array(':name' => $this->shortcut->id()))->fetchField(); + $number = $this->database->query('SELECT COUNT(*) FROM {shortcut_set_users} WHERE set_name = :name', array(':name' => $this->entity->id()))->fetchField(); $info = ''; if ($number) { $info .= '

' . format_plural($number, @@ -113,16 +96,16 @@ public function buildForm(array $form, array &$form_state, Shortcut $shortcut = '#markup' => $info, ); - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { - $this->shortcut->delete(); + public function submit(array $form, array &$form_state) { + $this->entity->delete(); $form_state['redirect'] = 'admin/config/user-interface/shortcut'; - drupal_set_message(t('The shortcut set %title has been deleted.', array('%title' => $this->shortcut->label()))); + drupal_set_message(t('The shortcut set %title has been deleted.', array('%title' => $this->entity->label()))); } } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php b/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php index 95802d8..5d4ecda 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Plugin/Core/Entity/Shortcut.php @@ -25,7 +25,8 @@ * "list" = "Drupal\shortcut\ShortcutListController", * "form" = { * "default" = "Drupal\shortcut\ShortcutFormController", - * "edit" = "Drupal\shortcut\ShortcutFormController" + * "edit" = "Drupal\shortcut\ShortcutFormController", + * "delete" = "Drupal\shortcut\Form\ShortcutDeleteForm" * } * }, * config_prefix = "shortcut.set", diff --git a/core/modules/shortcut/shortcut.routing.yml b/core/modules/shortcut/shortcut.routing.yml index 761067f..f4925c3 100644 --- a/core/modules/shortcut/shortcut.routing.yml +++ b/core/modules/shortcut/shortcut.routing.yml @@ -8,7 +8,7 @@ shortcut_link_delete: shortcut_set_delete: pattern: '/admin/config/user-interface/shortcut/manage/{shortcut}/delete' defaults: - _form: 'Drupal\shortcut\Form\SetDelete' + _entity_form: 'shortcut.delete' requirements: _entity_access: 'shortcut.delete' @@ -18,6 +18,7 @@ shortcut_set_admin: _content: 'Drupal\shortcut\Controller\ShortcutController::shortcutSetAdmin' requirements: _permission: 'administer shortcuts' + shortcut_set_edit: pattern: '/admin/config/user-interface/shortcut/manage/{shortcut}/edit' defaults: diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php index 7a79679..327fb3f 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Config\ConfigFactory; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; /** * Builds a form to delete a date format. @@ -64,7 +65,7 @@ public function getFormID() { /** * {@inheritdoc} */ - protected function getQuestion() { + public function getQuestion() { return t('Are you sure you want to remove the format %name : %format?', array( '%name' => $this->format['name'], '%format' => format_date(REQUEST_TIME, $this->formatID)) @@ -74,14 +75,14 @@ protected function getQuestion() { /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Remove'); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/config/regional/date-time/formats'; } @@ -91,12 +92,12 @@ protected function getCancelPath() { * @param string $format_id * The date format ID. */ - public function buildForm(array $form, array &$form_state, $format_id = NULL) { + public function buildForm(array $form, array &$form_state, $format_id = NULL, Request $request = NULL) { // We don't get the format ID in the returned format array. $this->formatID = $format_id; $this->format = $this->configFactory->get('system.date')->get("formats.$format_id"); - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php index 3392b76..cbce81f 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php @@ -7,10 +7,11 @@ namespace Drupal\system\Form; -use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Controller\ControllerInterface; +use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Config\ConfigFactory; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; /** * Builds a form for enabling a module. @@ -57,7 +58,7 @@ public function getFormID() { /** * {@inheritdoc} */ - protected function getQuestion() { + public function getQuestion() { return t('Are you sure you want to reset the date formats for %language to the global defaults?', array( '%language' => $this->language->name, )); @@ -66,21 +67,21 @@ protected function getQuestion() { /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Reset'); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/config/regional/date-time/locale'; } /** * {@inheritdoc} */ - protected function getDescription() { + public function getDescription() { return t('Resetting will remove all localized date formats for this language. This action cannot be undone.'); } @@ -91,10 +92,10 @@ protected function getDescription() { * The language code. * */ - public function buildForm(array $form, array &$form_state, $langcode = NULL) { + public function buildForm(array $form, array &$form_state, $langcode = NULL, Request $request = NULL) { $this->language = language_load($langcode); - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesInstallConfirmForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesInstallConfirmForm.php index 2569161..23d3ada 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesInstallConfirmForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesInstallConfirmForm.php @@ -8,6 +8,7 @@ namespace Drupal\system\Form; use Drupal\Core\Form\ConfirmFormBase; +use Symfony\Component\HttpFoundation\Request; /** * Builds a confirmation form for required modules. @@ -19,28 +20,28 @@ class ModulesInstallConfirmForm extends ConfirmFormBase { /** * {@inheritdoc} */ - protected function getQuestion() { + public function getQuestion() { return t('Some required modules must be enabled'); } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Continue'); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/modules'; } /** * {@inheritdoc} */ - protected function getDescription() { + public function getDescription() { return t('Would you like to continue with the above?'); } @@ -58,7 +59,7 @@ public function getFormID() { * @param array $storage * Temporary storage of module dependency information. */ - public function buildForm(array $form, array &$form_state, $modules = array(), $storage = array()) { + public function buildForm(array $form, array &$form_state, $modules = array(), $storage = array(), Request $request = NULL) { $items = array(); $form['validation_modules'] = array('#type' => 'value', '#value' => $modules); @@ -82,7 +83,7 @@ public function buildForm(array $form, array &$form_state, $modules = array(), $ $form['modules'] = array('#theme' => 'item_list', '#items' => $items); - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php index f6a29cc..77c841c 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php @@ -8,6 +8,7 @@ namespace Drupal\system\Form; use Drupal\Core\Form\ConfirmFormBase; +use Symfony\Component\HttpFoundation\Request; /** * Builds a confirmation form to uninstall selected modules. @@ -19,28 +20,28 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase { /** * {@inheritdoc} */ - protected function getQuestion() { + public function getQuestion() { return t('Confirm uninstall'); } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Uninstall'); } /** * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/modules/uninstall'; } /** * {@inheritdoc} */ - protected function getDescription() { + public function getDescription() { return t('Would you like to continue with uninstalling the above?'); } @@ -57,7 +58,7 @@ public function getFormID() { * @param array $modules * The array of modules. */ - public function buildForm(array $form, array &$form_state, $modules = array()) { + public function buildForm(array $form, array &$form_state, $modules = array(), Request $request = NULL) { $uninstall = array(); // Construct the hidden form elements and list items. foreach ($modules as $module => $value) { @@ -71,7 +72,7 @@ public function buildForm(array $form, array &$form_state, $modules = array()) { $form['text'] = array('#markup' => '

' . t('The following modules will be completely uninstalled from your site, and all data from these modules will be lost!') . '

'); $form['modules'] = array('#theme' => 'item_list', '#items' => $uninstall); - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 6d3a89b..de47454 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -750,7 +750,7 @@ function system_modules($form, $form_state = array()) { // Contents of confirm form is injected here because already in form // building function. $confirm_form = new ModulesInstallConfirmForm(); - return $confirm_form->buildForm($form, $form_state, $visible_files, $form_state['storage']); + return $confirm_form->buildForm($form, $form_state, $visible_files, $form_state['storage'], Drupal::request()); } // JS-only table filters. @@ -1163,7 +1163,7 @@ function system_modules_uninstall($form, $form_state = NULL) { // Contents of confirm form is injected here because already in form // building function. $confirm_form = new ModulesUninstallConfirmForm(); - return $confirm_form->buildForm($form, $form_state, $modules); + return $confirm_form->buildForm($form, $form_state, $modules, Drupal::request()); } // Get a list of disabled, installed modules. diff --git a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormArrayPathTestForm.php b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormArrayPathTestForm.php index f0210ae..186fc24 100644 --- a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormArrayPathTestForm.php +++ b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormArrayPathTestForm.php @@ -22,7 +22,7 @@ public function getFormID() { /** * Overrides \Drupal\form_test\ConfirmFormTestForm::getCancelPath(). */ - protected function getCancelPath() { + public function getCancelPath() { return array( 'path' => 'admin', 'query' => array( @@ -34,7 +34,7 @@ protected function getCancelPath() { /** * Overrides \Drupal\form_test\ConfirmFormTestForm::getCancelText(). */ - protected function getCancelText() { + public function getCancelText() { return t('ConfirmFormArrayPathTestForm::getCancelText().'); } diff --git a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php index eefa436..f18ffa2 100644 --- a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php +++ b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test; use Drupal\Core\Form\ConfirmFormBase; +use Symfony\Component\HttpFoundation\Request; /** * Provides a test confirmation form. @@ -15,58 +16,58 @@ class ConfirmFormTestForm extends ConfirmFormBase { /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'form_test_confirm_test_form'; } /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getQuestion(). + * {@inheritdoc} */ - protected function getQuestion() { + public function getQuestion() { return t('ConfirmFormTestForm::getQuestion().'); } /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). + * {@inheritdoc} */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin'; } /** - * Overrides \Drupal\Core\Form\ConfirmFormBase::getDescription(). + * {@inheritdoc} */ - protected function getDescription() { + public function getDescription() { return t('ConfirmFormTestForm::getDescription().'); } /** - * Overrides \Drupal\Core\Form\ConfirmFormBase::getConfirmText(). + * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('ConfirmFormTestForm::getConfirmText().'); } /** - * Overrides \Drupal\Core\Form\ConfirmFormBase::getCancelText(). + * {@inheritdoc} */ - protected function getCancelText() { + public function getCancelText() { return t('ConfirmFormTestForm::getCancelText().'); } /** - * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, array &$form_state, Request $request = NULL) { $form['element'] = array('#markup' => '

The ConfirmFormTestForm::buildForm() method was used for this form.

'); - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { drupal_set_message(t('The ConfirmFormTestForm::submitForm() method was used for this form.')); diff --git a/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php b/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php index 2108b92..817de06 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php +++ b/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php @@ -7,66 +7,41 @@ namespace Drupal\user\Form; -use Drupal\Core\Form\ConfirmFormBase; -use Drupal\user\RoleInterface; +use Drupal\Core\Entity\EntityConfirmFormBase; /** * Provides a deletion confirmation form for Role entity. */ -class UserRoleDelete extends ConfirmFormBase { - - /** - * The role being deleted. - * - * @var \Drupal\user\RoleInterface - */ - protected $role; +class UserRoleDelete extends EntityConfirmFormBase { /** * {@inheritdoc} */ - public function getFormID() { - return 'user_admin_role_delete_confirm'; + public function getQuestion() { + return t('Are you sure you want to delete the role %name?', array('%name' => $this->entity->label())); } /** * {@inheritdoc} */ - protected function getQuestion() { - return t('Are you sure you want to delete the role %name?', array('%name' => $this->role->label())); - } - - /** - * {@inheritdoc} - */ - protected function getCancelPath() { + public function getCancelPath() { return 'admin/people/roles'; } /** * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Delete'); } /** * {@inheritdoc} - * @param \Drupal\user\RoleInterface $user_role - * The role being deleted. */ - public function buildForm(array $form, array &$form_state, RoleInterface $user_role = NULL) { - $this->role = $user_role; - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - $this->role->delete(); - watchdog('user', 'Role %name has been deleted.', array('%name' => $this->role->label())); - drupal_set_message(t('Role %name has been deleted.', array('%name' => $this->role->label()))); + public function submit(array $form, array &$form_state) { + $this->entity->delete(); + watchdog('user', 'Role %name has been deleted.', array('%name' => $this->entity->label())); + drupal_set_message(t('Role %name has been deleted.', array('%name' => $this->entity->label()))); $form_state['redirect'] = 'admin/people/roles'; } diff --git a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php index 5a288c8..5d2445e 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php @@ -24,7 +24,8 @@ * "access" = "Drupal\user\RoleAccessController", * "list" = "Drupal\user\RoleListController", * "form" = { - * "default" = "Drupal\user\RoleFormController" + * "default" = "Drupal\user\RoleFormController", + * "delete" = "Drupal\user\Form\UserRoleDelete" * } * }, * config_prefix = "user.role", diff --git a/core/modules/user/user.routing.yml b/core/modules/user/user.routing.yml index b48c808..6461f64 100644 --- a/core/modules/user/user.routing.yml +++ b/core/modules/user/user.routing.yml @@ -65,6 +65,6 @@ user_role_edit: user_role_delete: pattern: '/admin/people/roles/manage/{user_role}/delete' defaults: - _form: '\Drupal\user\Form\UserRoleDelete' + _entity_form: user_role.delete requirements: _entity_access: user_role.delete diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php index 936103c..e33b3f5 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php @@ -7,18 +7,17 @@ namespace Drupal\views_ui\Form; -use Symfony\Component\DependencyInjection\ContainerInterface; - -use Drupal\Core\Controller\ControllerInterface; -use Drupal\Core\Form\ConfirmFormBase; -use Drupal\views\ViewStorageInterface; +use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityManager; use Drupal\user\TempStoreFactory; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; /** * Builds the form to break the lock of an edited view. */ -class BreakLockForm extends ConfirmFormBase implements ControllerInterface { +class BreakLockForm extends EntityConfirmFormBase implements EntityControllerInterface { /** * Stores the Entity manager. @@ -35,13 +34,6 @@ class BreakLockForm extends ConfirmFormBase implements ControllerInterface { protected $tempStore; /** - * The view being deleted. - * - * @var \Drupal\views\ViewStorageInterface - */ - protected $view; - - /** * Constructs a \Drupal\views_ui\Form\BreakLockForm object. * * @param \Drupal\Core\Entity\EntityManager $entity_manager @@ -57,7 +49,7 @@ public function __construct(EntityManager $entity_manager, TempStoreFactory $tem /** * {@inheritdoc} */ - public static function create(ContainerInterface $container) { + public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( $container->get('plugin.manager.entity'), $container->get('user.tempstore') @@ -65,60 +57,59 @@ public static function create(ContainerInterface $container) { } /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'views_ui_break_lock_confirm'; } /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getQuestion(). + * {@inheritdoc} */ - protected function getQuestion() { - return t('Do you want to break the lock on view %name?', array('%name' => $this->view->id())); + public function getQuestion() { + return t('Do you want to break the lock on view %name?', array('%name' => $this->entity->id())); } /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getDescription(). + * {@inheritdoc} */ - protected function getDescription() { - $locked = $this->tempStore->getMetadata($this->view->id()); + public function getDescription() { + $locked = $this->tempStore->getMetadata($this->entity->id()); $accounts = $this->entityManager->getStorageController('user')->load(array($locked->owner)); return t('By breaking this lock, any unsaved changes made by !user will be lost.', array('!user' => theme('username', array('account' => reset($accounts))))); } /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). + * {@inheritdoc} */ - protected function getCancelPath() { - return 'admin/structure/views/view/' . $this->view->id(); + public function getCancelPath() { + return 'admin/structure/views/view/' . $this->entity->id(); } /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getConfirmText(). + * {@inheritdoc} */ - protected function getConfirmText() { + public function getConfirmText() { return t('Break lock'); } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, ViewStorageInterface $view = NULL) { - $this->view = $view; - if (!$this->tempStore->getMetadata($this->view->id())) { - $form['message']['#markup'] = t('There is no lock on view %name to break.', array('%name' => $this->view->id())); + public function buildForm(array $form, array &$form_state, Request $request = NULL) { + if (!$this->tempStore->getMetadata($this->entity->id())) { + $form['message']['#markup'] = t('There is no lock on view %name to break.', array('%name' => $this->entity->id())); return $form; } - return parent::buildForm($form, $form_state); + return parent::buildForm($form, $form_state, $request); } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { - $this->tempStore->delete($this->view->id()); - $form_state['redirect'] = 'admin/structure/views/view/' . $this->view->id(); + public function submit(array $form, array &$form_state) { + $this->tempStore->delete($this->entity->id()); + $form_state['redirect'] = 'admin/structure/views/view/' . $this->entity->id(); drupal_set_message(t('The lock has been broken and you may now edit this view.')); } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/DeleteForm.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/DeleteForm.php deleted file mode 100644 index e36d7ce..0000000 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/DeleteForm.php +++ /dev/null @@ -1,75 +0,0 @@ - $this->view->label())); - } - - /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). - */ - protected function getCancelPath() { - return 'admin/structure/views'; - } - - /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getConfirmText(). - */ - protected function getConfirmText() { - return t('Delete'); - } - - /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). - */ - public function getFormID() { - return 'views_ui_confirm_delete'; - } - - /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). - */ - public function buildForm(array $form, array &$form_state, ViewStorageInterface $view = NULL) { - $this->view = $view; - return parent::buildForm($form, $form_state); - } - - /** - * 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) { - $this->view->delete(); - $form_state['redirect'] = 'admin/structure/views'; - } - -} diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewDeleteFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewDeleteFormController.php new file mode 100644 index 0000000..18e81d0 --- /dev/null +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewDeleteFormController.php @@ -0,0 +1,48 @@ + $this->entity->label())); + } + + /** + * {@inheritdoc} + */ + public function getCancelPath() { + return 'admin/structure/views'; + } + + /** + * {@inheritdoc} + */ + public function getConfirmText() { + return t('Delete'); + } + + /** + * {@inheritdoc} + */ + public function submit(array $form, array &$form_state) { + parent::submit($form, $form_state); + + $this->entity->delete(); + $form_state['redirect'] = 'admin/structure/views'; + } + +} diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module index 21fdabe..cbbcde8 100644 --- a/core/modules/views_ui/views_ui.module +++ b/core/modules/views_ui/views_ui.module @@ -108,6 +108,8 @@ function views_ui_entity_info(&$entity_info) { 'add' => 'Drupal\views_ui\ViewAddFormController', 'preview' => 'Drupal\views_ui\ViewPreviewFormController', 'clone' => 'Drupal\views_ui\ViewCloneFormController', + 'delete' => 'Drupal\views_ui\ViewDeleteFormController', + 'break_lock' => 'Drupal\views_ui\Form\BreakLockForm', ), ); } diff --git a/core/modules/views_ui/views_ui.routing.yml b/core/modules/views_ui/views_ui.routing.yml index 16eff86..4502101 100644 --- a/core/modules/views_ui/views_ui.routing.yml +++ b/core/modules/views_ui/views_ui.routing.yml @@ -58,7 +58,7 @@ views_ui.clone: views_ui.delete: pattern: '/admin/structure/views/view/{view}/delete' defaults: - _form: 'Drupal\views_ui\Form\DeleteForm' + _entity_form: 'view.delete' requirements: _permission: 'administer views' @@ -104,8 +104,7 @@ views_ui.preview: views_ui.breakLock: pattern: '/admin/structure/views/view/{view}/break-lock' defaults: - _form: '\Drupal\views_ui\Form\BreakLockForm' - display_id: NULL + _entity_form: 'view.break_lock' requirements: _permission: 'administer views'