diff --git a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php index a174e31..635e446 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php @@ -81,14 +81,33 @@ public function form(array $form, array &$form_state) { * {@inheritdoc} */ protected function actions(array $form, array &$form_state) { - $actions = parent::actions($form, $form_state); - $actions['submit']['#value'] = $this->getConfirmText(); - unset($actions['delete']); - - // Prepare cancel link. - $actions['cancel'] = ConfirmFormHelper::buildCancelLink($this, $this->getRequest()); - - return $actions; + return array( + 'submit' => array( + '#value' => $this->getConfirmText(), + '#validate' => array( + array($this, 'validate'), + ), + '#submit' => array( + array($this, 'submitForm'), + ), + ), + 'cancel' => ConfirmFormHelper::buildCancelLink($this, $this->getRequest()), + ); } + /** + * {@inheritdoc} + * + * The save method makes no sense on EntityConfirmFormBase. Form submissions + * should be processed by overriding the submitForm method. + */ + public function save(array $form, array &$form_state) {} + + /** + * {@inheritdoc} + * + * The delete method makes no sense on EntityConfirmFormBase. Form submissions + * should be processed by overriding the submitForm method. + */ + public function delete(array $form, array &$form_state) {} } diff --git a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php index 564fa88..1cb1083 100644 --- a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php @@ -74,13 +74,34 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ protected function actions(array $form, array &$form_state) { - $actions = parent::actions($form, $form_state); - $actions['submit']['#value'] = $this->getConfirmText(); - unset($actions['delete']); - - // Prepare cancel link. - $actions['cancel'] = ConfirmFormHelper::buildCancelLink($this, $this->getRequest()); - return $actions; + return array( + 'submit' => array( + '#value' => $this->getConfirmText(), + '#validate' => array( + array($this, 'validate'), + ), + '#submit' => array( + array($this, 'submitForm'), + ), + ), + 'cancel' => ConfirmFormHelper::buildCancelLink($this, $this->getRequest()), + ); } + /** + * {@inheritdoc} + * + * The save method makes no sense on EntityConfirmFormBase. Form submissions + * should be processed by overriding the submitForm method. + */ + public function save(array $form, array &$form_state) {} + + /** + * {@inheritdoc} + * + * The delete method makes no sense on EntityConfirmFormBase. Form submissions + * should be processed by overriding the submitForm method. + */ + public function delete(array $form, array &$form_state) {} + } diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php index c80daa4..80f4200 100644 --- a/core/lib/Drupal/Core/Entity/EntityForm.php +++ b/core/lib/Drupal/Core/Entity/EntityForm.php @@ -105,12 +105,6 @@ public function buildForm(array $form, array &$form_state) { } /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - } - - /** * Initialize the form state and the entity before the first form build. */ protected function init(array &$form_state) { @@ -207,7 +201,9 @@ protected function actionsElement(array $form, array &$form_state) { * many entity types. */ protected function actions(array $form, array &$form_state) { - // @todo Rename the action key from submit to save. + // @todo Consider renaming the action key from submit to save. The impacts + // are hard to predict. For example, see + // language_configuration_element_process(). $actions['submit'] = array( '#type' => 'submit', '#value' => $this->t('Save'), @@ -215,7 +211,7 @@ protected function actions(array $form, array &$form_state) { array($this, 'validate'), ), '#submit' => array( - array($this, 'submit'), + array($this, 'submitForm'), array($this, 'save'), ), ); @@ -255,33 +251,38 @@ public function validate(array $form, array &$form_state) { * {@inheritdoc} * * This is the default entity object builder function. It is called before any - * other submit handler to build the new entity object to be passed to the + * other submit handler to build the new entity object to be used by the * following submit handlers. At this point of the form workflow the entity is * validated and the form state can be updated, this way the subsequently - * invoked handlers can retrieve a regular entity object to act on. + * invoked handlers can retrieve a regular entity object to act on. Generally + * this method should not be overridden unless the entity requires the same + * preparation for two actions, see \Drupal\comment\CommentFormController for + * an example with the save and preview actions. * * @param array $form * An associative array containing the structure of the form. * @param array $form_state * A reference to a keyed array containing the current state of the form. */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { // Remove button and internal Form API values from submitted values. form_state_values_clean($form_state); $this->entity = $this->buildEntity($form, $form_state); - return $this->entity; } /** * Form submission handler for the 'save' action. * + * Normally this method should be overridden to provide specific messages to + * the user and redirect the form after the entity has been saved. + * * @param array $form * An associative array containing the structure of the form. * @param array $form_state * A reference to a keyed array containing the current state of the form. */ public function save(array $form, array &$form_state) { - // @todo Perform common save operations. + $this->entity->save(); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityFormInterface.php b/core/lib/Drupal/Core/Entity/EntityFormInterface.php index aae4c5f..df1566d 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityFormInterface.php @@ -115,20 +115,6 @@ public function buildEntity(array $form, array &$form_state); public function validate(array $form, array &$form_state); /** - * Updates the form's entity by processing this submission's values. - * - * Note: Before this can be safely invoked the entity form must have passed - * validation, i.e. only add this as form #submit handler if validation is - * added as well. - * - * @param array $form - * A nested array form elements comprising the form. - * @param array $form_state - * An associative array containing the current state of the form. - */ - public function submit(array $form, array &$form_state); - - /** * Sets the translation manager for this form. * * @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager diff --git a/core/modules/action/lib/Drupal/action/ActionFormBase.php b/core/modules/action/lib/Drupal/action/ActionFormBase.php index c2cbee3..64a52bd 100644 --- a/core/modules/action/lib/Drupal/action/ActionFormBase.php +++ b/core/modules/action/lib/Drupal/action/ActionFormBase.php @@ -133,13 +133,12 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); + public function submitForm(array &$form, array &$form_state) { + parent::submitForm($form, $form_state); if ($this->plugin instanceof PluginFormInterface) { $this->plugin->submitConfigurationForm($form, $form_state); } - return $this->entity; } /** diff --git a/core/modules/action/lib/Drupal/action/Form/ActionDeleteForm.php b/core/modules/action/lib/Drupal/action/Form/ActionDeleteForm.php index 968b7f0..02cbfb2 100644 --- a/core/modules/action/lib/Drupal/action/Form/ActionDeleteForm.php +++ b/core/modules/action/lib/Drupal/action/Form/ActionDeleteForm.php @@ -40,7 +40,7 @@ public function getCancelRoute() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $this->entity->id(), '%action' => $this->entity->label())); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php index 7cc3827..8c3a817 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php @@ -40,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $this->entity->label())); drupal_set_message($this->t('The feed %feed has been deleted.', array('%feed' => $this->entity->label()))); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsDeleteForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsDeleteForm.php index f053281..6fcf914 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsDeleteForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsDeleteForm.php @@ -40,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->deleteItems(); $form_state['redirect_route']['route_name'] = 'aggregator.admin_overview'; diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockForm.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockForm.php index f495c4f..7aacbff 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockForm.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockForm.php @@ -167,7 +167,7 @@ public function form(array $form, array &$form_state) { } /** - * Overrides \Drupal\Core\Entity\EntityForm::submit(). + * {@inheritdoc} * * Updates the custom block object by processing the submitted values. * @@ -175,23 +175,15 @@ public function form(array $form, array &$form_state) { * form state's entity with the current step's values before proceeding to the * next step. */ - public function submit(array $form, array &$form_state) { - // Build the block object from the submitted values. - $block = parent::submit($form, $form_state); + public function save(array $form, array &$form_state) { + /** @var \Drupal\custom_block\CustomBlockInterface $block */ + $block = $this->entity; // Save as a new revision if requested to do so. if (!empty($form_state['values']['revision'])) { $block->setNewRevision(); } - return $block; - } - - /** - * {@inheritdoc} - */ - public function save(array $form, array &$form_state) { - $block = $this->entity; $insert = $block->isNew(); $block->save(); $watchdog_args = array('@type' => $block->bundle(), '%info' => $block->label()); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeForm.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeForm.php index c790efa..75b133f 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeForm.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeForm.php @@ -85,7 +85,7 @@ public function form(array $form, array &$form_state) { } /** - * Overrides \Drupal\Core\Entity\EntityForm::save(). + * {@inheritdoc} */ public function save(array $form, array &$form_state) { $block_type = $this->entity; diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php index 36df166..4d17f11 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php @@ -54,7 +54,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); drupal_set_message($this->t('Custom block %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('custom_block', 'Custom block %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php index 8b7a681..25e5268 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php @@ -83,7 +83,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); $form_state['redirect_route']['route_name'] = 'custom_block.type_list'; drupal_set_message(t('Custom block type %label has been deleted.', array('%label' => $this->entity->label()))); diff --git a/core/modules/block/lib/Drupal/block/BlockForm.php b/core/modules/block/lib/Drupal/block/BlockForm.php index 350fde6..005a63e 100644 --- a/core/modules/block/lib/Drupal/block/BlockForm.php +++ b/core/modules/block/lib/Drupal/block/BlockForm.php @@ -302,8 +302,8 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); + public function submitForm(array &$form, array &$form_state) { + parent::submitForm($form, $form_state); $entity = $this->entity; // The Block Entity form puts all block plugin form elements in the diff --git a/core/modules/block/lib/Drupal/block/Form/BlockDeleteForm.php b/core/modules/block/lib/Drupal/block/Form/BlockDeleteForm.php index 20c1e7e..90bb8ac 100644 --- a/core/modules/block/lib/Drupal/block/Form/BlockDeleteForm.php +++ b/core/modules/block/lib/Drupal/block/Form/BlockDeleteForm.php @@ -40,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); drupal_set_message($this->t('The block %name has been removed.', array('%name' => $this->entity->label()))); $form_state['redirect_route']['route_name'] = 'block.admin_display'; diff --git a/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php b/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php index f4a97a1..3d146c2 100644 --- a/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php +++ b/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php @@ -97,10 +97,8 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} - * - * @see book_remove_button_submit() */ - public function submit(array $form, array &$form_state) { + public function save(array $form, array &$form_state) { $form_state['redirect_route'] = array( 'route_name' => 'node.view', 'route_parameters' => array( diff --git a/core/modules/comment/lib/Drupal/comment/CommentForm.php b/core/modules/comment/lib/Drupal/comment/CommentForm.php index ad0de74..f4c8df3 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentForm.php +++ b/core/modules/comment/lib/Drupal/comment/CommentForm.php @@ -262,7 +262,7 @@ protected function actions(array $form, array &$form_state) { array($this, 'validate'), ), '#submit' => array( - array($this, 'submit'), + array($this, 'submitForm'), array($this, 'preview'), ), ); @@ -319,12 +319,12 @@ public function buildEntity(array $form, array &$form_state) { } /** - * Overrides Drupal\Core\Entity\EntityForm::submit(). + * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { + parent::submitForm($form, $form_state); /** @var \Drupal\comment\CommentInterface $comment */ - $comment = parent::submit($form, $form_state); - + $comment = $this->entity; // If the comment was posted by a registered user, assign the author's ID. // @todo Too fragile. Should be prepared and stored in comment_form() // already. diff --git a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php index b2687f1..86d52e2 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php +++ b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php @@ -90,7 +90,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { // Delete the comment and its replies. $this->entity->delete(); drupal_set_message($this->t('The comment and all its replies have been deleted.')); diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestForm.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestForm.php index 6fcc00c..7cee08c 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestForm.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestForm.php @@ -66,7 +66,7 @@ public function form(array $form, array &$form_state) { } /** - * Overrides Drupal\Core\Entity\EntityForm::save(). + * {@inheritdoc} */ public function save(array $form, array &$form_state) { $entity = $this->entity; 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 4d0a184..fe8fa67 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 @@ -40,7 +40,7 @@ public function getCancelRoute() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(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_route']['route_name'] = 'config_test.list_page'; diff --git a/core/modules/contact/lib/Drupal/contact/CategoryForm.php b/core/modules/contact/lib/Drupal/contact/CategoryForm.php index a810b1e..33d9bbc 100644 --- a/core/modules/contact/lib/Drupal/contact/CategoryForm.php +++ b/core/modules/contact/lib/Drupal/contact/CategoryForm.php @@ -93,7 +93,7 @@ public function validate(array $form, array &$form_state) { } /** - * Overrides Drupal\Core\Entity\EntityForm::save(). + * {@inheritdoc} */ public function save(array $form, array &$form_state) { $category = $this->entity; diff --git a/core/modules/contact/lib/Drupal/contact/Form/CategoryDeleteForm.php b/core/modules/contact/lib/Drupal/contact/Form/CategoryDeleteForm.php index dac498e..4e5b089 100644 --- a/core/modules/contact/lib/Drupal/contact/Form/CategoryDeleteForm.php +++ b/core/modules/contact/lib/Drupal/contact/Form/CategoryDeleteForm.php @@ -40,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(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); diff --git a/core/modules/contact/lib/Drupal/contact/MessageForm.php b/core/modules/contact/lib/Drupal/contact/MessageForm.php index d28a8cb..4dc8e16 100644 --- a/core/modules/contact/lib/Drupal/contact/MessageForm.php +++ b/core/modules/contact/lib/Drupal/contact/MessageForm.php @@ -165,7 +165,7 @@ public function actions(array $form, array &$form_state) { array($this, 'validate'), ), '#submit' => array( - array($this, 'submit'), + array($this, 'submitForm'), array($this, 'preview'), ), ); @@ -182,7 +182,7 @@ public function preview(array $form, array &$form_state) { } /** - * Overrides Drupal\Core\Entity\EntityForm::save(). + * {@inheritdoc} */ public function save(array $form, array &$form_state) { $user = \Drupal::currentUser(); diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php index d2f22d0..4ea5ff3 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php @@ -49,11 +49,9 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); - + public function submitForm(array &$form, array &$form_state) { $entity_type = $this->entity->getEntityType(); - drupal_set_message(t('Deleted the %label @entity-type.', array('%label' => $this->entity->label(), '@entity-type' => $entity_type->getLowercaseLabel()))); + drupal_set_message(t('Deleted the %label @entity-type.', array('%label' => $this->entity->label(), '@entity-type' => strtolower($entity_type->getLabel())))); $this->entity->delete(); entity_info_cache_clear(); $form_state['redirect_route']['route_name'] = 'entity.' . $this->entity->getEntityTypeId() . '_list'; diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceConfigDeleteForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceConfigDeleteForm.php index 87dfafc..f1357ff 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceConfigDeleteForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceConfigDeleteForm.php @@ -67,7 +67,7 @@ public function getCancelRoute() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $field = $this->entity->getField(); $bundles = entity_get_bundles(); $bundle_label = $bundles[$this->entity->entity_type][$this->entity->bundle]['label']; diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatAddForm.php b/core/modules/filter/lib/Drupal/filter/FilterFormatAddForm.php index b8814f4..05a80be 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatAddForm.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatAddForm.php @@ -22,10 +22,9 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); + public function submitForm(array &$form, array &$form_state) { + parent::submitForm($form, $form_state); drupal_set_message(t('Added text format %format.', array('%format' => $this->entity->label()))); - return $this->entity; } } diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatEditForm.php b/core/modules/filter/lib/Drupal/filter/FilterFormatEditForm.php index 42cdc64..8090dea 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatEditForm.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatEditForm.php @@ -31,10 +31,9 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); + public function submitForm(array &$form, array &$form_state) { + parent::submitForm($form, $form_state); drupal_set_message(t('The text format %format has been updated.', array('%format' => $this->entity->label()))); - return $this->entity; } } diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatFormBase.php b/core/modules/filter/lib/Drupal/filter/FilterFormatFormBase.php index 2f986ff..608b94f 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatFormBase.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatFormBase.php @@ -244,8 +244,8 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); + public function submitForm(array &$form, array &$form_state) { + parent::submitForm($form, $form_state); // Add the submitted form values to the text format, and save it. $format = $this->entity; diff --git a/core/modules/filter/lib/Drupal/filter/Form/FilterDisableForm.php b/core/modules/filter/lib/Drupal/filter/Form/FilterDisableForm.php index 125015e..ddd6d7e 100644 --- a/core/modules/filter/lib/Drupal/filter/Form/FilterDisableForm.php +++ b/core/modules/filter/lib/Drupal/filter/Form/FilterDisableForm.php @@ -47,7 +47,7 @@ public function getDescription() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->disable()->save(); drupal_set_message(t('Disabled text format %format.', array('%format' => $this->entity->label()))); diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleAddForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleAddForm.php index 64c2a37..6054e78 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleAddForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleAddForm.php @@ -15,8 +15,8 @@ class ImageStyleAddForm extends ImageStyleFormBase { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { - parent::save($form, $form_state); + public function submitForm(array &$form, array &$form_state) { + parent::submitForm($form, $form_state); drupal_set_message($this->t('Style %name was created.', array('%name' => $this->entity->label()))); } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php index 470f31d..a3e6db3 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php @@ -62,7 +62,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->set('replacementID', $form_state['values']['replacement']); $this->entity->delete(); drupal_set_message($this->t('Style %name was deleted.', array('%name' => $this->entity->label()))); diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php index 1e7d782..930b56c 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php @@ -213,14 +213,14 @@ public function effectSave($form, &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { // Update image effect weights. if (!empty($form_state['values']['effects'])) { $this->updateEffectWeights($form_state['values']['effects']); } - parent::save($form, $form_state); + parent::submitForm($form, $form_state); drupal_set_message($this->t('Changes to the style have been saved.')); } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php index 2c87bb2..7f848fd 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php @@ -47,7 +47,7 @@ public function getCancelRoute() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->flush(); drupal_set_message($this->t('The image style %name has been flushed.', array('%name' => $this->entity->label()))); $form_state['redirect_route']['route_name'] = 'image.style_list'; diff --git a/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php b/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php index 241bbe7..b0dba10 100644 --- a/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php +++ b/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php @@ -106,7 +106,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { // @todo This should be replaced with $this->entity->delete() when the // additional logic in language_delete() is ported. $success = language_delete($this->entity->id()); diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkForm.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkForm.php index 422906f..4a20cd4 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkForm.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkForm.php @@ -270,11 +270,12 @@ public function buildEntity(array $form, array &$form_state) { } /** - * Overrides EntityForm::submit(). + * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { // Build the menu link object from the submitted values. - $menu_link = parent::submit($form, $form_state); + parent::submitForm($form, $form_state); + $menu_link = $this->entity; // The value of "hidden" is the opposite of the value supplied by the // "enabled" checkbox. @@ -283,8 +284,6 @@ public function submit(array $form, array &$form_state) { $menu_link->options['attributes']['title'] = $menu_link->description; list($menu_link->menu_name, $menu_link->plid) = explode(':', $menu_link->parent); - - return $menu_link; } /** diff --git a/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuDeleteForm.php b/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuDeleteForm.php index 98a45db..980a821 100644 --- a/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuDeleteForm.php +++ b/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuDeleteForm.php @@ -96,7 +96,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $form_state['redirect_route']['route_name'] = 'menu_ui.overview_page'; // Locked menus may not be deleted. diff --git a/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuLinkDeleteForm.php b/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuLinkDeleteForm.php index eeb40a6..8f5e9f6 100644 --- a/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuLinkDeleteForm.php +++ b/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuLinkDeleteForm.php @@ -36,7 +36,7 @@ public function getCancelRoute() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(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)); diff --git a/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuLinkResetForm.php b/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuLinkResetForm.php index 31b23ab..f44ffb3 100644 --- a/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuLinkResetForm.php +++ b/core/modules/menu_ui/lib/Drupal/menu_ui/Form/MenuLinkResetForm.php @@ -50,7 +50,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(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_route'] = array( diff --git a/core/modules/menu_ui/lib/Drupal/menu_ui/MenuForm.php b/core/modules/menu_ui/lib/Drupal/menu_ui/MenuForm.php index aa8a51a..108c297 100644 --- a/core/modules/menu_ui/lib/Drupal/menu_ui/MenuForm.php +++ b/core/modules/menu_ui/lib/Drupal/menu_ui/MenuForm.php @@ -181,14 +181,14 @@ protected function actions(array $form, array &$form_state) { $actions['delete']['#access'] = !$this->entity->isNew() && $this->entity->access('delete'); // Add the language configuration submit handler. This is needed because the - // submit button has custom submit handlers. + // save button has custom submit handlers. if ($this->moduleHandler->moduleExists('language')) { array_unshift($actions['submit']['#submit'],'language_configuration_element_submit'); array_unshift($actions['submit']['#submit'], array($this, 'languageConfigurationSubmit')); } // We cannot leverage the regular submit handler definition because we have // button-specific ones here. Hence we need to explicitly set it for the - // submit action, otherwise it would be ignored. + // save action, otherwise it would be ignored. if ($this->moduleHandler->moduleExists('content_translation')) { array_unshift($actions['submit']['#submit'], 'content_translation_language_configuration_element_submit'); } diff --git a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php index 164ac5f..5f28721 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php @@ -83,7 +83,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); watchdog('content', '@type: deleted %title.', array('@type' => $this->entity->bundle(), '%title' => $this->entity->label())); $node_type_storage = $this->entityManager->getStorage('node_type'); diff --git a/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php b/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php index 8adc575..1ef65aa 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php @@ -83,7 +83,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); $t_args = array('%name' => $this->entity->label()); drupal_set_message(t('The content type %name has been deleted.', $t_args)); diff --git a/core/modules/node/lib/Drupal/node/NodeForm.php b/core/modules/node/lib/Drupal/node/NodeForm.php index 37bb7da..8193695 100644 --- a/core/modules/node/lib/Drupal/node/NodeForm.php +++ b/core/modules/node/lib/Drupal/node/NodeForm.php @@ -287,7 +287,7 @@ protected function actions(array $form, array &$form_state) { array($this, 'validate'), ), '#submit' => array( - array($this, 'submit'), + array($this, 'submitForm'), array($this, 'preview'), ), ); @@ -335,17 +335,18 @@ public function validate(array $form, array &$form_state) { } /** + * {@inheritdoc} + * * Updates the node object by processing the submitted values. * * This function can be called by a "Next" button of a wizard to update the * form state's entity with the current step's values before proceeding to the * next step. - * - * Overrides Drupal\Core\Entity\EntityForm::submit(). */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { // Build the node object from the submitted values. - $node = parent::submit($form, $form_state); + parent::submitForm($form, $form_state); + $node = $this->entity; // Save as a new revision if requested to do so. if (!empty($form_state['values']['revision']) && $form_state['values']['revision'] != FALSE) { @@ -363,8 +364,6 @@ public function submit(array $form, array &$form_state) { $function = $module . '_node_submit'; $function($node, $form, $form_state); } - - return $node; } /** @@ -435,7 +434,6 @@ public function buildEntity(array $form, array &$form_state) { return $entity; } - /** * Overrides Drupal\Core\Entity\EntityForm::save(). */ diff --git a/core/modules/responsive_image/lib/Drupal/responsive_image/Form/ResponsiveImageMappingDeleteForm.php b/core/modules/responsive_image/lib/Drupal/responsive_image/Form/ResponsiveImageMappingDeleteForm.php index 2f79f57..e6eb5e4 100644 --- a/core/modules/responsive_image/lib/Drupal/responsive_image/Form/ResponsiveImageMappingDeleteForm.php +++ b/core/modules/responsive_image/lib/Drupal/responsive_image/Form/ResponsiveImageMappingDeleteForm.php @@ -37,7 +37,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); drupal_set_message($this->t('Responsive image mapping %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('responsive_image', 'Responsive image mapping %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); diff --git a/core/modules/responsive_image/lib/Drupal/responsive_image/ResponsiveImageMappingForm.php b/core/modules/responsive_image/lib/Drupal/responsive_image/ResponsiveImageMappingForm.php index 1b4bb4a..17f8863 100644 --- a/core/modules/responsive_image/lib/Drupal/responsive_image/ResponsiveImageMappingForm.php +++ b/core/modules/responsive_image/lib/Drupal/responsive_image/ResponsiveImageMappingForm.php @@ -115,7 +115,7 @@ public function validate(array $form, array &$form_state) { } /** - * Overrides Drupal\Core\Entity\EntityForm::save(). + * {@inheritdoc} */ public function save(array $form, array &$form_state) { /** @var \Drupal\responsive_image\ResponsiveImageMappingInterface $responsive_image_mapping */ diff --git a/core/modules/search/lib/Drupal/search/Form/SearchPageDeleteForm.php b/core/modules/search/lib/Drupal/search/Form/SearchPageDeleteForm.php index c9a5752..7037a38 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchPageDeleteForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchPageDeleteForm.php @@ -40,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); $form_state['redirect_route']['route_name'] = 'search.settings'; drupal_set_message($this->t('The %label search page has been deleted.', array('%label' => $this->entity->label()))); diff --git a/core/modules/search/lib/Drupal/search/Form/SearchPageFormBase.php b/core/modules/search/lib/Drupal/search/Form/SearchPageFormBase.php index 43fed9c..72a4120 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchPageFormBase.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchPageFormBase.php @@ -163,8 +163,8 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); + public function submitForm(array &$form, array &$form_state) { + parent::submitForm($form, $form_state); if ($this->plugin instanceof PluginFormInterface) { $this->plugin->submitConfigurationForm($form, $form_state); diff --git a/core/modules/shortcut/src/Form/SetCustomize.php b/core/modules/shortcut/src/Form/SetCustomize.php index 716f7ea..2208857 100644 --- a/core/modules/shortcut/src/Form/SetCustomize.php +++ b/core/modules/shortcut/src/Form/SetCustomize.php @@ -89,7 +89,7 @@ protected function actions(array $form, array &$form_state) { '#value' => t('Save changes'), '#access' => (bool) Element::getVisibleChildren($form['shortcuts']['links']), '#submit' => array( - array($this, 'submit'), + array($this, 'submitForm'), array($this, 'save'), ), ), diff --git a/core/modules/shortcut/src/Form/ShortcutDeleteForm.php b/core/modules/shortcut/src/Form/ShortcutDeleteForm.php index b5bbabe..164556b 100644 --- a/core/modules/shortcut/src/Form/ShortcutDeleteForm.php +++ b/core/modules/shortcut/src/Form/ShortcutDeleteForm.php @@ -50,7 +50,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); $form_state['redirect_route'] = array( 'route_name' => 'shortcut.set_customize', diff --git a/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php b/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php index 504b81e..8375432 100644 --- a/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php +++ b/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php @@ -105,7 +105,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); $form_state['redirect_route']['route_name'] = 'shortcut.set_admin'; drupal_set_message(t('The shortcut set %title has been deleted.', array('%title' => $this->entity->label()))); diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatAddForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatAddForm.php index b9289a2..957b7fa 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatAddForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatAddForm.php @@ -21,12 +21,4 @@ protected function actions(array $form, array &$form_state) { return $actions; } - /** - * {@inheritdoc} - */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); - drupal_set_message(t('Custom date format added.')); - } - } diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php index 79629fa..52d13fc 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php @@ -71,7 +71,7 @@ public function getCancelRoute() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); drupal_set_message(t('Removed date format %format.', array('%format' => $this->entity->label()))); diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatEditForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatEditForm.php index 3b25d7e..3cc2b7b 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatEditForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatEditForm.php @@ -35,12 +35,4 @@ protected function actions(array $form, array &$form_state) { return $actions; } - /** - * {@inheritdoc} - */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); - drupal_set_message(t('Custom date format updated.')); - } - } diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php index 3dfb81e..57f52bf 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php @@ -188,12 +188,21 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - $form_state['redirect_route']['route_name'] = 'system.date_format_list'; + public function submitForm(array &$form, array &$form_state) { $form_state['values']['pattern'][$this->patternType] = trim($form_state['values']['date_format_pattern']); + parent::submitForm($form, $form_state); + } - parent::submit($form, $form_state); - $this->entity->save(); + public function save(array $form, array &$form_state) { + $form_state['redirect_route']['route_name'] = 'system.date_format_list'; + $form_state['redirect'] = 'admin/config/regional/date-time'; + $status = $this->entity->save(); + if ($status == SAVED_UPDATED) { + drupal_set_message(t('Custom date format updated.')); + } + else { + drupal_set_message(t('Custom date format added.')); + } } } diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestDeleteForm.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestDeleteForm.php index 5f84846..270cd6e 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestDeleteForm.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestDeleteForm.php @@ -34,8 +34,8 @@ public function getQuestion() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); + public function submitForm(array &$form, array &$form_state) { + parent::submitForm($form, $form_state); $entity = $this->entity; $entity->delete(); drupal_set_message(t('%entity_type @id has been deleted.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()))); diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestForm.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestForm.php index 849ea17..8b38dc6 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestForm.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestForm.php @@ -61,25 +61,16 @@ public function form(array $form, array &$form_state) { } /** - * Overrides \Drupal\Core\Entity\EntityForm::submit(). + * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - // Build the entity object from the submitted values. - $entity = parent::submit($form, $form_state); + public function save(array $form, array &$form_state) { + $entity = $this->entity; // Save as a new revision if requested to do so. if (!empty($form_state['values']['revision'])) { $entity->setNewRevision(); } - return $entity; - } - - /** - * Overrides Drupal\Core\Entity\EntityForm::save(). - */ - public function save(array $form, array &$form_state) { - $entity = $this->entity; $is_new = $entity->isNew(); $entity->save(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php index 58fbb12..061ef55 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php @@ -57,7 +57,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); $storage = $this->entityManager->getStorage('taxonomy_vocabulary'); $vocabulary = $storage->load($this->entity->bundle()); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDeleteForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDeleteForm.php index 8032901..d159cce 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDeleteForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDeleteForm.php @@ -55,7 +55,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); drupal_set_message($this->t('Deleted vocabulary %name.', array('%name' => $this->entity->label()))); watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php index bae776c..93d5bd4 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php @@ -80,8 +80,10 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { + parent::submitForm($form, $form_state); $this->termStorage->resetWeights($this->entity->id()); + drupal_set_message($this->t('Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label()))); watchdog('taxonomy', 'Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE); $form_state['redirect_route'] = $this->entity->urlInfo('edit-form'); diff --git a/core/modules/user/lib/Drupal/user/AccountForm.php b/core/modules/user/lib/Drupal/user/AccountForm.php index f85fca2..e4da8fc 100644 --- a/core/modules/user/lib/Drupal/user/AccountForm.php +++ b/core/modules/user/lib/Drupal/user/AccountForm.php @@ -376,8 +376,8 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); + public function submitForm(array &$form, array &$form_state) { + parent::submitForm($form, $form_state); $user = $this->getEntity($form_state); // If there's a session set to the users id, remove the password reset tag diff --git a/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php b/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php index 9f76e1e..e9a4c5e 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php @@ -151,7 +151,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { // Cancel account immediately, if the current user has administrative // privileges, no confirmation mail shall be sent, and the user does not // attempt to cancel the own account. diff --git a/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php b/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php index 8e99476..aa4511b 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php @@ -203,7 +203,7 @@ public function submitForm(array &$form, array &$form_state) { $admin_form->setEntity($account); // Calling this directly required to init form object with $account. $admin_form->buildForm($admin_form_mock, $admin_form_state, $this->request); - $admin_form->submit($admin_form_mock, $admin_form_state); + $admin_form->submitForm($admin_form_mock, $admin_form_state); } else { user_cancel($form_state['values'], $uid, $form_state['values']['user_cancel_method']); diff --git a/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php b/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php index bbb3614..1449e35 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php +++ b/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php @@ -40,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); watchdog('user', 'Role %name has been deleted.', array('%name' => $this->entity->label())); drupal_set_message($this->t('Role %name has been deleted.', array('%name' => $this->entity->label()))); diff --git a/core/modules/user/lib/Drupal/user/RegisterForm.php b/core/modules/user/lib/Drupal/user/RegisterForm.php index 30f3018..e8eb2c7 100644 --- a/core/modules/user/lib/Drupal/user/RegisterForm.php +++ b/core/modules/user/lib/Drupal/user/RegisterForm.php @@ -69,9 +69,9 @@ protected function actions(array $form, array &$form_state) { } /** - * Overrides Drupal\Core\Entity\EntityForm::submit(). + * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $admin = $form_state['values']['administer_users']; if (!\Drupal::config('user.settings')->get('verify_mail') || $admin) { @@ -87,11 +87,11 @@ public function submit(array $form, array &$form_state) { $form_state['values']['pass'] = $pass; $form_state['values']['init'] = $form_state['values']['mail']; - parent::submit($form, $form_state); + parent::submitForm($form, $form_state); } /** - * Overrides Drupal\Core\Entity\EntityForm::submit(). + * {@inheritdoc} */ public function save(array $form, array &$form_state) { $account = $this->entity; 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 52501ef..2a59346 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 @@ -109,7 +109,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { $this->tempStore->delete($this->entity->id()); $form_state['redirect_route'] = $this->entity->urlInfo('edit-form'); drupal_set_message($this->t('The lock has been broken and you may now edit this view.')); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddForm.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddForm.php index fac46e3..d36e071 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddForm.php @@ -148,7 +148,8 @@ public function form(array $form, array &$form_state) { protected function actions(array $form, array &$form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = $this->t('Save and edit'); - + // Remove EntityFormController::save() form the submission handlers. + $actions['submit']['#submit'] = array(array($this, 'submitForm')); $actions['cancel'] = array( '#type' => 'submit', '#value' => $this->t('Cancel'), @@ -180,11 +181,11 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { try { /** @var $wizard \Drupal\views\Plugin\views\wizard\WizardInterface */ $wizard = $form_state['wizard_instance']; - $view = $wizard->createView($form, $form_state); + $this->entity = $wizard->createView($form, $form_state); } // @todo Figure out whether it really makes sense to throw and catch exceptions on the wizard. catch (WizardException $e) { @@ -192,9 +193,9 @@ public function submit(array $form, array &$form_state) { $form_state['redirect_route']['route_name'] = 'views_ui.list'; return; } - $view->save(); + $this->entity->save(); - $form_state['redirect_route'] = $view->urlInfo('edit-form'); + $form_state['redirect_route'] = $this->entity->urlInfo('edit-form'); } /** diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneForm.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneForm.php index 2ec467c..1048228 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneForm.php @@ -57,24 +57,28 @@ protected function actions(array $form, array &$form_state) { '#type' => 'submit', '#value' => $this->t('Clone'), '#submit' => array( - array($this, 'submit'), + array($this, 'submitForm'), + array($this, 'cloneView'), ), ); return $actions; } /** - * {@inheritdoc} + * Form submission handler for the 'clone' action. + * + * @param array $form + * An associative array containing the structure of the form. + * @param array $form_state + * A reference to a keyed array containing the current state of the form. */ - public function submit(array $form, array &$form_state) { - $original = parent::submit($form, $form_state); - $this->entity = $original->createDuplicate(); + public function cloneView(array $form, array &$form_state) { + $this->entity = $this->entity->createDuplicate(); $this->entity->set('id', $form_state['values']['id']); $this->entity->save(); // Redirect the user to the view admin form. $form_state['redirect_route'] = $this->entity->urlInfo('edit-form'); - return $this->entity; } } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewDeleteForm.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewDeleteForm.php index 6402190..5dd8163 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewDeleteForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewDeleteForm.php @@ -40,9 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); - + public function submitForm(array &$form, array &$form_state) { $this->entity->delete(); $form_state['redirect_route']['route_name'] = 'views_ui.list'; drupal_set_message($this->t('View %name deleted',array('%name' => $this->entity->label()))); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditForm.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditForm.php index 39e82d1..113035e 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditForm.php @@ -256,9 +256,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { - parent::submit($form, $form_state); - + public function save(array $form, array &$form_state) { $view = $this->entity; $executable = $view->getExecutable();