diff --git a/core/lib/Drupal/Core/Form/FormAlterInterface.php b/core/lib/Drupal/Core/Form/FormAlterInterface.php index 34a2ab6..9a3565e 100644 --- a/core/lib/Drupal/Core/Form/FormAlterInterface.php +++ b/core/lib/Drupal/Core/Form/FormAlterInterface.php @@ -14,8 +14,6 @@ * function mymodule_FORMID_alter(&$form, FormStateInterface $form_state) { * $alter = \Drupal::resolve('CLASSNAME'); * $alter->alter($form, $form_state); - * $form['#validate'][] = array($alter, 'validateForm'); - * $form['#submit'][] = array($alter, 'submitForm'); * } * @endcode */ @@ -30,24 +28,4 @@ * The current state of the form. */ public function alter(array &$form, FormStateInterface $form_state); - - /** - * Validation handler for the form alter. - * - * @param array $form - * The form array. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * The current state of the form. - */ - public function validate(array &$form, FormStateInterface $form_state); - - /** - * Submit handler for the form alter. - * - * @param array $form - * The form array. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * The current state of the form. - */ - public function submit(array &$form, FormStateInterface $form_state); } diff --git a/core/lib/Drupal/Core/Form/FormAlterSubmitInterface.php b/core/lib/Drupal/Core/Form/FormAlterSubmitInterface.php new file mode 100644 index 0000000..6438ab9 --- /dev/null +++ b/core/lib/Drupal/Core/Form/FormAlterSubmitInterface.php @@ -0,0 +1,27 @@ +alter($form, $form_state); - $form['actions']['submit']['#submit'][] = array($alter, 'submit'); } /** @@ -164,6 +163,4 @@ function contact_form_user_admin_settings_alter(&$form, FormStateInterface $form /** @var \Drupal\contact\Form\UserAccountSettingsFormAlter $alter */ $alter = \Drupal::resolve('Drupal\contact\Form\UserAccountSettingsFormAlter'); $alter->alter($form, $form_state); - // Add submit handler to save contact configuration. - $form['#submit'][] = array($alter, 'submit'); } diff --git a/core/modules/contact/src/Form/UserAccountSettingsFormAlter.php b/core/modules/contact/src/Form/UserAccountSettingsFormAlter.php index ba00e0f..4cbcb07 100644 --- a/core/modules/contact/src/Form/UserAccountSettingsFormAlter.php +++ b/core/modules/contact/src/Form/UserAccountSettingsFormAlter.php @@ -10,8 +10,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\DependencyInjection\DependencySerializationTrait; -use Drupal\Core\Form\ConfigFormBaseTrait; -use Drupal\Core\Form\FormAlterInterface; +use Drupal\Core\Form\FormAlterSubmitInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -21,7 +20,7 @@ * * @see \Drupal\user\AccountSettingsForm */ -class UserAccountSettingsFormAlter implements FormAlterInterface, ContainerInjectionInterface { +class UserAccountSettingsFormAlter implements FormAlterSubmitInterface, ContainerInjectionInterface { use DependencySerializationTrait; use StringTranslationTrait; @@ -59,13 +58,8 @@ public function alter(array &$form, FormStateInterface $form_state) { // @see \Drupal\Core\Form\ConfigFormBase::config() '#default_value' => $this->configFactory->get('contact.settings')->getOriginal('user_default_enabled', FALSE), ); - } - - /** - * {@inheritdoc} - */ - public function validate(array &$form, FormStateInterface $form_state) { - // No validations to perform. + // Add submit handler to save contact configuration. + $form['#submit'][] = array($this, 'submit'); } /** diff --git a/core/modules/contact/src/Form/UserFormAlter.php b/core/modules/contact/src/Form/UserFormAlter.php index bbb9a71..d43c895 100644 --- a/core/modules/contact/src/Form/UserFormAlter.php +++ b/core/modules/contact/src/Form/UserFormAlter.php @@ -10,7 +10,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\DependencyInjection\DependencySerializationTrait; -use Drupal\Core\Form\FormAlterInterface; +use Drupal\Core\Form\FormAlterSubmitInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -22,7 +22,7 @@ * * @see \Drupal\user\ProfileForm */ -class UserFormAlter implements FormAlterInterface, ContainerInjectionInterface { +class UserFormAlter implements FormAlterSubmitInterface, ContainerInjectionInterface { use DependencySerializationTrait; use StringTranslationTrait; @@ -71,13 +71,7 @@ public function alter(array &$form, FormStateInterface $form_state) { '#default_value' => isset($account_data) ? $account_data : $this->configFactory->get('contact.settings')->get('user_default_enabled'), '#description' => $this->t('Allow other users to contact you via a personal contact form which keeps your email address hidden. Note that some privileged users such as site administrators are still able to contact you even if you choose to disable this feature.'), ); - } - - /** - * {@inheritdoc} - */ - public function validate(array &$form, FormStateInterface $form_state) { - // No validations to perform. + $form['actions']['submit']['#submit'][] = array($this, 'submit'); } /** diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module index 3dccaff..07d4fe9 100644 --- a/core/modules/dblog/dblog.module +++ b/core/modules/dblog/dblog.module @@ -97,5 +97,4 @@ function dblog_form_system_logging_settings_alter(&$form, FormStateInterface $fo /** @var \Drupal\dblog\Form\SystemLoggingSettingsFormAlter $alter */ $alter = \Drupal::resolve('Drupal\dblog\Form\SystemLoggingSettingsFormAlter'); $alter->alter($form, $form_state); - $form['#submit'][] = array($alter, 'submit'); } diff --git a/core/modules/dblog/src/Form/SystemLoggingSettingsFormAlter.php b/core/modules/dblog/src/Form/SystemLoggingSettingsFormAlter.php index ec34c51..520e314 100644 --- a/core/modules/dblog/src/Form/SystemLoggingSettingsFormAlter.php +++ b/core/modules/dblog/src/Form/SystemLoggingSettingsFormAlter.php @@ -10,8 +10,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\DependencyInjection\DependencySerializationTrait; -use Drupal\Core\Form\ConfigFormBaseTrait; -use Drupal\Core\Form\FormAlterInterface; +use Drupal\Core\Form\FormAlterSubmitInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\UrlGeneratorTrait; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -22,7 +21,7 @@ * * @see \Drupal\system\Form\LoggingForm */ -class SystemLoggingSettingsFormAlter implements FormAlterInterface, ContainerInjectionInterface { +class SystemLoggingSettingsFormAlter implements FormAlterSubmitInterface, ContainerInjectionInterface { use DependencySerializationTrait; use StringTranslationTrait; use UrlGeneratorTrait; @@ -61,13 +60,7 @@ public function alter(array &$form, FormStateInterface $form_state) { '#options' => array(0 => $this->t('All')) + array_combine($row_limits, $row_limits), '#description' => $this->t('The maximum number of messages to keep in the database log. Requires a cron maintenance task.', array('@cron' => $this->url('system.status'))) ); - } - - /** - * {@inheritdoc} - */ - public function validate(array &$form, FormStateInterface $form_state) { - // No validations to perform. + $form['#submit'][] = array($this, 'submit'); } /** diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 6f1dc88..adfb167 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -841,7 +841,6 @@ function node_form_system_themes_admin_form_alter(&$form, FormStateInterface $fo /** @var \Drupal\node\Form\SystemThemesAdminFormAlter $alter */ $alter = \Drupal::resolve('Drupal\node\Form\SystemThemesAdminFormAlter'); $alter->alter($form, $form_state); - $form['#submit'][] = array($alter, 'submit'); } /** diff --git a/core/modules/node/src/Form/SystemThemesAdminFormAlter.php b/core/modules/node/src/Form/SystemThemesAdminFormAlter.php index 6609074..030176c 100644 --- a/core/modules/node/src/Form/SystemThemesAdminFormAlter.php +++ b/core/modules/node/src/Form/SystemThemesAdminFormAlter.php @@ -10,8 +10,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\DependencyInjection\DependencySerializationTrait; -use Drupal\Core\Form\ConfigFormBaseTrait; -use Drupal\Core\Form\FormAlterInterface; +use Drupal\Core\Form\FormAlterSubmitInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteBuilderIndicatorInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -22,7 +21,7 @@ * * @see \Drupal\system\Form\ThemeAdminForm */ -class SystemThemesAdminFormAlter implements FormAlterInterface, ContainerInjectionInterface { +class SystemThemesAdminFormAlter implements FormAlterSubmitInterface, ContainerInjectionInterface { use DependencySerializationTrait; use StringTranslationTrait; @@ -72,13 +71,7 @@ public function alter(array &$form, FormStateInterface $form_state) { '#title' => $this->t('Use the administration theme when editing or creating content'), '#default_value' => $this->configFactory->get('node.settings')->getOriginal('use_admin_theme', FALSE), ); - } - - /** - * {@inheritdoc} - */ - public function validate(array &$form, FormStateInterface $form_state) { - // No validations to perform. + $form['#submit'][] = array($this, 'submit'); } /** diff --git a/core/modules/syslog/src/Form/SystemLoggingSettingsFormAlter.php b/core/modules/syslog/src/Form/SystemLoggingSettingsFormAlter.php index 8835e46..5a8ea5b 100644 --- a/core/modules/syslog/src/Form/SystemLoggingSettingsFormAlter.php +++ b/core/modules/syslog/src/Form/SystemLoggingSettingsFormAlter.php @@ -11,8 +11,7 @@ use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Form\ConfigFormBaseTrait; -use Drupal\Core\Form\FormAlterInterface; +use Drupal\Core\Form\FormAlterSubmitInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\LinkGeneratorTrait; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -24,7 +23,7 @@ * * @see \Drupal\system\Form\LoggingForm */ -class SystemLoggingSettingsFormAlter implements FormAlterInterface, ContainerInjectionInterface { +class SystemLoggingSettingsFormAlter implements FormAlterSubmitInterface, ContainerInjectionInterface { use DependencySerializationTrait; use StringTranslationTrait; use LinkGeneratorTrait; @@ -97,6 +96,7 @@ public function alter(array &$form, FormStateInterface $form_state) { '#default_value' => $config->get('format'), '#description' => $this->t('Specify the format of the syslog entry. Available variables are:
!base_url
Base URL of the site.
!timestamp
Unix timestamp of the log entry.
!type
The category to which this message belongs.
!ip
IP address of the user triggering the message.
!request_uri
The requested URI.
!referer
HTTP Referer if available.
!uid
User ID.
!link
A link to associate with the message.
!message
The message to store in the log.
'), ); + $form['#submit'][] = array($this, 'submit'); } /** @@ -121,13 +121,6 @@ protected function facilityList() { /** * {@inheritdoc} */ - public function validate(array &$form, FormStateInterface $form_state) { - // No validations to perform. - } - - /** - * {@inheritdoc} - */ public function submit(array &$form, FormStateInterface $form_state) { $this->configFactory->get('syslog.settings') ->set('identity', $form_state->getValue('syslog_identity')) diff --git a/core/modules/syslog/syslog.module b/core/modules/syslog/syslog.module index ad3ed1b..d89ed06 100644 --- a/core/modules/syslog/syslog.module +++ b/core/modules/syslog/syslog.module @@ -35,5 +35,4 @@ function syslog_form_system_logging_settings_alter(&$form, FormStateInterface $f /** @var \Drupal\syslog\Form\SystemLoggingSettingsFormAlter $alter */ $alter = \Drupal::resolve('Drupal\syslog\Form\SystemLoggingSettingsFormAlter'); $alter->alter($form, $form_state); - $form['#submit'][] = array($alter, 'submit'); }