diff --git a/core/modules/aggregator/aggregator.routing.yml b/core/modules/aggregator/aggregator.routing.yml index 9a0a070..027e021 100644 --- a/core/modules/aggregator/aggregator.routing.yml +++ b/core/modules/aggregator/aggregator.routing.yml @@ -15,7 +15,7 @@ aggregator_admin_settings: aggregator_feed_items_delete: pattern: '/admin/config/services/aggregator/remove/{aggregator_feed}' defaults: - _entity_form: 'aggregator_feed.delete_items' + _entity_form: 'aggregator_feed.remove_items' 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/FeedItemsDeleteForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsDeleteForm.php deleted file mode 100644 index 9b713ce..0000000 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsDeleteForm.php +++ /dev/null @@ -1,84 +0,0 @@ -manager = $manager; - } - - /** - * {@inheritdoc} - */ - public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { - return new static( - $container->get('plugin.manager.aggregator.processor') - ); - } - - /** - * {@inheritdoc} - */ - public function getQuestion() { - return t('Are you sure you want to remove all items from the feed %feed?', array('%feed' => $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) { - foreach ($this->manager->getDefinitions() as $id => $definition) { - $this->manager->createInstance($id)->remove($this->entity); - } - // Reset feed. - $this->entity->checked->value = 0; - $this->entity->hash->value = ''; - $this->entity->etag->value = ''; - $this->entity->modified->value = 0; - $this->entity->save(); - - $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 fe1c153..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 @@ -25,7 +25,7 @@ * "form" = { * "default" = "Drupal\aggregator\FeedFormController", * "delete" = "Drupal\aggregator\Form\FeedDeleteForm", - * "delete_items" = "Drupal\aggregator\Form\FeedItemsDeleteForm" + * "remove_items" = "Drupal\aggregator\Form\FeedItemsRemoveForm" * } * }, * base_table = "aggregator_feed", @@ -175,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/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 8899eed..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(). - */ - public 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/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php index 39b6510..d079b51 100644 --- a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php +++ b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php @@ -7,33 +7,25 @@ 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} */ public function getQuestion() { - return t('Are you sure you want to reset the link %item to its default values?', array('%item' => $this->menuLink->link_title)); + return t('Are you sure you want to reset the link %item to its default values?', array('%item' => $this->entity->link_title)); } /** * {@inheritdoc} */ public function getCancelPath() { - return 'admin/structure/menu/manage/' . $this->menuLink->menu_name; + return 'admin/structure/menu/manage/' . $this->entity->menu_name; } /** @@ -53,25 +45,10 @@ public function getConfirmText() { /** * {@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 c8a9748..0d77e24 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -153,6 +153,7 @@ function menu_entity_info(&$entity_info) { ); $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 e7823a2..62c54f2 100644 --- a/core/modules/menu/menu.routing.yml +++ b/core/modules/menu/menu.routing.yml @@ -8,7 +8,7 @@ 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' 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 651f571..0000000 --- a/core/modules/picture/lib/Drupal/picture/Form/PictureMappingActionConfirmForm.php +++ /dev/null @@ -1,68 +0,0 @@ - $this->pictureMapping->label())); - } - - /** - * {@inheritdoc} - */ - public function getCancelPath() { - return 'admin/config/media/picturemapping'; - } - - /** - * {@inheritdoc} - */ - public 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/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatLocalizeResetForm.php index 0008d0c..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\Controller\ControllerInterface; use Drupal\Core\Form\ConfirmFormBase; -use Drupal\Core\ControllerInterface; use Drupal\Core\Config\ConfigFactory; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; /** * Builds a form for enabling a module. @@ -91,10 +92,10 @@ public 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 82670de..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. @@ -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 9d2d9d5..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. @@ -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 6177dfd..1e6abbd 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -781,7 +781,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. @@ -1194,7 +1194,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/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php index af9c554..eadf015 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 Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Entity\EntityControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; - -use Drupal\Core\ControllerInterface; -use Drupal\Core\Form\ConfirmFormBase; -use Drupal\views\ViewStorageInterface; use Drupal\Core\Entity\EntityManager; use Drupal\user\TempStoreFactory; +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 @@ -55,9 +47,9 @@ public function __construct(EntityManager $entity_manager, TempStoreFactory $tem } /** - * Implements \Drupal\Core\ControllerInterface::create(). + * {@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} */ public function getQuestion() { - return t('Do you want to break the lock on view %name?', array('%name' => $this->view->id())); + return t('Do you want to break the lock on view %name?', array('%name' => $this->entity->id())); } /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getDescription(). + * {@inheritdoc} */ public function getDescription() { - $locked = $this->tempStore->getMetadata($this->view->id()); + $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} */ public function getCancelPath() { - return 'admin/structure/views/view/' . $this->view->id(); + return 'admin/structure/views/view/' . $this->entity->id(); } /** - * Implements \Drupal\Core\Form\ConfirmFormBase::getConfirmText(). + * {@inheritdoc} */ 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/views_ui.module b/core/modules/views_ui/views_ui.module index 416ee72..cbbcde8 100644 --- a/core/modules/views_ui/views_ui.module +++ b/core/modules/views_ui/views_ui.module @@ -109,6 +109,7 @@ function views_ui_entity_info(&$entity_info) { '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 e45e963..376f1b3 100644 --- a/core/modules/views_ui/views_ui.routing.yml +++ b/core/modules/views_ui/views_ui.routing.yml @@ -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'