diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index 7ab2059fc874e72b16a089326e49a74eddaef622..d779bd95c7d45ade465267715255209640a79ad1 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -5,6 +5,8 @@ * Functions for use with Drupal's Ajax framework. */ +use Drupal\Core\Form\FormStateInterface; + /** * @defgroup ajax Ajax framework * @{ @@ -64,7 +66,7 @@ * return \Drupal::formBuilder()->getForm('ajax_example_simplest'); * } * - * function ajax_example_simplest($form, &$form_state) { + * function ajax_example_simplest($form, FormStateInterface $form_state) { * $form = array(); * $form['changethis'] = array( * '#type' => 'select', @@ -236,7 +238,7 @@ * * @see ajax_pre_render_element() */ -function ajax_process_form($element, &$form_state) { +function ajax_process_form($element, FormStateInterface $form_state) { $element = ajax_pre_render_element($element); if (!empty($element['#ajax_processed'])) { $form_state['cache'] = TRUE; diff --git a/core/includes/batch.inc b/core/includes/batch.inc index 02089bbdf9e8914f9baac64a9ac0535b91144d3e..81f0654dc6b4a9878f75ca648a43d64d7bb3d39a 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -17,6 +17,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Timer; use Drupal\Core\Batch\Percentage; +use Drupal\Core\Form\FormState; use Drupal\Core\Page\DefaultHtmlPageRenderer; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -442,6 +443,9 @@ function _batch_finished() { } // Determine the target path to redirect to. + if (!isset($_batch['form_state'])) { + $_batch['form_state'] = new FormState(); + } if (!isset($_batch['form_state']['redirect'])) { if (isset($_batch['redirect'])) { $_batch['form_state']['redirect'] = $_batch['redirect']; diff --git a/core/includes/form.inc b/core/includes/form.inc index 7d3107f13a43f2ea6bf9684eabd7e867029c1893..7131a7bba5cc0cb12834b3ca0ff839b0ba296889 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -12,6 +12,7 @@ use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\Xss; use Drupal\Core\Database\Database; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\OptGroup; use Drupal\Core\Render\Element; use Drupal\Core\Template\Attribute; @@ -26,7 +27,7 @@ * * @see \Drupal\Core\Form\FormBuilderInterface::getCache(). */ -function form_get_cache($form_build_id, &$form_state) { +function form_get_cache($form_build_id, FormStateInterface $form_state) { return \Drupal::formBuilder()->getCache($form_build_id, $form_state); } @@ -73,7 +74,7 @@ function form_set_cache($form_build_id, $form, $form_state) { * * @see module_load_include() */ -function form_load_include(&$form_state, $type, $module, $name = NULL) { +function form_load_include(FormStateInterface $form_state, $type, $module, $name = NULL) { if (!isset($name)) { $name = $module; } @@ -99,7 +100,7 @@ function form_load_include(&$form_state, $type, $module, $name = NULL) { * * @see \Drupal\Core\Form\FormBuilderInterface::submitForm(). */ -function drupal_form_submit($form_arg, &$form_state) { +function drupal_form_submit($form_arg, FormStateInterface $form_state) { \Drupal::formBuilder()->submitForm($form_arg, $form_state); } @@ -111,7 +112,7 @@ function drupal_form_submit($form_arg, &$form_state) { * * @see \Drupal\Core\Form\FormBuilderInterface::retrieveForm(). */ -function drupal_retrieve_form($form_id, &$form_state) { +function drupal_retrieve_form($form_id, FormStateInterface $form_state) { return \Drupal::formBuilder()->retrieveForm($form_id, $form_state); } @@ -123,7 +124,7 @@ function drupal_retrieve_form($form_id, &$form_state) { * * @see \Drupal\Core\Form\FormBuilderInterface::processForm(). */ -function drupal_process_form($form_id, &$form, &$form_state) { +function drupal_process_form($form_id, &$form, FormStateInterface $form_state) { \Drupal::formBuilder()->processForm($form_id, $form, $form_state); } @@ -149,7 +150,7 @@ function drupal_redirect_form($form_state) { * @see \Drupal\Core\Form\FormSubmitterInterface::executeSubmitHandlers() * @see \Drupal\Core\Form\FormValidatorInterface::executeValidateHandlers() */ -function form_execute_handlers($type, &$form, &$form_state) { +function form_execute_handlers($type, &$form, FormStateInterface $form_state) { if ($type == 'submit') { \Drupal::service('form_submitter')->executeSubmitHandlers($form, $form_state); } @@ -166,7 +167,7 @@ function form_execute_handlers($type, &$form, &$form_state) { * * @see \Drupal\Core\Form\FormErrorInterface::setErrorByName(). */ -function form_set_error($name, array &$form_state, $message = '') { +function form_set_error($name, FormStateInterface $form_state, $message = '') { \Drupal::formBuilder()->setErrorByName($name, $form_state, $message); } @@ -178,7 +179,7 @@ function form_set_error($name, array &$form_state, $message = '') { * * @see \Drupal\Core\Form\FormErrorInterface::getErrors() */ -function form_get_errors(array &$form_state) { +function form_get_errors(FormStateInterface $form_state) { return \Drupal::formBuilder()->getErrors($form_state); } @@ -190,7 +191,7 @@ function form_get_errors(array &$form_state) { * * @see \Drupal\Core\Form\FormErrorInterface::getError(). */ -function form_get_error($element, array &$form_state) { +function form_get_error($element, FormStateInterface $form_state) { return \Drupal::formBuilder()->getError($element, $form_state); } @@ -202,7 +203,7 @@ function form_get_error($element, array &$form_state) { * * @see \Drupal\Core\Form\FormErrorInterface::setError(). */ -function form_error(&$element, array &$form_state, $message = '') { +function form_error(&$element, FormStateInterface $form_state, $message = '') { \Drupal::formBuilder()->setError($element, $form_state, $message); } @@ -214,7 +215,7 @@ function form_error(&$element, array &$form_state, $message = '') { * * @see \Drupal\Core\Form\FormBuilderInterface::doBuildForm(). */ -function form_builder($form_id, &$element, &$form_state) { +function form_builder($form_id, &$element, FormStateInterface $form_state) { return \Drupal::formBuilder()->doBuildForm($form_id, $element, $form_state); } @@ -233,10 +234,9 @@ function form_builder($form_id, &$element, &$form_state) { * - op * * @param $form_state - * A keyed array containing the current state of the form, including - * submitted form values; altered by reference. + * The current state of the form, including submitted form values. */ -function form_state_values_clean(&$form_state) { +function form_state_values_clean(FormStateInterface $form_state) { // Remove internal Form API values. unset($form_state['values']['form_id'], $form_state['values']['form_token'], $form_state['values']['form_build_id'], $form_state['values']['op']); @@ -282,7 +282,7 @@ function form_state_values_clean(&$form_state) { * The incoming input to populate the form element. If this is FALSE, * the element's default value should be returned. * @param $form_state - * A keyed array containing the current state of the form. + * The current state of the form. * * @return * The data that will appear in the $form_state['values'] collection @@ -619,7 +619,7 @@ function form_type_token_value($element, $input = FALSE) { * * @see \Drupal\Core\Form\FormBuilderInterface::setValue(). */ -function form_set_value($element, $value, &$form_state) { +function form_set_value($element, $value, FormStateInterface $form_state) { \Drupal::formBuilder()->setValue($element, $value, $form_state); } @@ -1255,12 +1255,12 @@ function form_process_checkboxes($element) { * An associative array containing the properties and children of the * form actions container. * @param $form_state - * The $form_state array for the form this element belongs to. + * The current state of the form for the form this element belongs to. * * @return * The processed element. */ -function form_process_actions($element, &$form_state) { +function form_process_actions($element, FormStateInterface $form_state) { $element['#attributes']['class'][] = 'form-actions'; return $element; } @@ -1318,14 +1318,14 @@ function form_pre_render_actions_dropbutton(array $element) { * An associative array containing the properties and children of the * generic input element. * @param $form_state - * The $form_state array for the form this element belongs to. + * The current state of the form for the form this element belongs to. * * @return * The processed element. * * @see form_validate_pattern() */ -function form_process_pattern($element, &$form_state) { +function form_process_pattern($element, FormStateInterface $form_state) { if (isset($element['#pattern']) && !isset($element['#attributes']['pattern'])) { $element['#attributes']['pattern'] = $element['#pattern']; $element['#element_validate'][] = 'form_validate_pattern'; @@ -1341,11 +1341,11 @@ function form_process_pattern($element, &$form_state) { * An associative array containing the properties and children of the * generic form element. * @param $form_state - * The $form_state array for the form this element belongs to. + * The current state of the form for the form this element belongs to. * * @see form_process_pattern() */ -function form_validate_pattern($element, &$form_state) { +function form_validate_pattern($element, FormStateInterface $form_state) { if ($element['#value'] !== '') { // The pattern must match the entire string and should have the same // behavior as the RegExp object in ECMA 262. @@ -1368,12 +1368,12 @@ function form_validate_pattern($element, &$form_state) { * An associative array containing the properties and children of the * container. * @param $form_state - * The $form_state array for the form this element belongs to. + * The current state of the form for the form this element belongs to. * * @return * The processed element. */ -function form_process_container($element, &$form_state) { +function form_process_container($element, FormStateInterface $form_state) { // Generate the ID of the element if it's not explicitly given. if (!isset($element['#id'])) { $element['#id'] = drupal_html_id(implode('-', $element['#parents']) . '-wrapper'); @@ -1568,7 +1568,7 @@ function form_process_tableselect($element) { * @param array $element * An associative array containing the properties and children of the * table element. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * * @return array @@ -1577,7 +1577,7 @@ function form_process_tableselect($element) { * @see form_process_tableselect() * @see theme_tableselect() */ -function form_process_table($element, &$form_state) { +function form_process_table($element, FormStateInterface $form_state) { if ($element['#tableselect']) { if ($element['#multiple']) { $value = is_array($element['#value']) ? $element['#value'] : array(); @@ -1694,10 +1694,10 @@ function form_process_table($element, &$form_state) { * @param array $element * An associative array containing the properties and children of the * table element. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ -function form_validate_table($element, &$form_state) { +function form_validate_table($element, FormStateInterface $form_state) { // Skip this validation if the button to submit the form does not require // selected table row data. if (empty($form_state['triggering_element']['#tableselect'])) { @@ -1745,7 +1745,7 @@ function form_validate_table($element, &$form_state) { * - #disabled: (optional) Should be set to TRUE in case an existing machine * name must not be changed after initial creation. */ -function form_process_machine_name($element, &$form_state) { +function form_process_machine_name($element, FormStateInterface $form_state) { // We need to pass the langcode to the client. $language = \Drupal::languageManager()->getCurrentLanguage(); @@ -1829,7 +1829,7 @@ function form_process_machine_name($element, &$form_state) { * * Note that #maxlength is validated by _form_validate() already. */ -function form_validate_machine_name(&$element, &$form_state) { +function form_validate_machine_name(&$element, FormStateInterface $form_state) { // Verify that the machine name not only consists of replacement tokens. if (preg_match('@^' . $element['#machine_name']['replace'] . '+$@', $element['#value'])) { form_error($element, $form_state, t('The machine-readable name must contain unique characters.')); @@ -1870,12 +1870,12 @@ function form_validate_machine_name(&$element, &$form_state) { * element. Note that $element must be taken by reference here, so processed * child elements are taken over into $form_state. * @param $form_state - * The $form_state array for the form this element belongs to. + * The current state of the form for the form this element belongs to. * * @return * The processed element. */ -function form_process_group(&$element, &$form_state) { +function form_process_group(&$element, FormStateInterface $form_state) { $parents = implode('][', $element['#parents']); // Each details element forms a new group. The #type 'vertical_tabs' basically @@ -1994,12 +1994,12 @@ function form_pre_render_group($element) { * An associative array containing the properties and children of the * details element. * @param $form_state - * The $form_state array for the form this vertical tab widget belongs to. + * The current state of the form for the form this vertical tab widget belongs to. * * @return * The processed element. */ -function form_process_vertical_tabs($element, &$form_state) { +function form_process_vertical_tabs($element, FormStateInterface $form_state) { // Inject a new details as child, so that form_process_details() processes // this details element like any other details. $element['group'] = array( @@ -2088,13 +2088,13 @@ function template_preprocess_vertical_tabs(&$variables) { * autocomplete JavaScript library. * - #autocomplete_route_parameters: The parameters to be used in conjunction * with the route name. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * The form element. */ -function form_process_autocomplete($element, &$form_state) { +function form_process_autocomplete($element, FormStateInterface $form_state) { $access = FALSE; if (!empty($element['#autocomplete_route_name'])) { $parameters = isset($element['#autocomplete_route_parameters']) ? $element['#autocomplete_route_parameters'] : array(); @@ -2254,7 +2254,7 @@ function form_pre_render_email($element) { * * Note that #maxlength and #required is validated by _form_validate() already. */ -function form_validate_email(&$element, &$form_state) { +function form_validate_email(&$element, FormStateInterface $form_state) { $value = trim($element['#value']); form_set_value($element, $value, $form_state); @@ -2325,7 +2325,7 @@ function form_pre_render_range($element) { * * Note that #required is validated by _form_validate() already. */ -function form_validate_number(&$element, &$form_state) { +function form_validate_number(&$element, FormStateInterface $form_state) { $value = $element['#value']; if ($value === '') { return; @@ -2433,7 +2433,7 @@ function form_pre_render_search($element) { * * Note that #maxlength and #required is validated by _form_validate() already. */ -function form_validate_url(&$element, &$form_state) { +function form_validate_url(&$element, FormStateInterface $form_state) { $value = trim($element['#value']); form_set_value($element, $value, $form_state); @@ -2445,7 +2445,7 @@ function form_validate_url(&$element, &$form_state) { /** * Form element validation handler for #type 'color'. */ -function form_validate_color(&$element, &$form_state) { +function form_validate_color(&$element, FormStateInterface $form_state) { $value = trim($element['#value']); // Default to black if no value is given. diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 214ce288d22e46cdced6b87cde2b5e5f8b93388e..121badc1a7a80419c0306d48783fc479ff14dfaa 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -7,6 +7,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Database\Install\TaskException; +use Drupal\Core\Form\FormState; use Drupal\Core\Installer\Exception\AlreadyInstalledException; use Drupal\Core\Installer\Exception\InstallerException; use Drupal\Core\Installer\Exception\NoProfilesException; @@ -157,7 +158,7 @@ function install_drupal($settings = array()) { * submission is for, and the values are used as the $form_state['values'] * array that is passed on to the form submission via drupal_form_submit()). * - * @see drupal_form_submit() + * @see \Drupal\Core\Form\FormBuilderInterface::submitForm() */ function install_state_defaults() { $defaults = array( @@ -804,12 +805,12 @@ function install_tasks_to_display($install_state) { function install_get_form($form_id, array &$install_state) { // Ensure the form will not redirect, since install_run_tasks() uses a custom // redirection logic. - $form_state = array( + $form_state = new FormState(array( 'build_info' => array( 'args' => array(&$install_state), ), 'no_redirect' => TRUE, - ); + )); $form_builder = \Drupal::formBuilder(); if ($install_state['interactive']) { $form = $form_builder->buildForm($form_id, $form_state); diff --git a/core/lib/Drupal/Core/Action/ConfigurableActionBase.php b/core/lib/Drupal/Core/Action/ConfigurableActionBase.php index c32695ba6ee5fd327206373f45c9d6027ae3ba8a..e0368807f0701521571c01547724e116359d8570 100644 --- a/core/lib/Drupal/Core/Action/ConfigurableActionBase.php +++ b/core/lib/Drupal/Core/Action/ConfigurableActionBase.php @@ -9,6 +9,7 @@ use Drupal\Component\Plugin\ConfigurablePluginInterface; use Drupal\Core\Action\ActionBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\PluginFormInterface; /** @@ -49,7 +50,7 @@ public function setConfiguration(array $configuration) { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { } /** diff --git a/core/lib/Drupal/Core/Condition/ConditionPluginBase.php b/core/lib/Drupal/Core/Condition/ConditionPluginBase.php index 221e3b5f0e8c57be8bfe8dfae40219de923f860d..a745065354c83ff6d31397af0786e1a8794746c5 100644 --- a/core/lib/Drupal/Core/Condition/ConditionPluginBase.php +++ b/core/lib/Drupal/Core/Condition/ConditionPluginBase.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Condition; use Drupal\Core\Executable\ExecutablePluginBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides a basis for fulfilling contexts for condition plugins. @@ -39,7 +40,7 @@ public function isNegated() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['negate'] = array( '#type' => 'checkbox', '#title' => $this->t('Negate the condition.'), @@ -51,13 +52,13 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['negate'] = $form_state['values']['negate']; } diff --git a/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php b/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php index 3729f2de1b95b0a5955fad4ae7fc77454b67603e..ef021774a61d57bed1e7f2efa507b6471960471a 100644 --- a/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php +++ b/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormStateInterface; /** * Defines a class to build a draggable listing of configuration entities. @@ -102,7 +103,7 @@ public function render() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form[$this->entitiesKey] = array( '#type' => 'table', '#header' => $this->buildHeader(), @@ -138,14 +139,14 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // No validation. } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($form_state['values'][$this->entitiesKey] as $id => $value) { if (isset($this->entities[$id]) && $this->entities[$id]->get($this->weightKey) != $value['weight']) { // Save entity only when its weight was changed. diff --git a/core/lib/Drupal/Core/Controller/FormController.php b/core/lib/Drupal/Core/Controller/FormController.php index a8c44e5bacc1632914a36e7e5c304efffa4104e1..95e3eb5d78ff1a2725a469506e7aac508e748062 100644 --- a/core/lib/Drupal/Core/Controller/FormController.php +++ b/core/lib/Drupal/Core/Controller/FormController.php @@ -9,6 +9,7 @@ use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Form\FormBuilderInterface; +use Drupal\Core\Form\FormState; use Symfony\Component\HttpFoundation\Request; /** @@ -66,7 +67,7 @@ public function getContentResult(Request $request) { // Add the form and form_state to trick the getArguments method of the // controller resolver. - $form_state = array(); + $form_state = new FormState(); $request->attributes->set('form', array()); $request->attributes->set('form_state', $form_state); $args = $this->controllerResolver->getArguments($request, array($form_object, 'buildForm')); diff --git a/core/lib/Drupal/Core/Display/VariantBase.php b/core/lib/Drupal/Core/Display/VariantBase.php index ef7346d8872dc1aa4bb711c728b05cd833d75114..b39d9b36c7734fb95b7102ca55cafb3a3ad581f7 100644 --- a/core/lib/Drupal/Core/Display/VariantBase.php +++ b/core/lib/Drupal/Core/Display/VariantBase.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Display; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Plugin\PluginDependencyTrait; use Drupal\Core\Session\AccountInterface; @@ -100,7 +101,7 @@ public function calculateDependencies() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['label'] = array( '#type' => 'textfield', '#title' => $this->t('Label'), @@ -114,13 +115,13 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['label'] = $form_state['values']['label']; } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php index 686cdae8324f892bf8c95afc2ab5b77185b6488c..fc5bd8ef48b9303cba0a1a146a96ba288444296f 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\ConfirmFormHelper; use Drupal\Core\Form\ConfirmFormInterface; +use Drupal\Core\Form\FormStateInterface; /** * Provides a generic base class for an entity-based confirmation form. @@ -53,7 +54,7 @@ public function getFormName() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $form['#title'] = $this->getQuestion(); @@ -72,7 +73,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { // Do not attach fields to the confirm form. return $form; } @@ -80,7 +81,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = $this->getConfirmText(); unset($actions['delete']); diff --git a/core/lib/Drupal/Core/Entity/ContentEntityForm.php b/core/lib/Drupal/Core/Entity/ContentEntityForm.php index 8722a9ce1139b030eafe3a3a7c9438cf11a19a44..d2fc4800e9cf265c800b1872cca64b4c17952f4c 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityForm.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityForm.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Entity; use Drupal\Core\Entity\Display\EntityFormDisplayInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\entity\Entity\EntityFormDisplay; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -47,7 +48,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $this->getFormDisplay($form_state)->buildForm($this->entity, $form, $form_state); return $form; @@ -56,7 +57,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { $this->updateFormLangcode($form_state); $entity = $this->buildEntity($form, $form_state); $this->getFormDisplay($form_state)->validateFormValues($entity, $form, $form_state); @@ -70,7 +71,7 @@ public function validate(array $form, array &$form_state) { /** * Initialize the form state and the entity before the first form build. */ - protected function init(array &$form_state) { + protected function init(FormStateInterface $form_state) { // Ensure we act on the translation object corresponding to the current form // language. $langcode = $this->getFormLangcode($form_state); @@ -85,7 +86,7 @@ protected function init(array &$form_state) { /** * {@inheritdoc} */ - public function getFormLangcode(array &$form_state) { + public function getFormLangcode(FormStateInterface $form_state) { if (empty($form_state['langcode'])) { // Imply a 'view' operation to ensure users edit entities in the same // language they are displayed. This allows to keep contextual editing @@ -98,14 +99,14 @@ public function getFormLangcode(array &$form_state) { /** * {@inheritdoc} */ - public function isDefaultFormLangcode(array $form_state) { + public function isDefaultFormLangcode(FormStateInterface $form_state) { return $this->getFormLangcode($form_state) == $this->entity->getUntranslated()->language()->id; } /** * {@inheritdoc} */ - protected function copyFormValuesToEntity(EntityInterface $entity, array $form, array &$form_state) { + protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) { // First, extract values from widgets. $extracted = $this->getFormDisplay($form_state)->extractFormValues($entity, $form, $form_state); @@ -122,14 +123,14 @@ protected function copyFormValuesToEntity(EntityInterface $entity, array $form, /** * {@inheritdoc} */ - public function getFormDisplay(array $form_state) { + public function getFormDisplay(FormStateInterface $form_state) { return isset($form_state['form_display']) ? $form_state['form_display'] : NULL; } /** * {@inheritdoc} */ - public function setFormDisplay(EntityFormDisplayInterface $form_display, array &$form_state) { + public function setFormDisplay(EntityFormDisplayInterface $form_display, FormStateInterface $form_state) { $form_state['form_display'] = $form_display; return $this; } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityFormInterface.php b/core/lib/Drupal/Core/Entity/ContentEntityFormInterface.php index c0063060984c5d62384ff5ab7d8b5a7b0b6ab47a..4d5cf4daec7c5011b5b60d437946f11e49a8600c 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityFormInterface.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityFormInterface.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Entity; use Drupal\Core\Entity\Display\EntityFormDisplayInterface; +use Drupal\Core\Form\FormStateInterface; /** * Defines a common interface for content entity form classes. @@ -17,13 +18,13 @@ interface ContentEntityFormInterface extends EntityFormInterface { /** * Returns the form display. * - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return \Drupal\Core\Entity\Display\EntityFormDisplayInterface. * The current form display. */ - public function getFormDisplay(array $form_state); + public function getFormDisplay(FormStateInterface $form_state); /** * Sets the form display. @@ -33,9 +34,9 @@ public function getFormDisplay(array $form_state); * * @param \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display * The form display that the current form operates with. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function setFormDisplay(EntityFormDisplayInterface $form_display, array &$form_state); + public function setFormDisplay(EntityFormDisplayInterface $form_display, FormStateInterface $form_state); } diff --git a/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php b/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php index 7d8e3b571ed414d21dd5d23b52b7c566dbf35690..4ecc887a2f39c0ac94001b7b7d116ea86ba94e03 100644 --- a/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php +++ b/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Entity\Display; use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Form\FormStateInterface; /** * Provides a common interface for entity form displays. @@ -93,10 +94,10 @@ interface EntityFormDisplayInterface extends EntityDisplayInterface { * $form_state['values']. If not specified, $form['#parents'] is set to an * empty array, which results in field values located at the top-level of * $form_state['values']. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. */ - public function buildForm(ContentEntityInterface $entity, array &$form, array &$form_state); + public function buildForm(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state); /** * Validates submitted widget values and sets the corresponding form errors. @@ -122,10 +123,10 @@ public function buildForm(ContentEntityInterface $entity, array &$form, array &$ * @param array $form * The form structure where field elements are attached to. This might be a * full form structure, or a sub-element of a larger form. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. */ - public function validateFormValues(ContentEntityInterface $entity, array &$form, array &$form_state); + public function validateFormValues(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state); /** * Extracts field values from the submitted widget values into the entity. @@ -138,7 +139,7 @@ public function validateFormValues(ContentEntityInterface $entity, array &$form, * @param array $form * The form structure where field elements are attached to. This might be a * full form structure, or a sub-element of a larger form. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. * * @return array @@ -147,6 +148,6 @@ public function validateFormValues(ContentEntityInterface $entity, array &$form, * any, do not correspond to widgets and should be extracted manually by * the caller if needed. */ - public function extractFormValues(ContentEntityInterface $entity, array &$form, array &$form_state); + public function extractFormValues(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state); } diff --git a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php index a86d646f2d270b362d9eaf61bf37d1ea4b0390a8..d01d4afdc35f6385c7867bc3e9ec30d7ad7096bf 100644 --- a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\ConfirmFormHelper; use Drupal\Core\Form\ConfirmFormInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\Request; /** @@ -56,7 +57,7 @@ public function getFormName() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $form['#title'] = $this->getQuestion(); @@ -75,7 +76,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = $this->getConfirmText(); unset($actions['delete']); diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php index dcb9aaeccde56b51240bf475736d4b6afd1f2dec..f929a95585801959c7a3f4d646e2041738d9f024 100644 --- a/core/lib/Drupal/Core/Entity/EntityForm.php +++ b/core/lib/Drupal/Core/Entity/EntityForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; /** @@ -87,7 +88,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // During the initial form build, add this controller to the form state and // allow for initial preparation before form building and processing. if (!isset($form_state['controller'])) { @@ -109,13 +110,13 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } /** * Initialize the form state and the entity before the first form build. */ - protected function init(array &$form_state) { + protected function init(FormStateInterface $form_state) { // Add the controller to the form state so it can be easily accessed by // module-provided form handlers there. $form_state['controller'] = $this; @@ -133,7 +134,7 @@ protected function init(array &$form_state) { * * @see \Drupal\Core\Entity\EntityForm::build() */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $entity = $this->entity; // Add a process callback. @@ -156,7 +157,7 @@ public function form(array $form, array &$form_state) { * * @see \Drupal\Core\Entity\EntityForm::form() */ - public function processForm($element, $form_state, $form) { + public function processForm($element, FormStateInterface $form_state, $form) { // If the form is cached, process callbacks may not have a valid reference // to the entity object, hence we must restore it. $this->entity = $form_state['controller']->getEntity(); @@ -167,7 +168,7 @@ public function processForm($element, $form_state, $form) { /** * Returns the action form element for the current entity form. */ - protected function actionsElement(array $form, array &$form_state) { + protected function actionsElement(array $form, FormStateInterface $form_state) { $element = $this->actions($form, $form_state); if (isset($element['delete'])) { @@ -204,7 +205,7 @@ protected function actionsElement(array $form, array &$form_state) { * @todo Consider introducing a 'preview' action here, since it is used by * many entity types. */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { // @todo Rename the action key from submit to save. $actions['submit'] = array( '#type' => 'submit', @@ -242,7 +243,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { $this->updateFormLangcode($form_state); // @todo Remove this. // Execute legacy global validation handlers. @@ -261,10 +262,10 @@ public function validate(array $form, array &$form_state) { * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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); @@ -276,24 +277,24 @@ public function submit(array $form, array &$form_state) { * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { // @todo Perform common save operations. } /** * {@inheritdoc} */ - public function getFormLangcode(array &$form_state) { + public function getFormLangcode(FormStateInterface $form_state) { return $this->entity->language()->id; } /** * {@inheritdoc} */ - public function isDefaultFormLangcode(array $form_state) { + public function isDefaultFormLangcode(FormStateInterface $form_state) { // The entity is not translatable, this is always the default language. return TRUE; } @@ -301,10 +302,10 @@ public function isDefaultFormLangcode(array $form_state) { /** * Updates the form language to reflect any change to the entity language. * - * @param array $form_state - * A reference to a keyed array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - protected function updateFormLangcode(array &$form_state) { + protected function updateFormLangcode(FormStateInterface $form_state) { // Update the form language as it might have changed. if (isset($form_state['values']['langcode']) && $this->isDefaultFormLangcode($form_state)) { $form_state['langcode'] = $form_state['values']['langcode']; @@ -314,7 +315,7 @@ protected function updateFormLangcode(array &$form_state) { /** * {@inheritdoc} */ - public function buildEntity(array $form, array &$form_state) { + public function buildEntity(array $form, FormStateInterface $form_state) { $entity = clone $this->entity; // If you submit a form, the form state comes from caching, which forces // the controller to be the one before caching. Ensure to have the @@ -344,10 +345,10 @@ public function buildEntity(array $form, array &$form_state) { * The entity the current form should operate upon. * @param array $form * A nested array of form elements comprising the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - protected function copyFormValuesToEntity(EntityInterface $entity, array $form, array &$form_state) { + protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) { // @todo: This relies on a method that only exists for config and content // entities, in a different way. Consider moving this logic to a config // entity specific implementation. @@ -381,10 +382,10 @@ protected function prepareEntity() {} * * @param string $hook * The hook variant name. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - protected function prepareInvokeAll($hook, array &$form_state) { + protected function prepareInvokeAll($hook, FormStateInterface $form_state) { $implementations = $this->moduleHandler->getImplementations($hook); foreach ($implementations as $module) { $function = $module . '_' . $hook; diff --git a/core/lib/Drupal/Core/Entity/EntityFormBuilder.php b/core/lib/Drupal/Core/Entity/EntityFormBuilder.php index c875754a7e9a17a40aa71feb278063088feeac69..3a825be7b1ab7f2c09d49dc895d1508cf4617bb6 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityFormBuilder.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Entity; use Drupal\Core\Form\FormBuilderInterface; +use Drupal\Core\Form\FormState; /** * Builds entity forms. @@ -44,10 +45,11 @@ public function __construct(EntityManagerInterface $entity_manager, FormBuilderI /** * {@inheritdoc} */ - public function getForm(EntityInterface $entity, $operation = 'default', array $form_state = array()) { + public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = array()) { $form_object = $this->entityManager->getFormObject($entity->getEntityTypeId(), $operation); $form_object->setEntity($entity); + $form_state = new FormState($form_state_additions); $form_state['build_info']['callback_object'] = $form_object; $form_state['build_info']['base_form_id'] = $form_object->getBaseFormID(); $form_state['build_info'] += array('args' => array()); diff --git a/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php b/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php index 888abdbcd270c7d63743778c3565395a11c9d8cd..584595fe3d2e9b3aa95ae58d25e44ae9fda19a26 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php @@ -24,9 +24,9 @@ interface EntityFormBuilderInterface { * _entity_form: node.book_outline * @endcode * where "book_outline" is the value of $operation. - * @param array $form_state - * (optional) An associative array containing the current state of the form. - * Use this to pass additional information to the form, such as the + * @param array $form_state_additions + * (optional) An associative array used to build the current state of the + * form. Use this to pass additional information to the form, such as the * langcode. Defaults to an empty array. * * @code @@ -37,6 +37,6 @@ interface EntityFormBuilderInterface { * @return array * The processed form for the given entity and operation. */ - public function getForm(EntityInterface $entity, $operation = 'default', array $form_state = array()); + public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = array()); } diff --git a/core/lib/Drupal/Core/Entity/EntityFormInterface.php b/core/lib/Drupal/Core/Entity/EntityFormInterface.php index f1aeaa808b5283fdae69cf672abb40a47a22f4c7..31f485acdfaf6bde979c6cf0aaf3d0974acd50ad 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityFormInterface.php @@ -9,6 +9,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\BaseFormIdInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\TranslationInterface; /** @@ -19,24 +20,24 @@ interface EntityFormInterface extends BaseFormIdInterface { /** * Returns the code identifying the active form language. * - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return string * The form language code. */ - public function getFormLangcode(array &$form_state); + public function getFormLangcode(FormStateInterface $form_state); /** * Checks whether the current form language matches the entity one. * - * @param array $form_state - * A keyed array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return boolean * Returns TRUE if the entity form language matches the entity one. */ - public function isDefaultFormLangcode(array $form_state); + public function isDefaultFormLangcode(FormStateInterface $form_state); /** * Sets the operation for this form. @@ -61,8 +62,8 @@ public function getOperation(); * * The form entity which has been used for populating form element defaults. * - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return \Drupal\Core\Entity\EntityInterface * The current form entity. @@ -96,23 +97,23 @@ public function setEntity(EntityInterface $entity); * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return \Drupal\Core\Entity\EntityInterface * An updated copy of the form's entity object. */ - public function buildEntity(array $form, array &$form_state); + public function buildEntity(array $form, FormStateInterface $form_state); /** * Validates the submitted form values of the entity form. * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function validate(array $form, array &$form_state); + public function validate(array $form, FormStateInterface $form_state); /** * Updates the form's entity by processing this submission's values. @@ -123,10 +124,10 @@ public function validate(array $form, array &$form_state); * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function submit(array $form, array &$form_state); + public function submit(array $form, FormStateInterface $form_state); /** * Sets the string translation service for this form. diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php index a22375e203d2a69cda2c818ab1cfe93327ce639a..715bbb7fbd7d5ec1ac461dbb7327de2f9f9422a4 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Field; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\Core\TypedData\Plugin\DataType\Map; use Drupal\Core\TypedData\TypedDataInterface; @@ -244,14 +245,14 @@ public function deleteRevision() { } /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { return array(); } /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { return array(); } diff --git a/core/lib/Drupal/Core/Field/FieldItemInterface.php b/core/lib/Drupal/Core/Field/FieldItemInterface.php index 25bad4eb14d722fc0ac14e9dd41dcd926fb43608..b3a92697ac2c6a9c71fe3a76f8e53b2de6dc0065 100644 --- a/core/lib/Drupal/Core/Field/FieldItemInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemInterface.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\ComplexDataInterface; /** @@ -333,7 +334,7 @@ public static function instanceSettingsFromConfigData(array $settings); * * @param array $form * The form where the settings form is being included in. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state of the (entire) configuration form. * @param bool $has_data * TRUE if the field already has data, FALSE if not. @@ -341,7 +342,7 @@ public static function instanceSettingsFromConfigData(array $settings); * @return * The form definition for the field settings. */ - public function settingsForm(array &$form, array &$form_state, $has_data); + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data); /** * Returns a form for the instance-level settings. @@ -351,12 +352,12 @@ public function settingsForm(array &$form, array &$form_state, $has_data); * * @param array $form * The form where the settings form is being included in. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state of the (entire) configuration form. * * @return array * The form definition for the field instance settings. */ - public function instanceSettingsForm(array $form, array &$form_state); + public function instanceSettingsForm(array $form, FormStateInterface $form_state); } diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index 0c6559c20775260fbe4f8b59d65cbd6937685a18..726572fdcd7181bf37ac2b0dc87a6485355296a2 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Session\AccountInterface; @@ -301,7 +302,7 @@ public function getConstraints() { /** * {@inheritdoc} */ - public function defaultValuesForm(array &$form, array &$form_state) { + public function defaultValuesForm(array &$form, FormStateInterface $form_state) { if (empty($this->getFieldDefinition()->default_value_function)) { // Place the input in a separate place in the submitted values tree. $widget = $this->defaultValueWidget($form_state); @@ -316,7 +317,7 @@ public function defaultValuesForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function defaultValuesFormValidate(array $element, array &$form, array &$form_state) { + public function defaultValuesFormValidate(array $element, array &$form, FormStateInterface $form_state) { // Extract the submitted value, and validate it. $widget = $this->defaultValueWidget($form_state); $widget->extractFormValues($this, $element, $form_state); @@ -331,7 +332,7 @@ public function defaultValuesFormValidate(array $element, array &$form, array &$ /** * {@inheritdoc} */ - public function defaultValuesFormSubmit(array $element, array &$form, array &$form_state) { + public function defaultValuesFormSubmit(array $element, array &$form, FormStateInterface $form_state) { // Extract the submitted value, and return it as an array. $widget = $this->defaultValueWidget($form_state); $widget->extractFormValues($this, $element, $form_state); @@ -348,13 +349,13 @@ public static function processDefaultValue($default_value, ContentEntityInterfac /** * Returns the widget object used in default value form. * - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state of the (entire) configuration form. * * @return \Drupal\Core\Field\WidgetInterface * A Widget object. */ - protected function defaultValueWidget(array &$form_state) { + protected function defaultValueWidget(FormStateInterface $form_state) { if (!isset($form_state['default_value_widget'])) { $entity = $this->getEntity(); diff --git a/core/lib/Drupal/Core/Field/FieldItemListInterface.php b/core/lib/Drupal/Core/Field/FieldItemListInterface.php index 0a1583b85aafcb0d3f66004126520208c429b201..ddfe26b78f646574717de291c84623789b595832 100644 --- a/core/lib/Drupal/Core/Field/FieldItemListInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemListInterface.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Field; use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Access\AccessibleInterface; use Drupal\Core\TypedData\ListInterface; @@ -188,13 +189,13 @@ public function view($display_options = array()); * * @param array $form * The form where the settings form is being included in. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state of the (entire) configuration form. * * @return array * The form definition for the field instance default value. */ - public function defaultValuesForm(array &$form, array &$form_state); + public function defaultValuesForm(array &$form, FormStateInterface $form_state); /** * Validates the submitted default value. @@ -206,10 +207,10 @@ public function defaultValuesForm(array &$form, array &$form_state); * The default value form element. * @param array $form * The form where the settings form is being included in. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state of the (entire) configuration form. */ - public function defaultValuesFormValidate(array $element, array &$form, array &$form_state); + public function defaultValuesFormValidate(array $element, array &$form, FormStateInterface $form_state); /** * Processes the submitted default value. @@ -221,13 +222,13 @@ public function defaultValuesFormValidate(array $element, array &$form, array &$ * The default value form element. * @param array $form * The form where the settings form is being included in. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state of the (entire) configuration form. * * @return array * The field instance default value. */ - public function defaultValuesFormSubmit(array $element, array &$form, array &$form_state); + public function defaultValuesFormSubmit(array $element, array &$form, FormStateInterface $form_state); /** * Processes the default value before being applied. diff --git a/core/lib/Drupal/Core/Field/FormatterBase.php b/core/lib/Drupal/Core/Field/FormatterBase.php index ed309a9175d5e27912e1a562849297231d2aa457..a3ad53ec3937ae2c7ab0479accd4b5df73e0b76b 100644 --- a/core/lib/Drupal/Core/Field/FormatterBase.php +++ b/core/lib/Drupal/Core/Field/FormatterBase.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Field; +use Drupal\Core\Form\FormStateInterface; + /** * Base class for 'Field formatter' plugin implementations. * @@ -106,7 +108,7 @@ public function view(FieldItemListInterface $items) { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { return array(); } diff --git a/core/lib/Drupal/Core/Field/FormatterInterface.php b/core/lib/Drupal/Core/Field/FormatterInterface.php index 9db98577ecee3ce5e225799ae59e4b1b54739023..8596e6b1c94f515f47be9f24d6eea3bcb94ca9e9 100644 --- a/core/lib/Drupal/Core/Field/FormatterInterface.php +++ b/core/lib/Drupal/Core/Field/FormatterInterface.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Field; +use Drupal\Core\Form\FormStateInterface; + /** * Interface definition for field formatter plugins. * @@ -23,13 +25,13 @@ interface FormatterInterface extends PluginSettingsInterface { * * @param array $form * The form where the settings form is being included in. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * The form elements for the formatter settings. */ - public function settingsForm(array $form, array &$form_state); + public function settingsForm(array $form, FormStateInterface $form_state); /** * Returns a short summary for the current formatter settings. diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php index 4a0436bba84254b3c9ca56a4ec6ad0683a46573d..0e43ac11d8724ddba17c7b270d89cd10f531b93c 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Field\Plugin\Field\FieldFormatter; +use Drupal\Core\Form\FormStateInterface; + /** * Plugin implementation of the 'number_decimal' formatter. * @@ -40,7 +42,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $elements = parent::settingsForm($form, $form_state); $elements['decimal_separator'] = array( diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php index cc360b9737332b05bf3535286b0fd3721052ba87..dc0fe82010e656e4c93e4d8ff87ae78e90b2a054 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; /** * Parent plugin for decimal and integer formatters. @@ -18,7 +19,7 @@ abstract class NumericFormatterBase extends FormatterBase { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $options = array( '' => t('- None -'), '.' => t('Decimal point'), diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php index fd20d22c690f31882aaba9c1674a2483e84c00c7..6819f79f7aadd6bfd700c5de1c7b283e112c2c6b 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\AllowedValuesInterface; use Drupal\Core\TypedData\DataDefinition; @@ -64,7 +65,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { $element['on_label'] = array( '#type' => 'textfield', '#title' => $this->t('"On" label'), diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php index 10d03b3aa6a04d7c0a620a4f9b1e8114df127cb0..3f371fbae98cb1151278be8a7676cd53294d122e 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\DataDefinition; /** @@ -63,7 +64,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { $element = array(); $settings = $this->getSettings(); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php index 41a703279212f3fbc509394b2bd3c329035f9dfa..28846bbd4508c447e7d75a3220c2fb53236d02bc 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Form\FormStateInterface; /** * Base class for numeric configurable field types. @@ -29,7 +30,7 @@ public static function defaultInstanceSettings() { /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { $element = array(); $settings = $this->getSettings(); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php index 711a9b2209eb4f40f78e6aaf70cd2edd28403ae0..3069af389bac464b02c87e661842386ba477475c 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'boolean_checkbox' widget. @@ -36,7 +37,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['display_label'] = array( '#type' => 'checkbox', '#title' => t('Use field label instead of the "On label" as label'), @@ -61,7 +62,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element['value'] = $element + array( '#type' => 'checkbox', '#default_value' => !empty($items[0]->value), diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php index 15bc2ccf2cee1cde768fa04215a2f406bd74257d..ce60ebc8a28a60977292addb7d2273a07ed64de2 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'email_default' widget. @@ -35,7 +36,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['placeholder'] = array( '#type' => 'textfield', '#title' => t('Placeholder'), @@ -65,7 +66,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element['value'] = $element + array( '#type' => 'email', '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php index fa31ce751da47f6ac2e7ae6d86829f2ccd2ebb47..0f5020c027b7211e436037508d325ed1d5b334eb 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\Validator\ConstraintViolationInterface; /** @@ -38,7 +39,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['placeholder'] = array( '#type' => 'textfield', '#title' => t('Placeholder'), @@ -68,7 +69,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $value = isset($items[$delta]->value) ? $items[$delta]->value : NULL; $field_settings = $this->getFieldSettings(); @@ -113,7 +114,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen /** * {@inheritdoc} */ - public function errorElement(array $element, ConstraintViolationInterface $error, array $form, array &$form_state) { + public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) { return $element['value']; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php index fae98b156bc63aef9bf8c3adf29e4a00d793fbd8..8658dd0c56185c9803fdc6bd957be025c07720d0 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'string_textarea' widget. @@ -36,7 +37,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['rows'] = array( '#type' => 'number', '#title' => t('Rows'), @@ -71,7 +72,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element['value'] = $element + array( '#type' => 'textarea', '#default_value' => $items[$delta]->value, diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringWidget.php index ed1d92880fc9bd26072d6917489c21347c4636c6..853e66111db83ab6e0be9b1eae67ed1049790d84 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'string' widget. @@ -36,7 +37,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['size'] = array( '#type' => 'number', '#title' => t('Size of textfield'), @@ -71,7 +72,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element['value'] = $element + array( '#type' => 'textfield', '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php index 39606c6cc90db34b85c0a5f11e7a127b93d0bf47..8be947c0eab235b0c913266fc0ae90e9a392c753 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'uri' widget. @@ -36,7 +37,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['size'] = array( '#type' => 'number', '#title' => $this->t('Size of URI field'), @@ -71,7 +72,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element['value'] = $element + array( '#type' => 'url', '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index 1fe49395b81d64110e0e457007f4761a719a745a..89f501c933e0ad55e719db65403ec6deba8a06a9 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\SortArray; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\ConstraintViolationListInterface; @@ -58,7 +59,7 @@ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInter /** * {@inheritdoc} */ - public function form(FieldItemListInterface $items, array &$form, array &$form_state, $get_delta = NULL) { + public function form(FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta = NULL) { $field_name = $this->fieldDefinition->getName(); $parents = $form['#parents']; @@ -140,7 +141,7 @@ public function form(FieldItemListInterface $items, array &$form, array &$form_s * - AHAH-'add more' button * - table display and drag-n-drop value reordering */ - protected function formMultipleElements(FieldItemListInterface $items, array &$form, array &$form_state) { + protected function formMultipleElements(FieldItemListInterface $items, array &$form, FormStateInterface $form_state) { $field_name = $this->fieldDefinition->getName(); $cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality(); $parents = $form['#parents']; @@ -238,7 +239,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f * This stores the final location of the field within the form structure so * that flagErrors() can assign validation errors to the right form element. */ - public static function afterBuild(array $element, array &$form_state) { + public static function afterBuild(array $element, FormStateInterface $form_state) { $parents = $element['#field_parents']; $field_name = $element['#field_name']; @@ -252,7 +253,7 @@ public static function afterBuild(array $element, array &$form_state) { /** * Submission handler for the "Add another item" button. */ - public static function addMoreSubmit(array $form, array &$form_state) { + public static function addMoreSubmit(array $form, FormStateInterface $form_state) { $button = $form_state['triggering_element']; // Go one level up in the form, to the widgets container. @@ -274,7 +275,7 @@ public static function addMoreSubmit(array $form, array &$form_state) { * This returns the new page content to replace the page content made obsolete * by the form submission. */ - public static function addMoreAjax(array $form, array $form_state) { + public static function addMoreAjax(array $form, FormStateInterface $form_state) { $button = $form_state['triggering_element']; // Go one level up in the form, to the widgets container. @@ -296,7 +297,7 @@ public static function addMoreAjax(array $form, array $form_state) { /** * Generates the form element for a single copy of the widget. */ - protected function formSingleElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + protected function formSingleElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $entity = $items->getEntity(); $element += array( @@ -327,7 +328,7 @@ protected function formSingleElement(FieldItemListInterface $items, $delta, arra /** * {@inheritdoc} */ - public function extractFormValues(FieldItemListInterface $items, array $form, array &$form_state) { + public function extractFormValues(FieldItemListInterface $items, array $form, FormStateInterface $form_state) { $field_name = $this->fieldDefinition->getName(); // Extract the values from $form_state['values']. @@ -372,7 +373,7 @@ public function extractFormValues(FieldItemListInterface $items, array $form, ar /** * {@inheritdoc} */ - public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, array &$form_state) { + public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) { $field_name = $this->fieldDefinition->getName(); $field_state = static::getWidgetState($form['#parents'], $field_name, $form_state); @@ -441,15 +442,15 @@ public function flagErrors(FieldItemListInterface $items, ConstraintViolationLis /** * {@inheritdoc} */ - public static function getWidgetState(array $parents, $field_name, array &$form_state) { - return NestedArray::getValue($form_state, static::getWidgetStateParents($parents, $field_name)); + public static function getWidgetState(array $parents, $field_name, FormStateInterface $form_state) { + return NestedArray::getValue($form_state['storage'], static::getWidgetStateParents($parents, $field_name)); } /** * {@inheritdoc} */ - public static function setWidgetState(array $parents, $field_name, array &$form_state, array $field_state) { - NestedArray::setValue($form_state, static::getWidgetStateParents($parents, $field_name), $field_state); + public static function setWidgetState(array $parents, $field_name, FormStateInterface $form_state, array $field_state) { + NestedArray::setValue($form_state['storage'], static::getWidgetStateParents($parents, $field_name), $field_state); } /** @@ -473,7 +474,7 @@ protected static function getWidgetStateParents(array $parents, $field_name) { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { return array(); } @@ -487,14 +488,14 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function errorElement(array $element, ConstraintViolationInterface $error, array $form, array &$form_state) { + public function errorElement(array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state) { return $element; } /** * {@inheritdoc} */ - public function massageFormValues(array $values, array $form, array &$form_state) { + public function massageFormValues(array $values, array $form, FormStateInterface $form_state) { return $values; } diff --git a/core/lib/Drupal/Core/Field/WidgetBaseInterface.php b/core/lib/Drupal/Core/Field/WidgetBaseInterface.php index 0d52c1c23bc5425f711656650d02bf0feeb143e3..db7e0e7074c27e0e650e3a8b528af4c57f7e64ec 100644 --- a/core/lib/Drupal/Core/Field/WidgetBaseInterface.php +++ b/core/lib/Drupal/Core/Field/WidgetBaseInterface.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\Validator\ConstraintViolationListInterface; /** @@ -32,15 +33,15 @@ interface WidgetBaseInterface extends PluginSettingsInterface { * @param array $form * An array representing the form that the editing element will be attached * to. - * @param array $form_state - * An array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param int $get_delta * Used to get only a specific delta value of a multiple value field. * * @return array * The form element array created for this field. */ - public function form(FieldItemListInterface $items, array &$form, array &$form_state, $get_delta = NULL); + public function form(FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta = NULL); /** * Extracts field values from submitted form values. @@ -51,10 +52,10 @@ public function form(FieldItemListInterface $items, array &$form, array &$form_s * @param array $form * The form structure where field elements are attached to. This might be a * full form structure, or a sub-element of a larger form. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. */ - public function extractFormValues(FieldItemListInterface $items, array $form, array &$form_state); + public function extractFormValues(FieldItemListInterface $items, array $form, FormStateInterface $form_state); /** * Reports field-level validation errors against actual form elements. @@ -66,10 +67,10 @@ public function extractFormValues(FieldItemListInterface $items, array $form, ar * @param array $form * The form structure where field elements are attached to. This might be a * full form structure, or a sub-element of a larger form. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. */ - public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, array &$form_state); + public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state); /** * Retrieves processing information about the widget from $form_state. @@ -80,7 +81,7 @@ public function flagErrors(FieldItemListInterface $items, ConstraintViolationLis * The array of #parents where the field lives in the form. * @param string $field_name * The field name. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. * * @return array @@ -89,7 +90,7 @@ public function flagErrors(FieldItemListInterface $items, ConstraintViolationLis * - array_parents: The location of the field's widgets within the $form * structure. This entry is populated at '#after_build' time. */ - public static function getWidgetState(array $parents, $field_name, array &$form_state); + public static function getWidgetState(array $parents, $field_name, FormStateInterface $form_state); /** * Stores processing information about the widget in $form_state. @@ -100,12 +101,12 @@ public static function getWidgetState(array $parents, $field_name, array &$form_ * The array of #parents where the widget lives in the form. * @param string $field_name * The field name. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. * @param array $field_state * The array of data to store. See getWidgetState() for the structure and * content of the array. */ - public static function setWidgetState(array $parents, $field_name, array &$form_state, array $field_state); + public static function setWidgetState(array $parents, $field_name, FormStateInterface $form_state, array $field_state); } diff --git a/core/lib/Drupal/Core/Field/WidgetInterface.php b/core/lib/Drupal/Core/Field/WidgetInterface.php index feb5d9aa01ec6ea8f0144bed4a8d46bed04523fd..90034a8213697caf80a5e598b97b4f0d9fee9530 100644 --- a/core/lib/Drupal/Core/Field/WidgetInterface.php +++ b/core/lib/Drupal/Core/Field/WidgetInterface.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\Validator\ConstraintViolationInterface; /** @@ -30,13 +31,13 @@ interface WidgetInterface extends WidgetBaseInterface { * * @param array $form * The form where the settings form is being included in. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * The form definition for the widget settings. */ - public function settingsForm(array $form, array &$form_state); + public function settingsForm(array $form, FormStateInterface $form_state); /** * Returns a short summary for the current widget settings. @@ -97,8 +98,8 @@ public function settingsSummary(); * @param array $form * The form structure where widgets are being attached to. This might be a * full form structure, or a sub-element of a larger form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * The form elements for a single widget for this field. @@ -106,7 +107,7 @@ public function settingsSummary(); * @see hook_field_widget_form_alter() * @see hook_field_widget_WIDGET_TYPE_form_alter() */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state); + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state); /** * Assigns a field-level validation error to the right widget sub-element. @@ -122,14 +123,14 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen * @param array $form * The form structure where field elements are attached to. This might be a * full form structure, or a sub-element of a larger form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array|bool * The element on which the error should be flagged, or FALSE to completely * ignore the violation (use with care!). */ - public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, array &$form_state); + public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state); /** * Massages the form values into the format expected for field values. @@ -144,12 +145,12 @@ public function errorElement(array $element, ConstraintViolationInterface $viola * @param array $form * The form structure where field elements are attached to. This might be a * full form structure, or a sub-element of a larger form. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. * * @return array * An array of field values, keyed by delta. */ - public function massageFormValues(array $values, array $form, array &$form_state); + public function massageFormValues(array $values, array $form, FormStateInterface $form_state); } diff --git a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php index 765d9555c75ab31ee1c42e2961362f877865d761..818f345a8669be418968ce0477737b233352577a 100644 --- a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php +++ b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php @@ -8,6 +8,7 @@ namespace Drupal\Core\FileTransfer\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; /** @@ -25,7 +26,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // If possible, we want to post this form securely via HTTPS. $form['#https'] = TRUE; @@ -138,7 +139,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // Only validate the form if we have collected all of the user input and are // ready to proceed with updating or installing. if ($form_state['triggering_element']['#name'] != 'process_updates') { @@ -168,7 +169,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { switch ($form_state['triggering_element']['#name']) { case 'process_updates': diff --git a/core/lib/Drupal/Core/Form/ConfigFormBase.php b/core/lib/Drupal/Core/Form/ConfigFormBase.php index 8ed7403074fcea0618293e4ecf731c26dc6c0f18..f58bc11b6e4497fe489d67c789316d36b0a1f4a0 100644 --- a/core/lib/Drupal/Core/Form/ConfigFormBase.php +++ b/core/lib/Drupal/Core/Form/ConfigFormBase.php @@ -36,9 +36,9 @@ public static function create(ContainerInterface $container) { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = array( '#type' => 'submit', @@ -53,9 +53,9 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The configuration options have been saved.')); } diff --git a/core/lib/Drupal/Core/Form/ConfirmFormBase.php b/core/lib/Drupal/Core/Form/ConfirmFormBase.php index d44ab47d7915ea7c49a8f687268f36753a0fb765..28966900e53674e928381e524c96ae2804cd4468 100644 --- a/core/lib/Drupal/Core/Form/ConfirmFormBase.php +++ b/core/lib/Drupal/Core/Form/ConfirmFormBase.php @@ -43,7 +43,7 @@ public function getFormName() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['#title'] = $this->getQuestion(); $form['#attributes']['class'][] = 'confirmation'; diff --git a/core/lib/Drupal/Core/Form/FormBase.php b/core/lib/Drupal/Core/Form/FormBase.php index b9f04c1a83345ee7c1fa820e5eef6066423ed0e1..e90dcf676c09ed225de870ccd5da6f04205a86cf 100644 --- a/core/lib/Drupal/Core/Form/FormBase.php +++ b/core/lib/Drupal/Core/Form/FormBase.php @@ -46,13 +46,6 @@ abstract class FormBase implements FormInterface, ContainerInjectionInterface { */ protected $configFactory; - /** - * The form error handler. - * - * @var \Drupal\Core\Form\FormErrorInterface - */ - protected $errorHandler; - /** * {@inheritdoc} */ @@ -63,7 +56,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // Validation is optional. } @@ -173,35 +166,24 @@ private function container() { return \Drupal::getContainer(); } - /** - * Returns the form error handler. - * - * @return \Drupal\Core\Form\FormErrorInterface - * The form error handler. - */ - protected function errorHandler() { - if (!$this->errorHandler) { - $this->errorHandler = \Drupal::service('form_builder'); - } - return $this->errorHandler; - } - /** * Files an error against a form element. * * @param string $name * The name of the form element. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param string $message * (optional) The error message to present to the user. * - * @see \Drupal\Core\Form\FormErrorInterface::setErrorByName() + * @deprecated Use \Drupal\Core\Form\FormStateInterface::setErrorByName(). + * + * @todo Remove in https://www.drupal.org/node/2308821. * * @return $this */ - protected function setFormError($name, array &$form_state, $message = '') { - $this->errorHandler()->setErrorByName($name, $form_state, $message); + protected function setFormError($name, FormStateInterface $form_state, $message = '') { + $form_state->setErrorByName($name, $message); return $this; } diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index c150c29dae0adfa8493bd6bd7a0896bc29339789..c92f2d643cd33cf3a1f5cd919b9348ef3055195e 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -136,7 +136,7 @@ public function __construct(FormValidatorInterface $form_validator, FormSubmitte /** * {@inheritdoc} */ - public function getFormId($form_arg, &$form_state) { + public function getFormId($form_arg, FormStateInterface &$form_state) { // If the $form_arg is the name of a class, instantiate it. Don't allow // arbitrary strings to be passed to the class resolver. if (is_string($form_arg) && class_exists($form_arg)) { @@ -148,9 +148,9 @@ public function getFormId($form_arg, &$form_state) { } // Add the $form_arg as the callback object and determine the form ID. - $form_state['build_info']['callback_object'] = $form_arg; + $form_state->addBuildInfo('callback_object', $form_arg); if ($form_arg instanceof BaseFormIdInterface) { - $form_state['build_info']['base_form_id'] = $form_arg->getBaseFormID(); + $form_state->addBuildInfo('base_form_id', $form_arg->getBaseFormID()); } return $form_arg->getFormId(); } @@ -159,12 +159,12 @@ public function getFormId($form_arg, &$form_state) { * {@inheritdoc} */ public function getForm($form_arg) { - $form_state = array(); + $form_state = new FormState(); $args = func_get_args(); // Remove $form_arg from the arguments. unset($args[0]); - $form_state['build_info']['args'] = array_values($args); + $form_state->addBuildInfo('args', array_values($args)); return $this->buildForm($form_arg, $form_state); } @@ -172,16 +172,13 @@ public function getForm($form_arg) { /** * {@inheritdoc} */ - public function buildForm($form_id, array &$form_state) { - // Ensure some defaults; if already set they will not be overridden. - $form_state += $this->getFormStateDefaults(); - + public function buildForm($form_id, FormStateInterface &$form_state) { // Ensure the form ID is prepared. $form_id = $this->getFormId($form_id, $form_state); if (!isset($form_state['input'])) { $request = $this->requestStack->getCurrentRequest(); - $form_state['input'] = $form_state['method'] == 'get' ? $request->query->all() : $request->request->all(); + $form_state->set('input', $form_state['method'] == 'get' ? $request->query->all() : $request->request->all()); } if (isset($_SESSION['batch_form_state'])) { @@ -210,19 +207,19 @@ public function buildForm($form_id, array &$form_state) { // keys need to be removed after retrieving and preparing the form, except // any that were already set prior to retrieving the form. if ($check_cache) { - $form_state_before_retrieval = $form_state; + $form_state_before_retrieval = clone $form_state; } $form = $this->retrieveForm($form_id, $form_state); $this->prepareForm($form_id, $form, $form_state); - // self::setCache() removes uncacheable $form_state keys defined in - // self::getUncacheableKeys() in order for multi-step forms to work + // self::setCache() removes uncacheable $form_state keys (see properties + // in \Drupal\Core\Form\FormState) in order for multi-step forms to work // properly. This means that form processing logic for single-step forms // using $form_state['cache'] may depend on data stored in those keys - // during self::retrieveForm()/self::prepareForm(), but form - // processing should not depend on whether the form is cached or not, so - // $form_state is adjusted to match what it would be after a + // during self::retrieveForm()/self::prepareForm(), but form processing + // should not depend on whether the form is cached or not, so $form_state + // is adjusted to match what it would be after a // self::setCache()/self::getCache() sequence. These exceptions are // allowed to survive here: // - always_process: Does not make sense in conjunction with form caching @@ -231,9 +228,9 @@ public function buildForm($form_id, array &$form_state) { // - temporary: Any assigned data is expected to survives within the same // page request. if ($check_cache) { - $uncacheable_keys = array_flip(array_diff($this->getUncacheableKeys(), array('always_process', 'temporary'))); - $form_state = array_diff_key($form_state, $uncacheable_keys); - $form_state += $form_state_before_retrieval; + $cache_form_state = $form_state->getCacheableArray(array('always_process', 'temporary')); + $form_state = $form_state_before_retrieval; + $form_state->setFormState($cache_form_state); } } @@ -270,36 +267,7 @@ public function buildForm($form_id, array &$form_state) { /** * {@inheritdoc} */ - public function getFormStateDefaults() { - return array( - 'rebuild' => FALSE, - 'rebuild_info' => array(), - 'redirect' => NULL, - // @todo 'args' is usually set, so no other default 'build_info' keys are - // appended via += $this->getFormStateDefaults(). - 'build_info' => array( - 'args' => array(), - 'files' => array(), - ), - 'temporary' => array(), - 'validation_complete' => FALSE, - 'submitted' => FALSE, - 'executed' => FALSE, - 'programmed' => FALSE, - 'programmed_bypass_access_check' => TRUE, - 'cache'=> FALSE, - 'method' => 'post', - 'groups' => array(), - 'buttons' => array(), - 'errors' => array(), - 'limit_validation_errors' => NULL, - ); - } - - /** - * {@inheritdoc} - */ - public function rebuildForm($form_id, &$form_state, $old_form = NULL) { + public function rebuildForm($form_id, FormStateInterface &$form_state, $old_form = NULL) { $form = $this->retrieveForm($form_id, $form_state); // If only parts of the form will be returned to the browser (e.g., Ajax or @@ -335,7 +303,7 @@ public function rebuildForm($form_id, &$form_state, $old_form = NULL) { // Clear out all group associations as these might be different when // re-rendering the form. - $form_state['groups'] = array(); + $form_state->set('groups', array()); // Return a fully built form that is ready for rendering. return $this->doBuildForm($form_id, $form, $form_state); @@ -344,13 +312,13 @@ public function rebuildForm($form_id, &$form_state, $old_form = NULL) { /** * {@inheritdoc} */ - public function getCache($form_build_id, &$form_state) { + public function getCache($form_build_id, FormStateInterface &$form_state) { if ($form = $this->keyValueExpirableFactory->get('form')->get($form_build_id)) { $user = $this->currentUser(); if ((isset($form['#cache_token']) && $this->csrfToken->validate($form['#cache_token'])) || (!isset($form['#cache_token']) && $user->isAnonymous())) { if ($stored_form_state = $this->keyValueExpirableFactory->get('form_state')->get($form_build_id)) { // Re-populate $form_state for subsequent rebuilds. - $form_state = $stored_form_state + $form_state; + $form_state->setFormState($stored_form_state); // If the original form is contained in include files, load the files. // @see form_load_include() @@ -380,7 +348,7 @@ public function getCache($form_build_id, &$form_state) { /** * {@inheritdoc} */ - public function setCache($form_build_id, $form, $form_state) { + public function setCache($form_build_id, $form, FormStateInterface $form_state) { // 6 hours cache life time for forms should be plenty. $expire = 21600; @@ -393,77 +361,42 @@ public function setCache($form_build_id, $form, $form_state) { } // Cache form state. - // Store the known list of safe strings for form re-use. // @todo Ensure we are not storing an excessively large string list in: // https://www.drupal.org/node/2295823 - $form_state['build_info']['safe_strings'] = SafeMarkup::getAll(); + $form_state->addBuildInfo('safe_strings', SafeMarkup::getAll()); - if ($data = array_diff_key($form_state, array_flip($this->getUncacheableKeys()))) { + if ($data = $form_state->getCacheableArray()) { $this->keyValueExpirableFactory->get('form_state')->setWithExpire($form_build_id, $data, $expire); } } - /** - * Returns an array of $form_state keys that shouldn't be cached. - */ - protected function getUncacheableKeys() { - return array( - // Public properties defined by form constructors and form handlers. - 'always_process', - 'must_validate', - 'rebuild', - 'rebuild_info', - 'redirect', - 'redirect_route', - 'no_redirect', - 'temporary', - // Internal properties defined by form processing. - 'buttons', - 'triggering_element', - 'complete_form', - 'groups', - 'input', - 'method', - 'submit_handlers', - 'validation_complete', - 'submitted', - 'executed', - 'validate_handlers', - 'values', - 'errors', - 'limit_validation_errors', - ); - } - /** * {@inheritdoc} */ - public function submitForm($form_arg, &$form_state) { + public function submitForm($form_arg, FormStateInterface &$form_state) { if (!isset($form_state['build_info']['args'])) { $args = func_get_args(); // Remove $form and $form_state from the arguments. unset($args[0], $args[1]); - $form_state['build_info']['args'] = array_values($args); + $form_state->addBuildInfo('args', array_values($args)); } - // Merge in default values. - $form_state += $this->getFormStateDefaults(); // Populate $form_state['input'] with the submitted values before retrieving // the form, to be consistent with what self::buildForm() does for // non-programmatic submissions (form builder functions may expect it to be // there). - $form_state['input'] = $form_state['values']; + $form_state->set('input', $form_state->get('values')); - $form_state['programmed'] = TRUE; + $form_state->set('programmed', TRUE); $form_id = $this->getFormId($form_arg, $form_state); $form = $this->retrieveForm($form_id, $form_state); // Programmed forms are always submitted. - $form_state['submitted'] = TRUE; + $form_state->set('submitted', TRUE); // Reset form validation. - $form_state['must_validate'] = TRUE; + $form_state->set('must_validate', TRUE); $this->clearErrors($form_state); $this->prepareForm($form_id, $form, $form_state); @@ -473,9 +406,9 @@ public function submitForm($form_arg, &$form_state) { /** * {@inheritdoc} */ - public function retrieveForm($form_id, &$form_state) { + public function retrieveForm($form_id, FormStateInterface &$form_state) { // Record the $form_id. - $form_state['build_info']['form_id'] = $form_id; + $form_state->addBuildInfo('form_id', $form_id); // We save two copies of the incoming arguments: one for modules to use // when mapping form ids to constructor functions, and another to pass to @@ -513,20 +446,22 @@ public function retrieveForm($form_id, &$form_state) { /** * {@inheritdoc} */ - public function processForm($form_id, &$form, &$form_state) { - $form_state['values'] = array(); + public function processForm($form_id, &$form, FormStateInterface &$form_state) { + $form_state->set('values', array()); // With GET, these forms are always submitted if requested. if ($form_state['method'] == 'get' && !empty($form_state['always_process'])) { - if (!isset($form_state['input']['form_build_id'])) { - $form_state['input']['form_build_id'] = $form['#build_id']; + $input = $form_state->get('input'); + if (!isset($input['form_build_id'])) { + $input['form_build_id'] = $form['#build_id']; } - if (!isset($form_state['input']['form_id'])) { - $form_state['input']['form_id'] = $form_id; + if (!isset($input['form_id'])) { + $input['form_id'] = $form_id; } - if (!isset($form_state['input']['form_token']) && isset($form['#token'])) { - $form_state['input']['form_token'] = $this->csrfToken->get($form['#token']); + if (!isset($input['form_token']) && isset($form['#token'])) { + $input['form_token'] = $this->csrfToken->get($form['#token']); } + $form_state->set('input', $input); } // self::doBuildForm() finishes building the form by calling element @@ -550,7 +485,7 @@ public function processForm($form_id, &$form, &$form_state) { // exactly one submit button in the form, and if so, automatically use it // as triggering_element. if ($form_state['programmed'] && !isset($form_state['triggering_element']) && count($form_state['buttons']) == 1) { - $form_state['triggering_element'] = reset($form_state['buttons']); + $form_state->set('triggering_element', reset($form_state['buttons'])); } $this->formValidator->validateForm($form_id, $form, $form_state); @@ -594,7 +529,7 @@ public function processForm($form_id, &$form, &$form_state) { // Form building functions (e.g., self::handleInputElement()) may use // $form_state['rebuild'] to determine if they are running in the // context of a rebuild, so ensure it is set. - $form_state['rebuild'] = TRUE; + $form_state->setRebuild(); $form = $this->rebuildForm($form_id, $form_state, $form); } } @@ -614,14 +549,14 @@ public function processForm($form_id, &$form, &$form_state) { /** * {@inheritdoc} */ - public function prepareForm($form_id, &$form, &$form_state) { + public function prepareForm($form_id, &$form, FormStateInterface &$form_state) { $user = $this->currentUser(); $form['#type'] = 'form'; - $form_state['programmed'] = isset($form_state['programmed']) ? $form_state['programmed'] : FALSE; + $form_state->set('programmed', isset($form_state['programmed']) ? $form_state['programmed'] : FALSE); // Fix the form method, if it is 'get' in $form_state, but not in $form. - if ($form_state['method'] == 'get' && !isset($form['#method'])) { + if ($form_state->get('method') == 'get' && !isset($form['#method'])) { $form['#method'] = 'get'; } @@ -718,56 +653,56 @@ public function prepareForm($form_id, &$form, &$form_state) { /** * {@inheritdoc} */ - public function validateForm($form_id, &$form, &$form_state) { + public function validateForm($form_id, &$form, FormStateInterface &$form_state) { $this->formValidator->validateForm($form_id, $form, $form_state); } /** * {@inheritdoc} */ - public function redirectForm($form_state) { + public function redirectForm(FormStateInterface $form_state) { return $this->formSubmitter->redirectForm($form_state); } /** * {@inheritdoc} */ - public function executeValidateHandlers(&$form, &$form_state) { + public function executeValidateHandlers(&$form, FormStateInterface &$form_state) { $this->formValidator->executeValidateHandlers($form, $form_state); } /** * {@inheritdoc} */ - public function executeSubmitHandlers(&$form, &$form_state) { + public function executeSubmitHandlers(&$form, FormStateInterface &$form_state) { $this->formSubmitter->executeSubmitHandlers($form, $form_state); } /** * {@inheritdoc} */ - public function doSubmitForm(&$form, &$form_state) { + public function doSubmitForm(&$form, FormStateInterface &$form_state) { throw new \LogicException('Use FormBuilderInterface::processForm() instead.'); } /** * {@inheritdoc} */ - public function setErrorByName($name, array &$form_state, $message = '') { + public function setErrorByName($name, FormStateInterface &$form_state, $message = '') { $this->formValidator->setErrorByName($name, $form_state, $message); } /** * {@inheritdoc} */ - public function clearErrors(array &$form_state) { + public function clearErrors(FormStateInterface &$form_state) { $this->formValidator->clearErrors($form_state); } /** * {@inheritdoc} */ - public function getErrors(array $form_state) { + public function getErrors(FormStateInterface &$form_state) { return $this->formValidator->getErrors($form_state); } @@ -781,21 +716,21 @@ public function getAnyErrors() { /** * {@inheritdoc} */ - public function getError($element, array &$form_state) { + public function getError($element, FormStateInterface &$form_state) { return $this->formValidator->getError($element, $form_state); } /** * {@inheritdoc} */ - public function setError(&$element, array &$form_state, $message = '') { + public function setError(&$element, FormStateInterface &$form_state, $message = '') { $this->formValidator->setError($element, $form_state, $message); } /** * {@inheritdoc} */ - public function doBuildForm($form_id, &$element, &$form_state) { + public function doBuildForm($form_id, &$element, FormStateInterface &$form_state) { // Initialize as unprocessed. $element['#processed'] = FALSE; @@ -826,16 +761,16 @@ public function doBuildForm($form_id, &$element, &$form_state) { // Store a reference to the complete form in $form_state prior to building // the form. This allows advanced #process and #after_build callbacks to // perform changes elsewhere in the form. - $form_state['complete_form'] = &$element; + $form_state->setCompleteForm($element); // Set a flag if we have a correct form submission. This is always TRUE // for programmed forms coming from self::submitForm(), or if the form_id // coming from the POST data is set and matches the current form_id. if ($form_state['programmed'] || (!empty($form_state['input']) && (isset($form_state['input']['form_id']) && ($form_state['input']['form_id'] == $form_id)))) { - $form_state['process_input'] = TRUE; + $form_state->set('process_input', TRUE); } else { - $form_state['process_input'] = FALSE; + $form_state->set('process_input', FALSE); } // All form elements should have an #array_parents property. @@ -931,7 +866,7 @@ public function doBuildForm($form_id, &$element, &$form_state) { // If there is a file element, we need to flip a flag so later the // form encoding can be set. if (isset($element['#type']) && $element['#type'] == 'file') { - $form_state['has_file_element'] = TRUE; + $form_state->set('has_file_element', TRUE); } // Final tasks for the form element after self::doBuildForm() has run for @@ -949,26 +884,27 @@ public function doBuildForm($form_id, &$element, &$form_state) { // consistent as we can be across browsers, if no 'triggering_element' has // been identified yet, default it to the first button. if (!$form_state['programmed'] && !isset($form_state['triggering_element']) && !empty($form_state['buttons'])) { - $form_state['triggering_element'] = $form_state['buttons'][0]; + $form_state->set('triggering_element', $form_state['buttons'][0]); } + $triggering_element = $form_state->get('triggering_element'); // If the triggering element specifies "button-level" validation and // submit handlers to run instead of the default form-level ones, then add // those to the form state. foreach (array('validate', 'submit') as $type) { - if (isset($form_state['triggering_element']['#' . $type])) { - $form_state[$type . '_handlers'] = $form_state['triggering_element']['#' . $type]; + if (isset($triggering_element['#' . $type])) { + $form_state->set($type . '_handlers', $triggering_element['#' . $type]); } } // If the triggering element executes submit handlers, then set the form // state key that's needed for those handlers to run. - if (!empty($form_state['triggering_element']['#executes_submit_callback'])) { - $form_state['submitted'] = TRUE; + if (!empty($triggering_element['#executes_submit_callback'])) { + $form_state->set('submitted', TRUE); } // Special processing if the triggering element is a button. - if (!empty($form_state['triggering_element']['#is_button'])) { + if (!empty($triggering_element['#is_button'])) { // Because there are several ways in which the triggering element could // have been determined (including from input variables set by // JavaScript or fallback behavior implemented for IE), and because @@ -978,7 +914,7 @@ public function doBuildForm($form_id, &$element, &$form_state) { // $form_state['values'][BUTTON_NAME] being set. But it's common for // forms to have several buttons named 'op' and switch on // $form_state['values']['op'] during submit handler execution. - $form_state['values'][$form_state['triggering_element']['#name']] = $form_state['triggering_element']['#value']; + $form_state->addValue($triggering_element['#name'], $triggering_element['#value']); } } return $element; @@ -987,7 +923,7 @@ public function doBuildForm($form_id, &$element, &$form_state) { /** * Adds the #name and #value properties of an input element before rendering. */ - protected function handleInputElement($form_id, &$element, &$form_state) { + protected function handleInputElement($form_id, &$element, FormStateInterface &$form_state) { if (!isset($element['#name'])) { $name = array_shift($element['#parents']); $element['#name'] = $name; @@ -1101,7 +1037,7 @@ protected function handleInputElement($form_id, &$element, &$form_state) { if ($process_input) { // Detect if the element triggered the submission via Ajax. if ($this->elementTriggeredScriptedSubmission($element, $form_state)) { - $form_state['triggering_element'] = $element; + $form_state->set('triggering_element', $element); } // If the form was submitted by the browser rather than via Ajax, then it @@ -1113,16 +1049,18 @@ protected function handleInputElement($form_id, &$element, &$form_state) { // form_state_values_clean() and for the self::doBuildForm() code that // handles a form submission containing no button information in // \Drupal::request()->request. - $form_state['buttons'][] = $element; + $buttons = $form_state->get('buttons'); + $buttons[] = $element; + $form_state->set('buttons', $buttons); if ($this->buttonWasClicked($element, $form_state)) { - $form_state['triggering_element'] = $element; + $form_state->set('triggering_element', $element); } } } // Set the element's value in $form_state['values'], but only, if its key // does not exist yet (a #value_callback may have already populated it). - if (!NestedArray::keyExists($form_state['values'], $element['#parents'])) { + if (!NestedArray::keyExists($form_state->getValues(), $element['#parents'])) { $this->setValue($element, $element['#value'], $form_state); } } @@ -1138,7 +1076,7 @@ protected function handleInputElement($form_id, &$element, &$form_state) { * element value. An example where this is needed is if there are several * // buttons all named 'op', and only differing in their value. */ - protected function elementTriggeredScriptedSubmission($element, &$form_state) { + protected function elementTriggeredScriptedSubmission($element, FormStateInterface &$form_state) { if (!empty($form_state['input']['_triggering_element_name']) && $element['#name'] == $form_state['input']['_triggering_element_name']) { if (empty($form_state['input']['_triggering_element_value']) || $form_state['input']['_triggering_element_value'] == $element['#value']) { return TRUE; @@ -1167,7 +1105,7 @@ protected function elementTriggeredScriptedSubmission($element, &$form_state) { * to know which button was clicked should get that information from * $form_state['triggering_element']. */ - protected function buttonWasClicked($element, &$form_state) { + protected function buttonWasClicked($element, FormStateInterface &$form_state) { // First detect normal 'vanilla' button clicks. Traditionally, all standard // buttons on a form share the same name (usually 'op'), and the specific // return value is used to determine which was clicked. This ONLY works as @@ -1190,8 +1128,10 @@ protected function buttonWasClicked($element, &$form_state) { /** * {@inheritdoc} */ - public function setValue($element, $value, &$form_state) { - NestedArray::setValue($form_state['values'], $element['#parents'], $value, TRUE); + public function setValue($element, $value, FormStateInterface &$form_state) { + $values = $form_state->getValues(); + NestedArray::setValue($values, $element['#parents'], $value, TRUE); + $form_state->set('values', $values); } /** diff --git a/core/lib/Drupal/Core/Form/FormBuilderInterface.php b/core/lib/Drupal/Core/Form/FormBuilderInterface.php index 6f42d14241af522d344ec07632a70c4bd490c760..bb4d953ab4e43f6522e03314a5fb1eceeaaea9c5 100644 --- a/core/lib/Drupal/Core/Form/FormBuilderInterface.php +++ b/core/lib/Drupal/Core/Form/FormBuilderInterface.php @@ -17,13 +17,13 @@ interface FormBuilderInterface extends FormErrorInterface { * * @param \Drupal\Core\Form\FormInterface|string $form_arg * The value is identical to that of self::getForm()'s $form_arg argument. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return string * The unique string identifying the desired form. */ - public function getFormId($form_arg, &$form_state); + public function getFormId($form_arg, FormStateInterface &$form_state); /** * Gets a renderable form array. @@ -58,164 +58,12 @@ public function getForm($form_arg); * previous page-load. The form is then passed on for processing, validation * and submission if there is proper input. * - * @param \Drupal\Core\Form\FormInterface|string $form_arg + * @param \Drupal\Core\Form\FormInterface|string $form_id * The value must be one of the following: * - The name of a class that implements \Drupal\Core\Form\FormInterface. * - An instance of a class that implements \Drupal\Core\Form\FormInterface. - * @param array $form_state - * An array which stores information about the form. This is passed as a - * reference so that the caller can use it to examine what in the form - * changed when the form submission process is complete. Furthermore, it may - * be used to store information related to the processed data in the form, - * which will persist across page requests when the 'cache' or 'rebuild' - * flag is set. The following parameters may be set in $form_state to affect - * how the form is rendered: - * - build_info: Internal. An associative array of information stored by - * Form API that is necessary to build and rebuild the form from cache - * when the original context may no longer be available: - * - callback: The actual callback to be used to retrieve the form array. - * Can be any callable. If none is provided $form_id is used as the name - * of a function to call instead. - * - args: A list of arguments to pass to the form constructor. - * - files: An optional array defining include files that need to be - * loaded for building the form. Each array entry may be the path to a - * file or another array containing values for the parameters 'type', - * 'module' and 'name' as needed by module_load_include(). The files - * listed here are automatically loaded by form_get_cache(). By default - * the current menu router item's 'file' definition is added, if any. - * Use form_load_include() to add include files from a form constructor. - * - form_id: Identification of the primary form being constructed and - * processed. - * - base_form_id: Identification for a base form, as declared in the form - * class's \Drupal\Core\Form\BaseFormIdInterface::getBaseFormId() method. - * - rebuild_info: Internal. Similar to 'build_info', but pertaining to - * self::rebuildForm(). - * - rebuild: Normally, after the entire form processing is completed and - * submit handlers have run, a form is considered to be done and - * self::redirectForm() will redirect the user to a new page using a GET - * request (so a browser refresh does not re-submit the form). However, if - * 'rebuild' has been set to TRUE, then a new copy of the form is - * immediately built and sent to the browser, instead of a redirect. This - * is used for multi-step forms, such as wizards and confirmation forms. - * Normally, $form_state['rebuild'] is set by a submit handler, since its - * is usually logic within a submit handler that determines whether a form - * is done or requires another step. However, a validation handler may - * already set $form_state['rebuild'] to cause the form processing to - * bypass submit handlers and rebuild the form instead, even if there are - * no validation errors. - * - response: Used when a form needs to return some kind of a - * \Symfony\Component\HttpFoundation\Response object, e.g., a - * \Symfony\Component\HttpFoundation\BinaryFileResponse when triggering a - * file download. If you use the $form_state['redirect'] key, it will be - * used to build a \Symfony\Component\HttpFoundation\RedirectResponse and - * will populate this key. - * - redirect: Used to redirect the form on submission. It may either be a - * string containing the destination URL, or an array of arguments - * compatible with url(). See url() for complete information. - * - no_redirect: If set to TRUE the form will NOT perform a redirect, - * even if 'redirect' is set. - * - method: The HTTP form method to use for finding the input for this - * form. May be 'post' or 'get'. Defaults to 'post'. Note that 'get' - * method forms do not use form ids so are always considered to be - * submitted, which can have unexpected effects. The 'get' method should - * only be used on forms that do not change data, as that is exclusively - * the domain of 'post.' - * - cache: If set to TRUE the original, unprocessed form structure will be - * cached, which allows the entire form to be rebuilt from cache. A - * typical form workflow involves two page requests; first, a form is - * built and rendered for the user to fill in. Then, the user fills the - * form in and submits it, triggering a second page request in which the - * form must be built and processed. By default, $form and $form_state are - * built from scratch during each of these page requests. Often, it is - * necessary or desired to persist the $form and $form_state variables - * from the initial page request to the one that processes the submission. - * 'cache' can be set to TRUE to do this. A prominent example is an - * Ajax-enabled form, in which ajax_process_form() enables form caching - * for all forms that include an element with the #ajax property. (The - * Ajax handler has no way to build the form itself, so must rely on the - * cached version.) Note that the persistence of $form and $form_state - * happens automatically for (multi-step) forms having the 'rebuild' flag - * set, regardless of the value for 'cache'. - * - no_cache: If set to TRUE the form will NOT be cached, even if 'cache' - * is set. - * - values: An associative array of values submitted to the form. The - * validation functions and submit functions use this array for nearly all - * their decision making. (Note that #tree determines whether the values - * are a flat array or an array whose structure parallels the $form array. - * See the @link forms_api_reference.html Form API reference @endlink for - * more information.) - * - input: The array of values as they were submitted by the user. These - * are raw and unvalidated, so should not be used without a thorough - * understanding of security implications. In almost all cases, code - * should use the data in the 'values' array exclusively. The most common - * use of this key is for multi-step forms that need to clear some of the - * user input when setting 'rebuild'. The values correspond to - * \Drupal::request()->request or \Drupal::request()->query, depending on - * the 'method' chosen. - * - always_process: If TRUE and the method is GET, a form_id is not - * necessary. This should only be used on RESTful GET forms that do NOT - * write data, as this could lead to security issues. It is useful so that - * searches do not need to have a form_id in their query arguments to - * trigger the search. - * - must_validate: Ordinarily, a form is only validated once, but there are - * times when a form is resubmitted internally and should be validated - * again. Setting this to TRUE will force that to happen. This is most - * likely to occur during Ajax operations. - * - programmed: If TRUE, the form was submitted programmatically, usually - * invoked via self::submitForm(). Defaults to FALSE. - * - programmed_bypass_access_check: If TRUE, programmatic form submissions - * are processed without taking #access into account. Set this to FALSE - * when submitting a form programmatically with values that may have been - * input by the user executing the current request; this will cause - * #access to be respected as it would on a normal form submission. - * Defaults to TRUE. - * - process_input: Boolean flag. TRUE signifies correct form submission. - * This is always TRUE for programmed forms coming from self::submitForm() - * (see 'programmed' key), or if the form_id coming from the - * \Drupal::request()->request data is set and matches the current form_id. - * - submitted: If TRUE, the form has been submitted. Defaults to FALSE. - * - executed: If TRUE, the form was submitted and has been processed and - * executed. Defaults to FALSE. - * - triggering_element: (read-only) The form element that triggered - * submission, which may or may not be a button (in the case of Ajax - * forms). This key is often used to distinguish between various buttons - * in a submit handler, and is also used in Ajax handlers. - * - has_file_element: Internal. If TRUE, there is a file element and Form - * API will set the appropriate 'enctype' HTML attribute on the form. - * - groups: Internal. An array containing references to details elements to - * render them within vertical tabs. - * - storage: $form_state['storage'] is not a special key, and no specific - * support is provided for it in the Form API. By tradition it was - * the location where application-specific data was stored for - * communication between the submit, validation, and form builder - * functions, especially in a multi-step-style form. Form implementations - * may use any key(s) within $form_state (other than the keys listed here - * and other reserved ones used by Form API internals) for this kind of - * storage. The recommended way to ensure that the chosen key doesn't - * conflict with ones used by the Form API or other modules is to use the - * module name as the key name or a prefix for the key name. For example, - * the entity form classes use $this->entity in entity forms, - * or $form_state['controller']->getEntity() outside the controller, to - * store information about the entity being edited, and this information - * stays available across successive clicks of the "Preview" button (if - * available) as well as when the "Save" button is finally clicked. - * - buttons: A list containing copies of all submit and button elements in - * the form. - * - complete_form: A reference to the $form variable containing the - * complete form structure. #process, #after_build, #element_validate, and - * other handlers being invoked on a form element may use this reference - * to access other information in the form the element is contained in. - * - temporary: An array holding temporary data accessible during the - * current page request only. All $form_state properties that are not - * reserved keys (see form_state_keys_no_cache()) persist throughout a - * multistep form sequence. Form API provides this key for modules to - * communicate information across form-related functions during a single - * page request. It may be used to temporarily save data that does not - * need to or should not be cached during the whole form workflow; e.g., - * data that needs to be accessed during the current form build process - * only. There is no use-case for this functionality in Drupal core. - * Information on how certain $form_state properties control redirection - * behavior after form submission may be found in self::redirectForm(). + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * The rendered form. This function may also perform a redirect and hence @@ -223,12 +71,7 @@ public function getForm($form_arg); * * @see self::redirectForm() */ - public function buildForm($form_id, array &$form_state); - - /** - * Retrieves default values for the $form_state array. - */ - public function getFormStateDefaults(); + public function buildForm($form_id, FormStateInterface &$form_state); /** * Constructs a new $form from the information in $form_state. @@ -249,8 +92,8 @@ public function getFormStateDefaults(); * @param string $form_id * The unique string identifying the desired form. If a function with that * name exists, it is called to build the form array. - * @param array $form_state - * A keyed array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param array|null $old_form * (optional) A previously built $form. Used to retain the #build_id and * #action properties in Ajax callbacks and similar partial form rebuilds. @@ -266,17 +109,17 @@ public function getFormStateDefaults(); * @see self::processForm() * @see \Drupal\system\FormAjaxController::content() */ - public function rebuildForm($form_id, &$form_state, $old_form = NULL); + public function rebuildForm($form_id, FormStateInterface &$form_state, $old_form = NULL); /** * Fetches a form from the cache. */ - public function getCache($form_build_id, &$form_state); + public function getCache($form_build_id, FormStateInterface &$form_state); /** * Stores a form in the cache. */ - public function setCache($form_build_id, $form, $form_state); + public function setCache($form_build_id, $form, FormStateInterface $form_state); /** * Retrieves, populates, and processes a form. @@ -293,8 +136,8 @@ public function setCache($form_build_id, $form, $form_state); * the desired form. If $form_arg is a string and a function with that * name exists, it is called to build the form array. * @param $form_state - * A keyed array containing the current state of the form. Most important is - * the $form_state['values'] collection, a tree of data used to simulate the + * The current state of the form. Most important is the + * $form_state['values'] collection, a tree of data used to simulate the * incoming \Drupal::request()->request information from a user's form * submission. If a key is not filled in $form_state['values'], then the * default value of the respective element is used. To submit an unchecked @@ -310,7 +153,7 @@ public function setCache($form_build_id, $form, $form_state); * $form_state build info array so that the reference can be preserved. For * example, a form builder function with the following signature: * @code - * function mymodule_form($form, &$form_state, &$object) { + * function mymodule_form($form, FormStateInterface &$form_state, &$object) { * } * @endcode * would be called via self::submitForm() as follows: @@ -322,7 +165,7 @@ public function setCache($form_build_id, $form, $form_state); * For example: * @code * // register a new user - * $form_state = array(); + * $form_state = new FormState(); * $form_state['values']['name'] = 'robo-user'; * $form_state['values']['mail'] = 'robouser@example.com'; * $form_state['values']['pass']['pass1'] = 'password'; @@ -331,7 +174,7 @@ public function setCache($form_build_id, $form, $form_state); * drupal_form_submit('user_register_form', $form_state); * @endcode */ - public function submitForm($form_arg, &$form_state); + public function submitForm($form_arg, FormStateInterface &$form_state); /** * Retrieves the structured array that defines a given form. @@ -339,14 +182,14 @@ public function submitForm($form_arg, &$form_state); * @param string $form_id * The unique string identifying the desired form. If a function * with that name exists, it is called to build the form array. - * @param array $form_state - * A keyed array containing the current state of the form, including the - * additional arguments to self::getForm() or self::submitForm() in the - * 'args' component of the array. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form, including the additional arguments to + * self::getForm() or self::submitForm() in the 'args' component of the + * array. * * @return mixed|\Symfony\Component\HttpFoundation\Response */ - public function retrieveForm($form_id, &$form_state); + public function retrieveForm($form_id, FormStateInterface &$form_state); /** * Processes a form submission. @@ -358,16 +201,15 @@ public function retrieveForm($form_id, &$form_state); * The unique string identifying the current form. * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * A keyed array containing the current state of the form. This - * includes the current persistent storage data for the form, and - * any data passed along by earlier steps when displaying a - * multi-step form. Additional information, like the sanitized - * \Drupal::request()->request data, is also accumulated here. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. This includes the current persistent + * storage data for the form, and any data passed along by earlier steps + * when displaying a multi-step form. Additional information, like the + * sanitized \Drupal::request()->request data, is also accumulated here. * * @return \Symfony\Component\HttpFoundation\RedirectResponse|null */ - public function processForm($form_id, &$form, &$form_state); + public function processForm($form_id, &$form, FormStateInterface &$form_state); /** * Prepares a structured form array. @@ -380,11 +222,11 @@ public function processForm($form_id, &$form, &$form_state); * theming, and hook_form_alter functions. * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * A keyed array containing the current state of the form. Passed - * in here so that hook_form_alter() calls can use it, as well. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. Passed in here so that hook_form_alter() + * calls can use it, as well. */ - public function prepareForm($form_id, &$form, &$form_state); + public function prepareForm($form_id, &$form, FormStateInterface &$form_state); /** * Builds and processes all elements in the structured form array. @@ -473,15 +315,14 @@ public function prepareForm($form_id, &$form, &$form_state); * theming, and hook_form_alter functions. * @param array $element * An associative array containing the structure of the current element. - * @param array $form_state - * A keyed array containing the current state of the form. In this - * context, it is used to accumulate information about which button - * was clicked when the form was submitted, as well as the sanitized - * \Drupal::request()->request data. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. In this context, it is used to accumulate + * information about which button was clicked when the form was submitted, + * as well as the sanitized \Drupal::request()->request data. * * @return array */ - public function doBuildForm($form_id, &$element, &$form_state); + public function doBuildForm($form_id, &$element, FormStateInterface &$form_state); /** * Changes submitted form values during form validation. @@ -508,8 +349,8 @@ public function doBuildForm($form_id, &$element, &$form_state); * @param $value * The new value for the form element. * @param $form_state - * Form state array where the value change should be recorded. + * The current state of the form where the value change should be recorded. */ - public function setValue($element, $value, &$form_state); + public function setValue($element, $value, FormStateInterface &$form_state); } diff --git a/core/lib/Drupal/Core/Form/FormErrorInterface.php b/core/lib/Drupal/Core/Form/FormErrorInterface.php index 43d0c5ac0f0b76d76f01e93b9fa1068f033b9557..825ff49f7f8d80599170d1e0633197903f5fcb9d 100644 --- a/core/lib/Drupal/Core/Form/FormErrorInterface.php +++ b/core/lib/Drupal/Core/Form/FormErrorInterface.php @@ -9,6 +9,9 @@ /** * Provides an interface for form error handling. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Core\Form\FormStateInterface directly. */ interface FormErrorInterface { @@ -99,8 +102,8 @@ interface FormErrorInterface { * element is array('foo', 'bar', 'baz') then you may set an error on 'foo' * or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every * element where the #parents array starts with 'foo'. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param string $message * (optional) The error message to present to the user. * @@ -108,26 +111,26 @@ interface FormErrorInterface { * Return value is for internal use only. To get a list of errors, use * FormErrorInterface::getErrors() or FormErrorInterface::getError(). */ - public function setErrorByName($name, array &$form_state, $message = ''); + public function setErrorByName($name, FormStateInterface &$form_state, $message = ''); /** * Clears all errors against all form elements made by FormErrorInterface::setErrorByName(). * - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function clearErrors(array &$form_state); + public function clearErrors(FormStateInterface &$form_state); /** * Returns an associative array of all errors. * - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * An array of all errors, keyed by the name of the form element. */ - public function getErrors(array $form_state); + public function getErrors(FormStateInterface &$form_state); /** * Returns the error message filed against the given form element. @@ -137,18 +140,18 @@ public function getErrors(array $form_state); * * @param array $element * The form element to check for errors. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return string|null * Either the error message for this element or NULL if there are no errors. */ - public function getError($element, array &$form_state); + public function getError($element, FormStateInterface &$form_state); /** * Flags an element as having an error. */ - public function setError(&$element, array &$form_state, $message = ''); + public function setError(&$element, FormStateInterface &$form_state, $message = ''); /** * Returns if there have been any errors during build. diff --git a/core/lib/Drupal/Core/Form/FormInterface.php b/core/lib/Drupal/Core/Form/FormInterface.php index 40daf12c1043f8287add534c106958f5a729cdef..00c686ef310d15812232d44ab5e17dcad3dc81c9 100644 --- a/core/lib/Drupal/Core/Form/FormInterface.php +++ b/core/lib/Drupal/Core/Form/FormInterface.php @@ -27,32 +27,32 @@ public function getFormId(); * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * The form structure. */ - public function buildForm(array $form, array &$form_state); + public function buildForm(array $form, FormStateInterface $form_state); /** * Form validation handler. * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function validateForm(array &$form, array &$form_state); + public function validateForm(array &$form, FormStateInterface $form_state); /** * Form submission handler. * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function submitForm(array &$form, array &$form_state); + public function submitForm(array &$form, FormStateInterface $form_state); } diff --git a/core/lib/Drupal/Core/Form/FormState.php b/core/lib/Drupal/Core/Form/FormState.php new file mode 100644 index 0000000000000000000000000000000000000000..b0a21db0f0a51a188a19b269146d014386626461 --- /dev/null +++ b/core/lib/Drupal/Core/Form/FormState.php @@ -0,0 +1,748 @@ + array(), + 'files' => array(), + ); + + /** + * Similar to self::$build_info, but pertaining to + * \Drupal\Core\Form\FormBuilderInterface::rebuildForm(). + * + * This property is uncacheable. + * + * @var array + */ + protected $rebuild_info = array(); + + /** + * Normally, after the entire form processing is completed and submit handlers + * have run, a form is considered to be done and + * \Drupal\Core\Form\FormSubmitterInterface::redirectForm() will redirect the + * user to a new page using a GET request (so a browser refresh does not + * re-submit the form). However, if 'rebuild' has been set to TRUE, then a new + * copy of the form is immediately built and sent to the browser, instead of a + * redirect. This is used for multi-step forms, such as wizards and + * confirmation forms. Normally, $form_state['rebuild'] is set by a submit + * handler, since its is usually logic within a submit handler that determines + * whether a form is done or requires another step. However, a validation + * handler may already set $form_state['rebuild'] to cause the form processing + * to bypass submit handlers and rebuild the form instead, even if there are + * no validation errors. + * + * This property is uncacheable. + * + * @see self::setRebuild() + * + * @var bool + */ + protected $rebuild = FALSE; + + /** + * Used when a form needs to return some kind of a + * \Symfony\Component\HttpFoundation\Response object, e.g., a + * \Symfony\Component\HttpFoundation\BinaryFileResponse when triggering a + * file download. If you use the $form_state['redirect'] key, it will be used + * to build a \Symfony\Component\HttpFoundation\RedirectResponse and will + * populate this key. + * + * @var \Symfony\Component\HttpFoundation\Response|null + */ + protected $response; + + /** + * Used to redirect the form on submission. It may either be a string + * containing the destination URL, or an array of arguments compatible with + * url(). See url() for complete information. + * + * This property is uncacheable. + * + * @var string|array|null + */ + protected $redirect; + + /** + * Used for route-based redirects. + * + * This property is uncacheable. + * + * @var \Drupal\Core\Url|array + */ + protected $redirect_route; + + /** + * If set to TRUE the form will NOT perform a redirect, even if + * self::$redirect is set. + * + * This property is uncacheable. + * + * @var bool + */ + protected $no_redirect; + + /** + * The HTTP form method to use for finding the input for this form. + * + * May be 'post' or 'get'. Defaults to 'post'. Note that 'get' method forms do + * not use form ids so are always considered to be submitted, which can have + * unexpected effects. The 'get' method should only be used on forms that do + * not change data, as that is exclusively the domain of 'post.' + * + * This property is uncacheable. + * + * @var string + */ + protected $method = 'post'; + + /** + * If set to TRUE the original, unprocessed form structure will be cached, + * which allows the entire form to be rebuilt from cache. A typical form + * workflow involves two page requests; first, a form is built and rendered + * for the user to fill in. Then, the user fills the form in and submits it, + * triggering a second page request in which the form must be built and + * processed. By default, $form and $form_state are built from scratch during + * each of these page requests. Often, it is necessary or desired to persist + * the $form and $form_state variables from the initial page request to the + * one that processes the submission. 'cache' can be set to TRUE to do this. + * A prominent example is an Ajax-enabled form, in which ajax_process_form() + * enables form caching for all forms that include an element with the #ajax + * property. (The Ajax handler has no way to build the form itself, so must + * rely on the cached version.) Note that the persistence of $form and + * $form_state happens automatically for (multi-step) forms having the + * self::$rebuild flag set, regardless of the value for self::$cache. + * + * @var bool + */ + protected $cache = FALSE; + + /** + * If set to TRUE the form will NOT be cached, even if 'cache' is set. + * + * @var bool + */ + protected $no_cache; + + /** + * An associative array of values submitted to the form. + * + * The validation functions and submit functions use this array for nearly all + * their decision making. (Note that #tree determines whether the values are a + * flat array or an array whose structure parallels the $form array. See the + * @link forms_api_reference.html Form API reference @endlink for more + * information.) + * + * This property is uncacheable. + * + * @var array + */ + protected $values; + + /** + * The array of values as they were submitted by the user. + * + * These are raw and unvalidated, so should not be used without a thorough + * understanding of security implications. In almost all cases, code should + * use the data in the 'values' array exclusively. The most common use of this + * key is for multi-step forms that need to clear some of the user input when + * setting 'rebuild'. The values correspond to \Drupal::request()->request or + * \Drupal::request()->query, depending on the 'method' chosen. + * + * This property is uncacheable. + * + * @var array + */ + protected $input; + + /** + * If TRUE and the method is GET, a form_id is not necessary. + * + * This should only be used on RESTful GET forms that do NOT write data, as + * this could lead to security issues. It is useful so that searches do not + * need to have a form_id in their query arguments to trigger the search. + * + * This property is uncacheable. + * + * @var bool + */ + protected $always_process; + + /** + * Ordinarily, a form is only validated once, but there are times when a form + * is resubmitted internally and should be validated again. Setting this to + * TRUE will force that to happen. This is most likely to occur during Ajax + * operations. + * + * This property is uncacheable. + * + * @var bool + */ + protected $must_validate; + + /** + * If TRUE, the form was submitted programmatically, usually invoked via + * \Drupal\Core\Form\FormBuilderInterface::submitForm(). Defaults to FALSE. + * + * @var bool + */ + protected $programmed = FALSE; + + /** + * If TRUE, programmatic form submissions are processed without taking #access + * into account. Set this to FALSE when submitting a form programmatically + * with values that may have been input by the user executing the current + * request; this will cause #access to be respected as it would on a normal + * form submission. Defaults to TRUE. + * + * @var bool + */ + protected $programmed_bypass_access_check = TRUE; + + /** + * TRUE signifies correct form submission. This is always TRUE for programmed + * forms coming from \Drupal\Core\Form\FormBuilderInterface::submitForm() (see + * 'programmed' key), or if the form_id coming from the + * \Drupal::request()->request data is set and matches the current form_id. + * + * @var bool + */ + protected $process_input; + + /** + * If TRUE, the form has been submitted. Defaults to FALSE. + * + * This property is uncacheable. + * + * @var bool + */ + protected $submitted = FALSE; + + /** + * If TRUE, the form was submitted and has been processed and executed. + * + * This property is uncacheable. + * + * @var bool + */ + protected $executed = FALSE; + + /** + * The form element that triggered submission, which may or may not be a + * button (in the case of Ajax forms). This key is often used to distinguish + * between various buttons in a submit handler, and is also used in Ajax + * handlers. + * + * This property is uncacheable. + * + * @var array|null + */ + protected $triggering_element; + + /** + * If TRUE, there is a file element and Form API will set the appropriate + * 'enctype' HTML attribute on the form. + * + * @var bool + */ + protected $has_file_element; + + /** + * Contains references to details elements to render them within vertical tabs. + * + * This property is uncacheable. + * + * @var array + */ + protected $groups = array(); + + /** + * This is not a special key, and no specific support is provided for it in + * the Form API. By tradition it was the location where application-specific + * data was stored for communication between the submit, validation, and form + * builder functions, especially in a multi-step-style form. Form + * implementations may use any key(s) within $form_state (other than the keys + * listed here and other reserved ones used by Form API internals) for this + * kind of storage. The recommended way to ensure that the chosen key doesn't + * conflict with ones used by the Form API or other modules is to use the + * module name as the key name or a prefix for the key name. For example, the + * entity form classes use $this->entity in entity forms, or + * $form_state['controller']->getEntity() outside the controller, to store + * information about the entity being edited, and this information stays + * available across successive clicks of the "Preview" button (if available) + * as well as when the "Save" button is finally clicked. + * + * @var array + */ + protected $storage = array(); + + /** + * A list containing copies of all submit and button elements in the form. + * + * This property is uncacheable. + * + * @var array + */ + protected $buttons = array(); + + /** + * Holds temporary data accessible during the current page request only. + * + * All $form_state properties that are not reserved keys (see + * other properties marked as uncacheable) persist throughout a multistep form + * sequence. Form API provides this key for modules to communicate information + * across form-related functions during a single page request. It may be used + * to temporarily save data that does not need to or should not be cached + * during the whole form workflow; e.g., data that needs to be accessed during + * the current form build process only. There is no use-case for this + * functionality in Drupal core. + * + * This property is uncacheable. + * + * @var array + */ + protected $temporary; + + /** + * Tracks if the form has finished validation. + * + * This property is uncacheable. + * + * @var bool + */ + protected $validation_complete = FALSE; + + /** + * Contains errors for this form. + * + * This property is uncacheable. + * + * @var array + */ + protected $errors = array(); + + /** + * Stores which errors should be limited during validation. + * + * This property is uncacheable. + * + * @var array|null + */ + protected $limit_validation_errors; + + /** + * Stores the gathered validation handlers. + * + * This property is uncacheable. + * + * @var array|null + */ + protected $validate_handlers; + + /** + * Stores the gathered submission handlers. + * + * This property is uncacheable. + * + * @var array|null + */ + protected $submit_handlers; + + /** + * Constructs a \Drupal\Core\Form\FormState object. + * + * @param array $form_state_additions + * (optional) An associative array used to build the current state of the + * form. Use this to pass additional information to the form, such as the + * langcode. Defaults to an empty array. + */ + public function __construct(array $form_state_additions = array()) { + $this->setFormState($form_state_additions); + } + + /** + * {@inheritdoc} + */ + public function setFormState(array $form_state_additions) { + foreach ($form_state_additions as $key => $value) { + $this->set($key, $value); + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCacheableArray($allowed_keys = array()) { + $cacheable_array = array( + 'build_info' => $this->build_info, + 'response' => $this->response, + 'cache' => $this->cache, + 'no_cache' => $this->no_cache, + 'programmed' => $this->programmed, + 'programmed_bypass_access_check' => $this->programmed_bypass_access_check, + 'process_input' => $this->process_input, + 'has_file_element' => $this->has_file_element, + 'storage' => $this->storage, + ) + $this->internalStorage; + foreach ($allowed_keys as $allowed_key) { + $cacheable_array[$allowed_key] = $this->get($allowed_key); + } + return $cacheable_array; + } + + /** + * {@inheritdoc} + */ + public function setCompleteForm(array &$complete_form) { + $this->complete_form = &$complete_form; + return $this; + } + + /** + * {@inheritdoc} + */ + public function &getCompleteForm() { + return $this->complete_form; + } + + /** + * {@inheritdoc} + */ + public function offsetExists($offset) { + return isset($this->{$offset}) || isset($this->internalStorage[$offset]); + } + + /** + * {@inheritdoc} + */ + public function &offsetGet($offset) { + $value = &$this->get($offset); + return $value; + } + + /** + * {@inheritdoc} + */ + public function offsetSet($offset, $value) { + $this->set($offset, $value); + } + + /** + * {@inheritdoc} + */ + public function offsetUnset($offset) { + if (property_exists($this, $offset)) { + $this->{$offset} = NULL; + } + unset($this->internalStorage[$offset]); + } + + /** + * {@inheritdoc} + */ + public function setIfNotExists($property, $value) { + if (!$this->has($property)) { + $this->set($property, $value); + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function &get($property) { + if (property_exists($this, $property)) { + return $this->{$property}; + } + else { + if (!isset($this->internalStorage[$property])) { + $this->internalStorage[$property] = NULL; + } + return $this->internalStorage[$property]; + } + } + + /** + * {@inheritdoc} + */ + public function set($property, $value) { + if (property_exists($this, $property)) { + $this->{$property} = $value; + } + else { + $this->internalStorage[$property] = $value; + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function has($property) { + if (property_exists($this, $property)) { + return $this->{$property} !== NULL; + } + + return array_key_exists($property, $this->internalStorage); + } + + /** + * {@inheritdoc} + */ + public function addBuildInfo($property, $value) { + $build_info = $this->get('build_info'); + $build_info[$property] = $value; + $this->set('build_info', $build_info); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getValues() { + return $this->values; + } + + /** + * {@inheritdoc} + */ + public function addValue($property, $value) { + $values = $this->getValues(); + $values[$property] = $value; + $this->set('values', $values); + return $this; + } + + /** + * {@inheritdoc} + */ + public function setRedirect(Url $url) { + $this->set('redirect_route', $url); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getRedirect() { + // Skip redirection for form submissions invoked via + // \Drupal\Core\Form\FormBuilderInterface::submitForm(). + if ($this->get('programmed')) { + return FALSE; + } + // Skip redirection if rebuild is activated. + if ($this->get('rebuild')) { + return FALSE; + } + // Skip redirection if it was explicitly disallowed. + if ($this->get('no_redirect')) { + return FALSE; + } + + // Check for a route-based redirection. + if ($redirect_route = $this->get('redirect_route')) { + // @todo Remove once all redirects are converted to \Drupal\Core\Url. See + // https://www.drupal.org/node/2189661. + if (!($redirect_route instanceof Url)) { + $redirect_route += array( + 'route_parameters' => array(), + 'options' => array(), + ); + $redirect_route = new Url($redirect_route['route_name'], $redirect_route['route_parameters'], $redirect_route['options']); + } + + $redirect_route->setAbsolute(); + return $redirect_route; + } + + return $this->get('redirect'); + } + + /** + * Sets the global status of errors. + * + * @param bool $errors + * TRUE if any form has any errors, FALSE otherwise. + */ + protected static function setAnyErrors($errors = TRUE) { + static::$anyErrors = $errors; + } + + /** + * {@inheritdoc} + */ + public static function hasAnyErrors() { + return static::$anyErrors; + } + + /** + * {@inheritdoc} + */ + public function setErrorByName($name, $message = '') { + if ($this->get('validation_complete')) { + throw new \LogicException('Form errors cannot be set after form validation has finished.'); + } + + $errors = $this->getErrors(); + if (!isset($errors[$name])) { + $record = TRUE; + $limit_validation_errors = $this->get('limit_validation_errors'); + if ($limit_validation_errors !== NULL) { + // #limit_validation_errors is an array of "sections" within which user + // input must be valid. If the element is within one of these sections, + // the error must be recorded. Otherwise, it can be suppressed. + // #limit_validation_errors can be an empty array, in which case all + // errors are suppressed. For example, a "Previous" button might want + // its submit action to be triggered even if none of the submitted + // values are valid. + $record = FALSE; + foreach ($limit_validation_errors as $section) { + // Exploding by '][' reconstructs the element's #parents. If the + // reconstructed #parents begin with the same keys as the specified + // section, then the element's values are within the part of + // $form_state['values'] that the clicked button requires to be valid, + // so errors for this element must be recorded. As the exploded array + // will all be strings, we need to cast every value of the section + // array to string. + if (array_slice(explode('][', $name), 0, count($section)) === array_map('strval', $section)) { + $record = TRUE; + break; + } + } + } + if ($record) { + $errors[$name] = $message; + $this->set('errors', $errors); + static::setAnyErrors(); + if ($message) { + $this->drupalSetMessage($message, 'error'); + } + } + } + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setError(&$element, $message = '') { + $this->setErrorByName(implode('][', $element['#parents']), $message); + return $this; + } + + /** + * {@inheritdoc} + */ + public function clearErrors() { + $this->set('errors', array()); + static::setAnyErrors(FALSE); + } + + /** + * {@inheritdoc} + */ + public function getError($element) { + if ($errors = $this->getErrors($this)) { + $parents = array(); + foreach ($element['#parents'] as $parent) { + $parents[] = $parent; + $key = implode('][', $parents); + if (isset($errors[$key])) { + return $errors[$key]; + } + } + } + } + + /** + * {@inheritdoc} + */ + public function getErrors() { + return $this->get('errors'); + } + + /** + * {@inheritdoc} + */ + public function setRebuild($rebuild = TRUE) { + $this->set('rebuild', $rebuild); + return $this; + } + + /** + * Wraps drupal_set_message(). + * + * @return array|null + */ + protected function drupalSetMessage($message = NULL, $type = 'status', $repeat = FALSE) { + return drupal_set_message($message, $type, $repeat); + } + +} diff --git a/core/lib/Drupal/Core/Form/FormStateInterface.php b/core/lib/Drupal/Core/Form/FormStateInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..24ceb52652b528ebcacacccb30b40a86e41ce3f9 --- /dev/null +++ b/core/lib/Drupal/Core/Form/FormStateInterface.php @@ -0,0 +1,314 @@ + 'submit', + * '#value' => t('Previous'), + * '#limit_validation_errors' => array(), // No validation. + * '#submit' => array('some_submit_function'), // #submit required. + * ); + * @endcode + * + * Example 2: Require some, but not all, user input to be valid to process the + * submission of a "Previous" button. + * + * @code + * $form['actions']['previous'] = array( + * '#type' => 'submit', + * '#value' => t('Previous'), + * '#limit_validation_errors' => array( + * array('step1'), // Validate $form_state['values']['step1']. + * array('foo', 'bar'), // Validate $form_state['values']['foo']['bar']. + * ), + * '#submit' => array('some_submit_function'), // #submit required. + * ); + * @endcode + * + * This will require $form_state['values']['step1'] and everything within it + * (for example, $form_state['values']['step1']['choice']) to be valid, so + * calls to FormErrorInterface::setErrorByName('step1', $form_state, $message) + * or + * FormErrorInterface::setErrorByName('step1][choice', $form_state, $message) + * will prevent the submit handlers from running, and result in the error + * message being displayed to the user. However, calls to + * FormErrorInterface::setErrorByName('step2', $form_state, $message) and + * FormErrorInterface::setErrorByName('step2][groupX][choiceY', $form_state, $message) + * will be suppressed, resulting in the message not being displayed to the + * user, and the submit handlers will run despite + * $form_state['values']['step2'] and + * $form_state['values']['step2']['groupX']['choiceY'] containing invalid + * values. Errors for an invalid $form_state['values']['foo'] will be + * suppressed, but errors flagging invalid values for + * $form_state['values']['foo']['bar'] and everything within it will be + * flagged and submission prevented. + * + * Partial form validation is implemented by suppressing errors rather than by + * skipping the input processing and validation steps entirely, because some + * forms have button-level submit handlers that call Drupal API functions that + * assume that certain data exists within $form_state['values'], and while not + * doing anything with that data that requires it to be valid, PHP errors + * would be triggered if the input processing and validation steps were fully + * skipped. + * + * @param string $name + * The name of the form element. If the #parents property of your form + * element is array('foo', 'bar', 'baz') then you may set an error on 'foo' + * or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every + * element where the #parents array starts with 'foo'. + * @param string $message + * (optional) The error message to present to the user. + * + * @return $this + */ + public function setErrorByName($name, $message = ''); + + /** + * Flags an element as having an error. + * + * @param array $element + * The form element. + * @param string $message + * (optional) The error message to present to the user. + * + * @return $this + */ + public function setError(&$element, $message = ''); + + /** + * Clears all errors against all form elements made by FormErrorInterface::setErrorByName(). + */ + public function clearErrors(); + + /** + * Returns an associative array of all errors. + * + * @return array + * An array of all errors, keyed by the name of the form element. + */ + public function getErrors(); + + /** + * Returns the error message filed against the given form element. + * + * Form errors higher up in the form structure override deeper errors as well + * as errors on the element itself. + * + * @param array $element + * The form element to check for errors. + * + * @return string|null + * Either the error message for this element or NULL if there are no errors. + */ + public function getError($element); + + /** + * Sets the form to be rebuilt after processing. + * + * @param bool $rebuild + * (optional) Whether the form should be rebuilt or not. Defaults to TRUE. + * + * @return $this + */ + public function setRebuild($rebuild = TRUE); + +} diff --git a/core/lib/Drupal/Core/Form/FormSubmitter.php b/core/lib/Drupal/Core/Form/FormSubmitter.php index 78aca72665f549a5843051e1c2f450a5d9e095d2..4c5d1c75993c5a30e2c075d42376b7135944d526 100644 --- a/core/lib/Drupal/Core/Form/FormSubmitter.php +++ b/core/lib/Drupal/Core/Form/FormSubmitter.php @@ -47,7 +47,7 @@ public function __construct(RequestStack $request_stack, UrlGeneratorInterface $ /** * {@inheritdoc} */ - public function doSubmitForm(&$form, &$form_state) { + public function doSubmitForm(&$form, FormStateInterface &$form_state) { if (!$form_state['submitted']) { return; } @@ -61,18 +61,7 @@ public function doSubmitForm(&$form, &$form_state) { // \Drupal\Core\Form\FormBuilderInterface::submitForm). if ($batch = &$this->batchGet() && !isset($batch['current_set'])) { // Store $form_state information in the batch definition. - // We need the full $form_state when either: - // - Some submit handlers were saved to be called during batch - // processing. See self::executeSubmitHandlers(). - // - The form is multistep. - // In other cases, we only need the information expected by - // self::redirectForm(). - if ($batch['has_form_submits'] || !empty($form_state['rebuild'])) { - $batch['form_state'] = $form_state; - } - else { - $batch['form_state'] = array_intersect_key($form_state, array_flip(array('programmed', 'rebuild', 'storage', 'no_redirect', 'redirect', 'redirect_route'))); - } + $batch['form_state'] = $form_state; $batch['progressive'] = !$form_state['programmed']; $response = batch_process(); @@ -103,13 +92,13 @@ public function doSubmitForm(&$form, &$form_state) { /** * {@inheritdoc} */ - public function executeSubmitHandlers(&$form, &$form_state) { + public function executeSubmitHandlers(&$form, FormStateInterface &$form_state) { // If there was a button pressed, use its handlers. - if (isset($form_state['submit_handlers'])) { + if (!empty($form_state['submit_handlers'])) { $handlers = $form_state['submit_handlers']; } // Otherwise, check for a form-level handler. - elseif (isset($form['#submit'])) { + elseif (!empty($form['#submit'])) { $handlers = $form['#submit']; } else { @@ -137,76 +126,53 @@ public function executeSubmitHandlers(&$form, &$form_state) { /** * {@inheritdoc} */ - public function redirectForm($form_state) { - // Skip redirection for form submissions invoked via - // \Drupal\Core\Form\FormBuilderInterface::submitForm(). - if (!empty($form_state['programmed'])) { - return; - } - // Skip redirection if rebuild is activated. - if (!empty($form_state['rebuild'])) { - return; - } - // Skip redirection if it was explicitly disallowed. - if (!empty($form_state['no_redirect'])) { - return; - } + public function redirectForm(FormStateInterface $form_state) { + // According to RFC 7231, 303 See Other status code must be used to redirect + // user agent (and not default 302 Found). + // @see http://tools.ietf.org/html/rfc7231#section-6.4.4 + $status_code = Response::HTTP_SEE_OTHER; + $redirect = $form_state->getRedirect(); // Allow using redirect responses directly if needed. - if (isset($form_state['redirect']) && $form_state['redirect'] instanceof RedirectResponse) { - return $form_state['redirect']; + if ($redirect instanceof RedirectResponse) { + return $redirect; } + $url = NULL; // Check for a route-based redirection. - if (isset($form_state['redirect_route'])) { - // @todo Remove once all redirects are converted to Url. - if (!($form_state['redirect_route'] instanceof Url)) { - $form_state['redirect_route'] += array( - 'route_parameters' => array(), - 'options' => array(), - ); - $form_state['redirect_route'] = new Url($form_state['redirect_route']['route_name'], $form_state['redirect_route']['route_parameters'], $form_state['redirect_route']['options']); + if ($redirect instanceof Url) { + $url = $redirect->toString(); + } + // An array contains the path to use for the redirect, as well as options to + // use for generating the URL. + elseif (is_array($redirect)) { + if (isset($redirect[1])) { + $options = $redirect[1]; } - - $form_state['redirect_route']->setAbsolute(); - // According to RFC 7231, 303 See Other status code must be used - // to redirect user agent (and not default 302 Found). - // @see http://tools.ietf.org/html/rfc7231#section-6.4.4 - return new RedirectResponse($form_state['redirect_route']->toString(), Response::HTTP_SEE_OTHER); + else { + $options = array(); + } + // Redirections should always use absolute URLs. + $options['absolute'] = TRUE; + if (isset($redirect[2])) { + $status_code = $redirect[2]; + } + $url = $this->urlGenerator->generateFromPath($redirect[0], $options); } - - // Only invoke a redirection if redirect value was not set to FALSE. - if (!isset($form_state['redirect']) || $form_state['redirect'] !== FALSE) { - if (isset($form_state['redirect'])) { - if (is_array($form_state['redirect'])) { - if (isset($form_state['redirect'][1])) { - $options = $form_state['redirect'][1]; - } - else { - $options = array(); - } - // Redirections should always use absolute URLs. - $options['absolute'] = TRUE; - if (isset($form_state['redirect'][2])) { - $status_code = $form_state['redirect'][2]; - } - else { - $status_code = Response::HTTP_SEE_OTHER; - } - return new RedirectResponse($this->urlGenerator->generateFromPath($form_state['redirect'][0], $options), $status_code); - } - else { - // This function can be called from the installer, which guarantees - // that $redirect will always be a string, so catch that case here - // and use the appropriate redirect function. - if ($this->drupalInstallationAttempted()) { - install_goto($form_state['redirect']); - } - else { - return new RedirectResponse($this->urlGenerator->generateFromPath($form_state['redirect'], array('absolute' => TRUE)), Response::HTTP_SEE_OTHER); - } - } + // A string represents the path to use for the redirect. + elseif (is_string($redirect)) { + // This function can be called from the installer, which guarantees + // that $redirect will always be a string, so catch that case here + // and use the appropriate redirect function. + if ($this->drupalInstallationAttempted()) { + install_goto($redirect); } + else { + $url = $this->urlGenerator->generateFromPath($redirect, array('absolute' => TRUE)); + } + } + // If no redirect was specified, redirect to the current path. + elseif ($redirect === NULL) { $request = $this->requestStack->getCurrentRequest(); // @todo Remove dependency on the internal _system_path attribute: // https://www.drupal.org/node/2293521. @@ -214,7 +180,10 @@ public function redirectForm($form_state) { 'query' => $request->query->all(), 'absolute' => TRUE, )); - return new RedirectResponse($url, Response::HTTP_SEE_OTHER); + } + + if ($url) { + return new RedirectResponse($url, $status_code); } } diff --git a/core/lib/Drupal/Core/Form/FormSubmitterInterface.php b/core/lib/Drupal/Core/Form/FormSubmitterInterface.php index 8ae8b0832e7af16527ac3ff8825a1575d2993889..8a79fe0791d2334b58a6924b237f1ba1ffb658c4 100644 --- a/core/lib/Drupal/Core/Form/FormSubmitterInterface.php +++ b/core/lib/Drupal/Core/Form/FormSubmitterInterface.php @@ -17,14 +17,14 @@ interface FormSubmitterInterface { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return null|\Symfony\Component\HttpFoundation\Response * If a response was set by a submit handler, or if the form needs to * redirect, a Response object will be returned. */ - public function doSubmitForm(&$form, &$form_state); + public function doSubmitForm(&$form, FormStateInterface &$form_state); /** * Executes custom submission handlers for a given form. @@ -35,18 +35,18 @@ public function doSubmitForm(&$form, &$form_state); * @param $form * An associative array containing the structure of the form. * @param $form_state - * A keyed array containing the current state of the form. If the user - * submitted the form by clicking a button with custom handler functions - * defined, those handlers will be stored here. + * The current state of the form. If the user submitted the form by clicking + * a button with custom handler functions defined, those handlers will be + * stored here. */ - public function executeSubmitHandlers(&$form, &$form_state); + public function executeSubmitHandlers(&$form, FormStateInterface &$form_state); /** * Redirects the user to a URL after a form has been processed. * * After a form is submitted and processed, normally the user should be * redirected to a new destination page. This function figures out what that - * destination should be, based on the $form_state array and the 'destination' + * destination should be, based on the $form_state and the 'destination' * query string in the request URL, and redirects the user there. * * Usually (for exceptions, see below) $form_state['redirect'] determines @@ -58,11 +58,11 @@ public function executeSubmitHandlers(&$form, &$form_state); * * Here is an example of how to set up a form to redirect to the path 'node': * @code - * $form_state['redirect'] = 'node'; + * $form_state->set('redirect', 'node'); * @endcode * And here is an example of how to redirect to 'node/123?foo=bar#baz': * @code - * $form_state['redirect'] = array( + * $form_state->set('redirect', array( * 'node/123', * array( * 'query' => array( @@ -70,7 +70,7 @@ public function executeSubmitHandlers(&$form, &$form_state); * ), * 'fragment' => 'baz', * ), - * ); + * )); * @endcode * * There are several exceptions to the "usual" behavior described above: @@ -94,13 +94,13 @@ public function executeSubmitHandlers(&$form, &$form_state); * $form_state['redirect']. * * @param $form_state - * An associative array containing the current state of the form. + * The current state of the form. * * @return \Symfony\Component\HttpFoundation\RedirectResponse|null * * @see \Drupal\Core\Form\FormBuilderInterface::processForm() * @see \Drupal\Core\Form\FormBuilderInterface::buildForm() */ - public function redirectForm($form_state); + public function redirectForm(FormStateInterface $form_state); } diff --git a/core/lib/Drupal/Core/Form/FormValidator.php b/core/lib/Drupal/Core/Form/FormValidator.php index eda8238a47ea3966e0351988ea6831894f3429a3..e35f06ac41e7c9088b44f145b0834e00e7454dcd 100644 --- a/core/lib/Drupal/Core/Form/FormValidator.php +++ b/core/lib/Drupal/Core/Form/FormValidator.php @@ -55,7 +55,7 @@ public function __construct(RequestStack $request_stack, TranslationInterface $s /** * {@inheritdoc} */ - public function executeValidateHandlers(&$form, &$form_state) { + public function executeValidateHandlers(&$form, FormStateInterface &$form_state) { // If there was a button pressed, use its handlers. if (isset($form_state['validate_handlers'])) { $handlers = $form_state['validate_handlers']; @@ -76,7 +76,7 @@ public function executeValidateHandlers(&$form, &$form_state) { /** * {@inheritdoc} */ - public function validateForm($form_id, &$form, &$form_state) { + public function validateForm($form_id, &$form, FormStateInterface &$form_state) { // If this form is flagged to always validate, ensure that previous runs of // validation are ignored. if (!empty($form_state['must_validate'])) { @@ -119,12 +119,12 @@ public function validateForm($form_id, &$form, &$form_state) { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param string $form_id * The unique string identifying the form. */ - protected function handleErrorsWithLimitedValidation(&$form, &$form_state, $form_id) { + protected function handleErrorsWithLimitedValidation(&$form, FormStateInterface &$form_state, $form_id) { // If validation errors are limited then remove any non validated form values, // so that only values that passed validation are left for submit callbacks. if (isset($form_state['triggering_element']['#limit_validation_errors']) && $form_state['triggering_element']['#limit_validation_errors'] !== FALSE) { @@ -171,12 +171,12 @@ protected function handleErrorsWithLimitedValidation(&$form, &$form_state, $form * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param string $form_id * The unique string identifying the form. */ - protected function finalizeValidation(&$form, &$form_state, $form_id) { + protected function finalizeValidation(&$form, FormStateInterface &$form_state, $form_id) { // After validation, loop through and assign each element its errors. $this->setElementErrorsFromFormState($form, $form_state); // Mark this form as validated. @@ -192,12 +192,12 @@ protected function finalizeValidation(&$form, &$form_state, $form_id) { * * @param $elements * An associative array containing the structure of the form. - * @param $form_state - * A keyed array containing the current state of the form. The current - * user-submitted data is stored in $form_state['values'], though - * form validation functions are passed an explicit copy of the - * values for the sake of simplicity. Validation handlers can also - * $form_state to pass information on to submit handlers. For example: + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. The current user-submitted data is stored + * in $form_state['values'], though form validation functions are passed an + * explicit copy of the values for the sake of simplicity. Validation + * handlers can also $form_state to pass information on to submit handlers. + * For example: * $form_state['data_for_submission'] = $data; * This technique is useful when validation requires file parsing, * web service requests, or other expensive requests that should @@ -206,7 +206,7 @@ protected function finalizeValidation(&$form, &$form_state, $form_id) { * A unique string identifying the form for validation, submission, * theming, and hook_form_alter functions. */ - protected function doValidateForm(&$elements, &$form_state, $form_id = NULL) { + protected function doValidateForm(&$elements, FormStateInterface &$form_state, $form_id = NULL) { // Recurse through all children. foreach (Element::children($elements) as $key) { if (isset($elements[$key]) && $elements[$key]) { @@ -289,18 +289,18 @@ protected function doValidateForm(&$elements, &$form_state, $form_id = NULL) { * * @param array $elements * An associative array containing the structure of the form. - * @param array $form_state - * A keyed array containing the current state of the form. The current - * user-submitted data is stored in $form_state['values'], though - * form validation functions are passed an explicit copy of the - * values for the sake of simplicity. Validation handlers can also - * $form_state to pass information on to submit handlers. For example: + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. The current user-submitted data is stored + * in $form_state['values'], though form validation functions are passed an + * explicit copy of the values for the sake of simplicity. Validation + * handlers can also $form_state to pass information on to submit handlers. + * For example: * $form_state['data_for_submission'] = $data; * This technique is useful when validation requires file parsing, * web service requests, or other expensive requests that should * not be repeated in the submission step. */ - protected function performRequiredValidation(&$elements, &$form_state) { + protected function performRequiredValidation(&$elements, FormStateInterface &$form_state) { // Verify that the value is not longer than #maxlength. if (isset($elements['#maxlength']) && Unicode::strlen($elements['#value']) > $elements['#maxlength']) { $this->setError($elements, $form_state, $this->t('!name cannot be longer than %max characters but is currently %length characters long.', array('!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => Unicode::strlen($elements['#value'])))); @@ -345,12 +345,12 @@ protected function performRequiredValidation(&$elements, &$form_state) { /** * Determines if validation errors should be limited. * - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array|null */ - protected function determineLimitValidationErrors(&$form_state) { + protected function determineLimitValidationErrors(FormStateInterface &$form_state) { // While this element is being validated, it may be desired that some // calls to self::setErrorByName() be suppressed and not result in a form // error, so that a button that implements low-risk functionality (such as @@ -395,10 +395,10 @@ protected function determineLimitValidationErrors(&$form_state) { * * @param array $elements * An associative array containing the structure of a form element. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - protected function setElementErrorsFromFormState(array &$elements, array &$form_state) { + protected function setElementErrorsFromFormState(array &$elements, FormStateInterface &$form_state) { // Recurse through all children. foreach (Element::children($elements) as $key) { if (isset($elements[$key]) && $elements[$key]) { @@ -412,91 +412,43 @@ protected function setElementErrorsFromFormState(array &$elements, array &$form_ /** * {@inheritdoc} */ - public function setErrorByName($name, array &$form_state, $message = '') { - if (!empty($form_state['validation_complete'])) { - throw new \LogicException('Form errors cannot be set after form validation has finished.'); - } - - if (!isset($form_state['errors'][$name])) { - $record = TRUE; - if (isset($form_state['limit_validation_errors'])) { - // #limit_validation_errors is an array of "sections" within which user - // input must be valid. If the element is within one of these sections, - // the error must be recorded. Otherwise, it can be suppressed. - // #limit_validation_errors can be an empty array, in which case all - // errors are suppressed. For example, a "Previous" button might want - // its submit action to be triggered even if none of the submitted - // values are valid. - $record = FALSE; - foreach ($form_state['limit_validation_errors'] as $section) { - // Exploding by '][' reconstructs the element's #parents. If the - // reconstructed #parents begin with the same keys as the specified - // section, then the element's values are within the part of - // $form_state['values'] that the clicked button requires to be valid, - // so errors for this element must be recorded. As the exploded array - // will all be strings, we need to cast every value of the section - // array to string. - if (array_slice(explode('][', $name), 0, count($section)) === array_map('strval', $section)) { - $record = TRUE; - break; - } - } - } - if ($record) { - $form_state['errors'][$name] = $message; - $this->requestStack->getCurrentRequest()->attributes->set('_form_errors', TRUE); - if ($message) { - $this->drupalSetMessage($message, 'error'); - } - } - } - - return $form_state['errors']; + public function setErrorByName($name, FormStateInterface &$form_state, $message = '') { + return $form_state->setErrorByName($name, $message); } /** * {@inheritdoc} */ - public function setError(&$element, array &$form_state, $message = '') { - $this->setErrorByName(implode('][', $element['#parents']), $form_state, $message); + public function setError(&$element, FormStateInterface &$form_state, $message = '') { + return $form_state->setError($element, $message); } /** * {@inheritdoc} */ - public function getError($element, array &$form_state) { - if ($errors = $this->getErrors($form_state)) { - $parents = array(); - foreach ($element['#parents'] as $parent) { - $parents[] = $parent; - $key = implode('][', $parents); - if (isset($errors[$key])) { - return $errors[$key]; - } - } - } + public function getError($element, FormStateInterface &$form_state) { + return $form_state->getError($element); } /** * {@inheritdoc} */ - public function clearErrors(array &$form_state) { - $form_state['errors'] = array(); - $this->requestStack->getCurrentRequest()->attributes->set('_form_errors', FALSE); + public function clearErrors(FormStateInterface &$form_state) { + $form_state->clearErrors(); } /** * {@inheritdoc} */ - public function getErrors(array $form_state) { - return $form_state['errors']; + public function getErrors(FormStateInterface &$form_state) { + return $form_state->getErrors(); } /** * {@inheritdoc} */ public function getAnyErrors() { - return (bool) $this->requestStack->getCurrentRequest()->attributes->get('_form_errors'); + return FormState::hasAnyErrors(); } /** @@ -506,13 +458,4 @@ protected function watchdog($type, $message, array $variables = array(), $severi watchdog($type, $message, $variables, $severity, $link); } - /** - * Wraps drupal_set_message(). - * - * @return array|null - */ - protected function drupalSetMessage($message = NULL, $type = 'status', $repeat = FALSE) { - return drupal_set_message($message, $type, $repeat); - } - } diff --git a/core/lib/Drupal/Core/Form/FormValidatorInterface.php b/core/lib/Drupal/Core/Form/FormValidatorInterface.php index 806e6a0c81914a70ac56cfe4f6f3b2196b9d063d..da8caa4f9bf33441a83879b0e5572d5a1c2d492b 100644 --- a/core/lib/Drupal/Core/Form/FormValidatorInterface.php +++ b/core/lib/Drupal/Core/Form/FormValidatorInterface.php @@ -21,14 +21,14 @@ interface FormValidatorInterface extends FormErrorInterface { * @param $form * An associative array containing the structure of the form. * @param $form_state - * A keyed array containing the current state of the form. If the user - * submitted the form by clicking a button with custom handler functions - * defined, those handlers will be stored here. + * The current state of the form. If the user submitted the form by clicking + * a button with custom handler functions defined, those handlers will be + * stored here. */ - public function executeValidateHandlers(&$form, &$form_state); + public function executeValidateHandlers(&$form, FormStateInterface &$form_state); /** - * Validates user-submitted form data in the $form_state array. + * Validates user-submitted form data in the $form_state. * * @param $form_id * A unique string identifying the form for validation, submission, @@ -42,16 +42,16 @@ public function executeValidateHandlers(&$form, &$form_state); * elements in $form_state['values'] to prevent form submit handlers from * receiving unvalidated values. * @param $form_state - * A keyed array containing the current state of the form. The current - * user-submitted data is stored in $form_state['values'], though - * form validation functions are passed an explicit copy of the - * values for the sake of simplicity. Validation handlers can also use - * $form_state to pass information on to submit handlers. For example: + * The current state of the form. The current user-submitted data is stored + * in $form_state['values'], though form validation functions are passed an + * explicit copy of the values for the sake of simplicity. Validation + * handlers can also use $form_state to pass information on to submit + * handlers. For example: * $form_state['data_for_submission'] = $data; * This technique is useful when validation requires file parsing, * web service requests, or other expensive requests that should * not be repeated in the submission step. */ - public function validateForm($form_id, &$form, &$form_state); + public function validateForm($form_id, &$form, FormStateInterface &$form_state); } diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php index 30d424e7523acfa39284d9fe01bf1493b7ebc64a..b50331ab3e93b103c032596b59187761123d4be7 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php @@ -8,6 +8,7 @@ namespace Drupal\Core\ImageToolkit; use Drupal\Component\Plugin\PluginInspectionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Image\ImageInterface; /** @@ -57,7 +58,7 @@ public function settingsForm(); * * @see system_image_toolkit_settings_submit() */ - public function settingsFormSubmit($form, &$form_state); + public function settingsFormSubmit($form, FormStateInterface $form_state); /** * Sets the image object that this toolkit instance is tied to. diff --git a/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php b/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php index d3667f7d78571bacb2d6589dd468fce0aa017776..a5c073743bd7424cf18f3f8a6c787f2c2ecd47db 100644 --- a/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\UserAgent; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManager; use Symfony\Component\HttpFoundation\Request; @@ -28,7 +29,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $install_state = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $install_state = NULL) { if (count($install_state['translations']) > 1) { $files = $install_state['translations']; } @@ -96,7 +97,7 @@ public function buildForm(array $form, array &$form_state, $install_state = NULL /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $install_state = &$form_state['build_info']['args'][0]; $install_state['parameters']['langcode'] = $form_state['values']['langcode']; } diff --git a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php index d88bc56ea2ebe1bf946658d109cfe8c81db26e14..e16c10ece595b144b628e3779ef8649516674bac 100644 --- a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Installer\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides the profile selection form. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $install_state = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $install_state = NULL) { $form['#title'] = $this->t('Select an installation profile'); $profiles = array(); @@ -87,7 +88,7 @@ public function buildForm(array $form, array &$form_state, $install_state = NULL /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { global $install_state; $install_state['parameters']['profile'] = $form_state['values']['profile']; } diff --git a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php index 745665b826dbba2e66365b84ce142c3d91400ff8..491a1d971bd528004fe79cb6a6ee6d8d22399516 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Locale\CountryManagerInterface; use Drupal\Core\State\StateInterface; use Drupal\user\UserStorageInterface; @@ -88,7 +89,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Configure site'); // Warn about settings.php permissions risk @@ -227,7 +228,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { if ($error = user_validate_name($form_state['values']['account']['name'])) { $this->setFormError('account][name', $form_state, $error); } @@ -236,7 +237,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('system.site') ->set('name', $form_state['values']['site_name']) ->set('mail', $form_state['values']['site_mail']) diff --git a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php index 23f0d03151845311b51d1b7622e534fe3726fe3c..10206207eb8a6fead72c13539e0030e880be0184 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Crypt; use Drupal\Core\Database\Database; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides a form to configure and rewrite settings.php. @@ -26,7 +27,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $conf_path = './' . conf_path(FALSE); $settings_file = $conf_path . '/settings.php'; @@ -114,7 +115,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $driver = $form_state['values']['driver']; $database = $form_state['values'][$driver]; $drivers = drupal_get_database_types(); @@ -134,7 +135,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { global $install_state; // Update global settings array and save. diff --git a/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php b/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php index 234fcb55bb26b89db342da8c7b440d6740927bcd..af3d43ceb15e65420d55bd73b58e0020b3862848 100644 --- a/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php +++ b/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Menu\Form; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Menu\MenuLinkInterface; use Drupal\Core\Menu\MenuLinkManagerInterface; use Drupal\Core\Menu\MenuParentFormSelectorInterface; @@ -101,7 +102,7 @@ public function setMenuLinkInstance(MenuLinkInterface $menu_link) { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Edit menu link %title', array('%title' => $this->menuLink->getTitle())); $provider = $this->menuLink->getProvider(); @@ -155,7 +156,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function extractFormValues(array &$form, array &$form_state) { + public function extractFormValues(array &$form, FormStateInterface $form_state) { $new_definition = array(); $new_definition['hidden'] = $form_state['values']['enabled'] ? 0 : 1; $new_definition['weight'] = (int) $form_state['values']['weight']; @@ -173,13 +174,13 @@ public function extractFormValues(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $new_definition = $this->extractFormValues($form, $form_state); return $this->menuLinkManager->updateDefinition($this->menuLink->getPluginId(), $new_definition); diff --git a/core/lib/Drupal/Core/Menu/Form/MenuLinkFormInterface.php b/core/lib/Drupal/Core/Menu/Form/MenuLinkFormInterface.php index f021890fc07c53795416ede1cc135033f5a2f0e1..fa0893bd3c37059376230eb4ea1116eaf5c25e4f 100644 --- a/core/lib/Drupal/Core/Menu/Form/MenuLinkFormInterface.php +++ b/core/lib/Drupal/Core/Menu/Form/MenuLinkFormInterface.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Menu\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Menu\MenuLinkInterface; use Drupal\Core\Plugin\PluginFormInterface; @@ -33,12 +34,12 @@ public function setMenuLinkInstance(MenuLinkInterface $menu_link); * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * The new plugin definition values taken from the form values. */ - public function extractFormValues(array &$form, array &$form_state); + public function extractFormValues(array &$form, FormStateInterface $form_state); } diff --git a/core/lib/Drupal/Core/Plugin/PluginFormInterface.php b/core/lib/Drupal/Core/Plugin/PluginFormInterface.php index daceeacd260f1fc0398836a7411fc5c3e35b7fa7..993c841ce3779e5857271be21d891ef8faaa00b0 100644 --- a/core/lib/Drupal/Core/Plugin/PluginFormInterface.php +++ b/core/lib/Drupal/Core/Plugin/PluginFormInterface.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Plugin; +use Drupal\Core\Form\FormStateInterface; + /** * Provides an interface for a plugin that contains a form. * @@ -19,32 +21,32 @@ interface PluginFormInterface { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * The form structure. */ - public function buildConfigurationForm(array $form, array &$form_state); + public function buildConfigurationForm(array $form, FormStateInterface $form_state); /** * Form validation handler. * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function validateConfigurationForm(array &$form, array &$form_state); + public function validateConfigurationForm(array &$form, FormStateInterface $form_state); /** * Form submission handler. * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function submitConfigurationForm(array &$form, array &$form_state); + public function submitConfigurationForm(array &$form, FormStateInterface $form_state); } diff --git a/core/lib/Drupal/Core/Update/Form/UpdateScriptSelectionForm.php b/core/lib/Drupal/Core/Update/Form/UpdateScriptSelectionForm.php index b6d440d8152931b49f73efebe932f8cd80e62aa6..574ec6c46db7bdecdf1adc720092de9e0687da50 100644 --- a/core/lib/Drupal/Core/Update/Form/UpdateScriptSelectionForm.php +++ b/core/lib/Drupal/Core/Update/Form/UpdateScriptSelectionForm.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Update\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides the list of available database module updates. @@ -24,7 +25,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $count = 0; $incompatible_count = 0; $form['start'] = array( @@ -127,7 +128,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/action/src/ActionAddForm.php b/core/modules/action/src/ActionAddForm.php index bae8dcbf7dc57c4219862e8cd7aacbc7ac3185be..6d8e4aabe0cab81fd2b202dfa43bee46646ac78d 100644 --- a/core/modules/action/src/ActionAddForm.php +++ b/core/modules/action/src/ActionAddForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Crypt; use Drupal\Core\Action\ActionManager; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -54,7 +55,7 @@ public static function create(ContainerInterface $container) { * @param string $action_id * The hashed version of the action ID. */ - public function buildForm(array $form, array &$form_state, $action_id = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $action_id = NULL) { // In \Drupal\action\Form\ActionAdminManageForm::buildForm() the action // are hashed. Here we have to decrypt it to find the desired action ID. foreach ($this->actionManager->getDefinitions() as $id => $definition) { diff --git a/core/modules/action/src/ActionFormBase.php b/core/modules/action/src/ActionFormBase.php index c2cbee3de106a622c2120974500a9b99a67d1d8f..23b7f07b3c0addaaa68c9bc9f376fc5c7de94169 100644 --- a/core/modules/action/src/ActionFormBase.php +++ b/core/modules/action/src/ActionFormBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\PluginFormInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -53,7 +54,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $this->plugin = $this->entity->getPlugin(); return parent::buildForm($form, $form_state); } @@ -61,7 +62,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form['label'] = array( '#type' => 'textfield', '#title' => $this->t('Label'), @@ -113,7 +114,7 @@ public function exists($id) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); unset($actions['delete']); return $actions; @@ -122,7 +123,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); if ($this->plugin instanceof PluginFormInterface) { @@ -133,7 +134,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); if ($this->plugin instanceof PluginFormInterface) { @@ -145,7 +146,7 @@ public function submit(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $this->entity->save(); drupal_set_message($this->t('The action has been successfully saved.')); diff --git a/core/modules/action/src/Form/ActionAdminManageForm.php b/core/modules/action/src/Form/ActionAdminManageForm.php index fd1a0d0213eb8edfd16db6d62c6767e32dbbdba9..81c08f44c0f046abea0eee47c8c38c7909ee2ede 100644 --- a/core/modules/action/src/Form/ActionAdminManageForm.php +++ b/core/modules/action/src/Form/ActionAdminManageForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Form\FormBase; use Drupal\Component\Utility\Crypt; use Drupal\Core\Action\ActionManager; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -53,7 +54,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $actions = array(); foreach ($this->manager->getDefinitions() as $id => $definition) { if (is_subclass_of($definition['class'], '\Drupal\Core\Plugin\PluginFormInterface')) { @@ -87,7 +88,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state['values']['action']) { $form_state['redirect_route'] = array( 'route_name' => 'action.admin_add', diff --git a/core/modules/action/src/Form/ActionDeleteForm.php b/core/modules/action/src/Form/ActionDeleteForm.php index 1ca080af04c214c869739d0215478327aa33f2ab..a65d574fa05c59c63fadc90d2e218100a6e69606 100644 --- a/core/modules/action/src/Form/ActionDeleteForm.php +++ b/core/modules/action/src/Form/ActionDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\action\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -39,7 +40,7 @@ public function getCancelUrl() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/action/src/Plugin/Action/EmailAction.php b/core/modules/action/src/Plugin/Action/EmailAction.php index c6589a619f5be5c5ae98d8721f3159bdfbcee42d..a9a00a9337846dcd0e421f989459ce783cbf77e6 100644 --- a/core/modules/action/src/Plugin/Action/EmailAction.php +++ b/core/modules/action/src/Plugin/Action/EmailAction.php @@ -9,6 +9,7 @@ use Drupal\Core\Action\ConfigurableActionBase; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Utility\Token; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -114,7 +115,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['recipient'] = array( '#type' => 'textfield', '#title' => t('Recipient'), @@ -143,7 +144,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { if (!valid_email_address($form_state['values']['recipient']) && strpos($form_state['values']['recipient'], ':mail') === FALSE) { // We want the literal %author placeholder to be emphasized in the error message. form_set_error('recipient', $form_state, t('Enter a valid email address or use a token email address such as %author.', array('%author' => '[node:author:mail]'))); @@ -153,7 +154,7 @@ public function validateConfigurationForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['recipient'] = $form_state['values']['recipient']; $this->configuration['subject'] = $form_state['values']['subject']; $this->configuration['message'] = $form_state['values']['message']; diff --git a/core/modules/action/src/Plugin/Action/GotoAction.php b/core/modules/action/src/Plugin/Action/GotoAction.php index e08d91fbcb4f2d9c69579b47929f359a0b07ee6f..40ba6214bff1858a35c2d27ed0207099e9964cf3 100644 --- a/core/modules/action/src/Plugin/Action/GotoAction.php +++ b/core/modules/action/src/Plugin/Action/GotoAction.php @@ -8,6 +8,7 @@ namespace Drupal\action\Plugin\Action; use Drupal\Core\Action\ConfigurableActionBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -94,7 +95,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['url'] = array( '#type' => 'textfield', '#title' => t('URL'), @@ -108,7 +109,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['url'] = $form_state['values']['url']; } diff --git a/core/modules/action/src/Plugin/Action/MessageAction.php b/core/modules/action/src/Plugin/Action/MessageAction.php index cc156507732e2065a387296427defae0dfc3097e..ece48fa128f3e91dd3dee01292c4f9e5d1e56dc6 100644 --- a/core/modules/action/src/Plugin/Action/MessageAction.php +++ b/core/modules/action/src/Plugin/Action/MessageAction.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\Xss; use Drupal\Core\Action\ConfigurableActionBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Utility\Token; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -68,7 +69,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['message'] = array( '#type' => 'textarea', '#title' => t('Message'), @@ -83,7 +84,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['message'] = $form_state['values']['message']; unset($this->configuration['node']); } diff --git a/core/modules/aggregator/src/FeedForm.php b/core/modules/aggregator/src/FeedForm.php index e832d87018883d33dc65fa1ca96a0a989f65c43c..6d9d3ea2673f0e973bbb597e54ded403fd32e098 100644 --- a/core/modules/aggregator/src/FeedForm.php +++ b/core/modules/aggregator/src/FeedForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -21,7 +22,7 @@ class FeedForm extends ContentEntityForm { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $feed = $this->entity; // @todo: convert to a language selection widget defined in the base field. @@ -41,7 +42,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { $feed = $this->buildEntity($form, $form_state); // Check for duplicate titles. $feed_storage = $this->entityManager->getStorage('aggregator_feed'); @@ -60,7 +61,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $feed = $this->entity; $insert = (bool) $feed->id(); $feed->save(); diff --git a/core/modules/aggregator/src/Form/FeedDeleteForm.php b/core/modules/aggregator/src/Form/FeedDeleteForm.php index e7efd14561e2b15b4246891a7a490e3796d7ba24..83c171e4587a51da4fe3c22aff4f51895d50c7ff 100644 --- a/core/modules/aggregator/src/Form/FeedDeleteForm.php +++ b/core/modules/aggregator/src/Form/FeedDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\aggregator\Form; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -39,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/src/Form/FeedItemsDeleteForm.php b/core/modules/aggregator/src/Form/FeedItemsDeleteForm.php index 0da20f628183bd8e7d19a6563dd69d9a693baef7..2d79aa2cd07465a39483b779cb5144573c7fbf8a 100644 --- a/core/modules/aggregator/src/Form/FeedItemsDeleteForm.php +++ b/core/modules/aggregator/src/Form/FeedItemsDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\aggregator\Form; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -39,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->deleteItems(); $form_state['redirect_route'] = $this->getCancelUrl(); diff --git a/core/modules/aggregator/src/Form/OpmlFeedAdd.php b/core/modules/aggregator/src/Form/OpmlFeedAdd.php index 0613f48bd910e74b8c91da2aeaee5a4c0670fb70..3bed94fb4efd52bff252fdc04fb25d7a693883fa 100644 --- a/core/modules/aggregator/src/Form/OpmlFeedAdd.php +++ b/core/modules/aggregator/src/Form/OpmlFeedAdd.php @@ -10,6 +10,7 @@ use Drupal\aggregator\FeedStorageInterface; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\ClientInterface; @@ -66,7 +67,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200); $period = array_map(array(\Drupal::service('date'), 'formatInterval'), array_combine($intervals, $intervals)); @@ -101,7 +102,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // If both fields are empty or filled, cancel. $file_upload = $this->getRequest()->files->get('files[upload]', NULL, TRUE); if (empty($form_state['values']['remote']) == empty($file_upload)) { @@ -112,7 +113,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $validators = array('file_validate_extensions' => array('opml xml')); if ($file = file_save_upload('upload', $validators, FALSE, 0)) { $data = file_get_contents($file->getFileUri()); diff --git a/core/modules/aggregator/src/Form/SettingsForm.php b/core/modules/aggregator/src/Form/SettingsForm.php index 075b61439b669e7f3229bcfbbe0008b904cb7bc9..3177742abcfb3fd325537c5acd4c1dced1aec373 100644 --- a/core/modules/aggregator/src/Form/SettingsForm.php +++ b/core/modules/aggregator/src/Form/SettingsForm.php @@ -10,6 +10,7 @@ use Drupal\aggregator\Plugin\AggregatorPluginManager; use Drupal\Component\Utility\String; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Core\Form\ConfigFormBase; @@ -98,7 +99,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('aggregator.settings'); // Global aggregator settings. @@ -187,7 +188,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); // Let active plugins validate their settings. foreach ($this->configurableInstances as $instance) { @@ -198,7 +199,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $config = $this->config('aggregator.settings'); // Let active plugins save their settings. diff --git a/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php b/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php index ee94c7c5185e5dca679e069c5e26c66e76fbab14..eb6ad366828e8770371f96418f338ff1bf2a8265 100644 --- a/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php +++ b/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php @@ -8,6 +8,7 @@ namespace Drupal\aggregator\Plugin; use Drupal\Component\Plugin\ConfigurablePluginInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Plugin\PluginFormInterface; @@ -35,7 +36,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { } /** diff --git a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php index 039ccea16be01ccc2023dee0ef2d91a3eff4ce1b..38f47566ed5d07f703ad585a84a01f0dd73c2efb 100644 --- a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php +++ b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php @@ -12,6 +12,7 @@ use Drupal\aggregator\ItemStorageInterface; use Drupal\block\BlockBase; use Drupal\Core\Entity\Query\QueryInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Session\AccountInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -114,9 +115,9 @@ protected function blockAccess(AccountInterface $account) { } /** - * Overrides \Drupal\block\BlockBase::blockForm(). + * {@inheritdoc} */ - public function blockForm($form, &$form_state) { + public function blockForm($form, FormStateInterface $form_state) { $feeds = $this->feedStorage->loadMultiple(); $options = array(); foreach ($feeds as $feed) { @@ -139,9 +140,9 @@ public function blockForm($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::blockSubmit(). + * {@inheritdoc} */ - public function blockSubmit($form, &$form_state) { + public function blockSubmit($form, FormStateInterface $form_state) { $this->configuration['block_count'] = $form_state['values']['block_count']; $this->configuration['feed'] = $form_state['values']['feed']; } diff --git a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php index 5fe77b8fe6b27d3110939b4b83580e32a3866a1a..c97c04d7bc40b50e1bb5adf20a28063105aa4860 100644 --- a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php +++ b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php @@ -15,6 +15,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Datetime\Date as DateFormatter; use Drupal\Core\Entity\Query\QueryInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -105,7 +106,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $processors = $this->configuration['processors']; $info = $this->getPluginDefinition(); $counts = array(3, 5, 10, 15, 20, 25); @@ -161,7 +162,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['items']['expire'] = $form_state['values']['aggregator_clear']; $this->configuration['items']['teaser_length'] = $form_state['values']['aggregator_teaser_length']; $this->configuration['source']['list_max'] = $form_state['values']['aggregator_summary_items']; diff --git a/core/modules/aggregator/src/Plugin/views/field/TitleLink.php b/core/modules/aggregator/src/Plugin/views/field/TitleLink.php index 725b82dbbb4a62129473569ee354ac9b79139333..9ab50bf53c526a9e1a51ebb4e3fcc18f1d18e137 100644 --- a/core/modules/aggregator/src/Plugin/views/field/TitleLink.php +++ b/core/modules/aggregator/src/Plugin/views/field/TitleLink.php @@ -7,6 +7,7 @@ namespace Drupal\aggregator\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; @@ -45,7 +46,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['display_as_link'] = array( '#title' => t('Display as link'), '#type' => 'checkbox', diff --git a/core/modules/aggregator/src/Plugin/views/row/Rss.php b/core/modules/aggregator/src/Plugin/views/row/Rss.php index f9a73a6e897f4d1d90dee40b0584f12c2c13d5ee..ff59828a0303d63794947e13782a2e8adc19b551 100644 --- a/core/modules/aggregator/src/Plugin/views/row/Rss.php +++ b/core/modules/aggregator/src/Plugin/views/row/Rss.php @@ -7,6 +7,7 @@ namespace Drupal\aggregator\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\row\RowPluginBase; /** @@ -51,7 +52,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['view_mode'] = array( '#type' => 'select', '#title' => t('Display type'), diff --git a/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php b/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php index 9b76fc97f7c317342ef4bf07775ab9ab9d34a318..b4f5fd565bcb2f59970ee9994ae499ec44cc678f 100644 --- a/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php +++ b/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php @@ -11,6 +11,7 @@ use Drupal\aggregator\Plugin\ProcessorInterface; use Drupal\aggregator\FeedInterface; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -66,7 +67,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $processors = $this->configFactory->get('aggregator.settings')->get('processors'); $info = $this->getPluginDefinition(); @@ -90,7 +91,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['items']['dummy_length'] = $form_state['values']['dummy_length']; $this->setConfiguration($this->configuration); } diff --git a/core/modules/aggregator/tests/src/Plugin/AggregatorPluginSettingsBaseTest.php b/core/modules/aggregator/tests/src/Plugin/AggregatorPluginSettingsBaseTest.php index b9390ffc8f0a9f652fcd89135411973cbeb99d67..90a4b690580d5a6236b7ed3a6414d77d5a2a59e1 100644 --- a/core/modules/aggregator/tests/src/Plugin/AggregatorPluginSettingsBaseTest.php +++ b/core/modules/aggregator/tests/src/Plugin/AggregatorPluginSettingsBaseTest.php @@ -8,6 +8,7 @@ namespace Drupal\aggregator\Tests\Plugin { use Drupal\aggregator\Form\SettingsForm; +use Drupal\Core\Form\FormState; use Drupal\Tests\UnitTestCase; /** @@ -73,7 +74,7 @@ public function setUp() { */ public function testSettingsForm() { // Emulate a form state of a sumbitted form. - $form_state = array('values' => array('dummy_length' => '', 'aggregator_allowed_html_tags' => '')); + $form_state = new FormState(array('values' => array('dummy_length' => '', 'aggregator_allowed_html_tags' => ''))); $test_processor = $this->getMock( 'Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor', diff --git a/core/modules/ban/src/Form/BanAdmin.php b/core/modules/ban/src/Form/BanAdmin.php index 3675e0928abeaa7a34c29ca8f9aca6d2bb55a910..bd87ba87203e71cd826330b5ab274085a1156fb3 100644 --- a/core/modules/ban/src/Form/BanAdmin.php +++ b/core/modules/ban/src/Form/BanAdmin.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\FormBase; use Drupal\ban\BanIpManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -54,7 +55,7 @@ public function getFormId() { * \Drupal::formBuilder()->getForm() for use as the default value of the IP * address form field. */ - public function buildForm(array $form, array &$form_state, $default_ip = '') { + public function buildForm(array $form, FormStateInterface $form_state, $default_ip = '') { $rows = array(); $header = array($this->t('banned IP addresses'), $this->t('Operations')); $result = $this->ipManager->findAll(); @@ -103,7 +104,7 @@ public function buildForm(array $form, array &$form_state, $default_ip = '') { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $ip = trim($form_state['values']['ip']); if ($this->ipManager->isBanned($ip)) { $this->setFormError('ip', $form_state, $this->t('This IP address is already banned.')); @@ -119,7 +120,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $ip = trim($form_state['values']['ip']); $this->ipManager->banIp($ip); drupal_set_message($this->t('The IP address %ip has been banned.', array('%ip' => $ip))); diff --git a/core/modules/ban/src/Form/BanDelete.php b/core/modules/ban/src/Form/BanDelete.php index 1e414392bd83158bb9f47c843c9cbdc4e6b2d9e1..b607ba92cc0d766ff922f464aa29c5a0b93ce7b6 100644 --- a/core/modules/ban/src/Form/BanDelete.php +++ b/core/modules/ban/src/Form/BanDelete.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\ban\BanIpManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -78,7 +79,7 @@ public function getCancelUrl() { * @param string $ban_id * The IP address record ID to unban. */ - public function buildForm(array $form, array &$form_state, $ban_id = '') { + public function buildForm(array $form, FormStateInterface $form_state, $ban_id = '') { if (!$this->banIp = $this->ipManager->findById($ban_id)) { throw new NotFoundHttpException(); } @@ -88,7 +89,7 @@ public function buildForm(array $form, array &$form_state, $ban_id = '') { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->ipManager->unbanIp($this->banIp); watchdog('user', 'Deleted %ip', array('%ip' => $this->banIp)); drupal_set_message($this->t('The IP address %ip was deleted.', array('%ip' => $this->banIp))); diff --git a/core/modules/block/src/BlockBase.php b/core/modules/block/src/BlockBase.php index 70e83e8fb26c1dbcd6f23e697d7d52a06e69752f..ca94ba075845bf56293cefbc54b40104f75e61db 100644 --- a/core/modules/block/src/BlockBase.php +++ b/core/modules/block/src/BlockBase.php @@ -12,6 +12,8 @@ use Drupal\Component\Plugin\ContextAwarePluginInterface; use Drupal\Core\Condition\ConditionAccessResolverTrait; use Drupal\Core\Condition\ConditionPluginBag; +use Drupal\Core\Form\FormState; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContextAwarePluginBase; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\NestedArray; @@ -198,7 +200,7 @@ protected function blockAccess(AccountInterface $account) { * * @see \Drupal\block\BlockBase::blockForm() */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $definition = $this->getPluginDefinition(); $form['provider'] = array( '#type' => 'value', @@ -323,7 +325,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function blockForm($form, &$form_state) { + public function blockForm($form, FormStateInterface $form_state) { return array(); } @@ -335,7 +337,7 @@ public function blockForm($form, &$form_state) { * * @see \Drupal\block\BlockBase::blockValidate() */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { // Remove the admin_label form item element value so it will not persist. unset($form_state['values']['admin_label']); @@ -344,10 +346,12 @@ public function validateConfigurationForm(array &$form, array &$form_state) { foreach ($this->getVisibilityConditions() as $condition_id => $condition) { // Allow the condition to validate the form. - $condition_values = array( - 'values' => &$form_state['values']['visibility'][$condition_id], - ); + $condition_values = new FormState(array( + 'values' => $form_state['values']['visibility'][$condition_id], + )); $condition->validateConfigurationForm($form, $condition_values); + // Update the original form values. + $form_state['values']['visibility'][$condition_id] = $condition_values['values']; } $this->blockValidate($form, $form_state); @@ -356,7 +360,7 @@ public function validateConfigurationForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function blockValidate($form, &$form_state) {} + public function blockValidate($form, FormStateInterface $form_state) {} /** * {@inheritdoc} @@ -366,7 +370,7 @@ public function blockValidate($form, &$form_state) {} * * @see \Drupal\block\BlockBase::blockSubmit() */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { // Process the block's submission handling if no errors occurred only. if (!form_get_errors($form_state)) { $this->configuration['label'] = $form_state['values']['label']; @@ -375,10 +379,12 @@ public function submitConfigurationForm(array &$form, array &$form_state) { $this->configuration['cache'] = $form_state['values']['cache']; foreach ($this->getVisibilityConditions() as $condition_id => $condition) { // Allow the condition to submit the form. - $condition_values = array( - 'values' => &$form_state['values']['visibility'][$condition_id], - ); + $condition_values = new FormState(array( + 'values' => $form_state['values']['visibility'][$condition_id], + )); $condition->submitConfigurationForm($form, $condition_values); + // Update the original form values. + $form_state['values']['visibility'][$condition_id] = $condition_values['values']; } $this->blockSubmit($form, $form_state); } @@ -387,7 +393,7 @@ public function submitConfigurationForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function blockSubmit($form, &$form_state) {} + public function blockSubmit($form, FormStateInterface $form_state) {} /** * {@inheritdoc} diff --git a/core/modules/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php index f562f52cb213feb66494538838a4f947b34aab1a..704f3d1a8acf75f9c4d3c7b7d64989549beffd0b 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -9,6 +9,8 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormState; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -52,7 +54,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $entity = $this->entity; // Store theme settings in $form_state for use below. @@ -125,7 +127,7 @@ public function form(array $form, array &$form_state) { /** * Handles switching the available regions based on the selected theme. */ - public function themeSwitch($form, &$form_state) { + public function themeSwitch($form, FormStateInterface $form_state) { $form['region']['#options'] = system_region_list($form_state['values']['theme'], REGIONS_VISIBLE); return $form['region']; } @@ -133,7 +135,7 @@ public function themeSwitch($form, &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = $this->t('Save block'); return $actions; @@ -142,35 +144,38 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); // The Block Entity form puts all block plugin form elements in the // settings form element, so just pass that to the block for validation. - $settings = array( - 'values' => &$form_state['values']['settings'] - ); + $settings = new FormState(array( + 'values' => $form_state['values']['settings'] + )); // Call the plugin validate handler. $this->entity->getPlugin()->validateConfigurationForm($form, $settings); + // Update the original form values. + $form_state['values']['settings'] = $settings['values']; } /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); $entity = $this->entity; // The Block Entity form puts all block plugin form elements in the // settings form element, so just pass that to the block for submission. // @todo Find a way to avoid this manipulation. - $settings = array( - 'values' => &$form_state['values']['settings'], - 'errors' => $form_state['errors'], - ); + $settings = new FormState(array( + 'values' => $form_state['values']['settings'], + )); // Call the plugin submit handler. $entity->getPlugin()->submitConfigurationForm($form, $settings); + // Update the original form values. + $form_state['values']['settings'] = $settings['values']; // Save the settings of the plugin. $entity->save(); diff --git a/core/modules/block/src/BlockListBuilder.php b/core/modules/block/src/BlockListBuilder.php index 1bf034d5887919f33eb6da5bd1f7e60ff4bb16bd..1b26b9fcd5a4b3cf5c6378b87993ab569e9fe7de 100644 --- a/core/modules/block/src/BlockListBuilder.php +++ b/core/modules/block/src/BlockListBuilder.php @@ -15,6 +15,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -133,7 +134,7 @@ public function getFormId() { * * Form constructor for the main block administration form. */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $placement = FALSE; if ($this->request->query->has('block-placement')) { $placement = $this->request->query->get('block-placement'); @@ -388,7 +389,7 @@ public function getDefaultOperations(EntityInterface $entity) { /** * Implements \Drupal\Core\Form\FormInterface::validateForm(). */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // No validation. } @@ -397,7 +398,7 @@ public function validateForm(array &$form, array &$form_state) { * * Form submission handler for the main block administration form. */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $entities = entity_load_multiple('block', array_keys($form_state['values']['blocks'])); foreach ($entities as $entity_id => $entity) { $entity->set('weight', $form_state['values']['blocks'][$entity_id]['weight']); diff --git a/core/modules/block/src/BlockPluginInterface.php b/core/modules/block/src/BlockPluginInterface.php index f1a94caf1d434db44694dfaaf00311ce68e5e40b..05d0ce59359f3b519c6fe6cd372d13287a1f3bac 100644 --- a/core/modules/block/src/BlockPluginInterface.php +++ b/core/modules/block/src/BlockPluginInterface.php @@ -12,6 +12,7 @@ use Drupal\Core\Cache\CacheableInterface; use Drupal\Component\Plugin\PluginInspectionInterface; use Drupal\Component\Plugin\ConfigurablePluginInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\Session\AccountInterface; @@ -88,47 +89,47 @@ public function setConfigurationValue($key, $value); * * @param array $form * The form definition array for the block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array $form * The renderable form array representing the entire configuration form. */ - public function blockForm($form, &$form_state); + public function blockForm($form, FormStateInterface $form_state); /** * Adds block type-specific validation for the block form. * - * Note that this method takes the form structure and form state arrays for - * the full block configuration form as arguments, not just the elements - * defined in BlockPluginInterface::blockForm(). + * Note that this method takes the form structure and form state for the full + * block configuration form as arguments, not just the elements defined in + * BlockPluginInterface::blockForm(). * * @param array $form * The form definition array for the full block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @see \Drupal\block\BlockPluginInterface::blockForm() * @see \Drupal\block\BlockPluginInterface::blockSubmit() */ - public function blockValidate($form, &$form_state); + public function blockValidate($form, FormStateInterface $form_state); /** * Adds block type-specific submission handling for the block form. * - * Note that this method takes the form structure and form state arrays for - * the full block configuration form as arguments, not just the elements - * defined in BlockPluginInterface::blockForm(). + * Note that this method takes the form structure and form state for the full + * block configuration form as arguments, not just the elements defined in + * BlockPluginInterface::blockForm(). * * @param array $form * The form definition array for the full block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @see \Drupal\block\BlockPluginInterface::blockForm() * @see \Drupal\block\BlockPluginInterface::blockValidate() */ - public function blockSubmit($form, &$form_state); + public function blockSubmit($form, FormStateInterface $form_state); /** * Suggests a machine name to identify an instance of this block. diff --git a/core/modules/block/src/Form/BlockDeleteForm.php b/core/modules/block/src/Form/BlockDeleteForm.php index 336888f2bac91985e894bda0b1c32a7ee71e548d..d8112476d7b95c2e558596d646a1db604da86d7c 100644 --- a/core/modules/block/src/Form/BlockDeleteForm.php +++ b/core/modules/block/src/Form/BlockDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\block\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -39,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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'] = $this->getCancelUrl(); diff --git a/core/modules/block/src/Plugin/views/display/Block.php b/core/modules/block/src/Plugin/views/display/Block.php index 9ee2ca98a10a19b83b43c690545d99205a30f74c..0e2e968f2fe31ea291f50a024641356b6f99eb9d 100644 --- a/core/modules/block/src/Plugin/views/display/Block.php +++ b/core/modules/block/src/Plugin/views/display/Block.php @@ -9,6 +9,7 @@ namespace Drupal\block\Plugin\views\display; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\Block\ViewsBlock; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Views; @@ -140,7 +141,7 @@ public function optionsSummary(&$categories, &$options) { /** * Provide the default form for setting options. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); switch ($form_state['section']) { @@ -201,7 +202,7 @@ public function buildOptionsForm(&$form, &$form_state) { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { parent::submitOptionsForm($form, $form_state); switch ($form_state['section']) { case 'block_description': @@ -222,15 +223,15 @@ public function submitOptionsForm(&$form, &$form_state) { * The ViewsBlock plugin. * @param array $form * The form definition array for the block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array $form * The renderable form array representing the entire configuration form. * * @see \Drupal\views\Plugin\Block\ViewsBlock::blockForm() */ - public function blockForm(ViewsBlock $block, array &$form, array &$form_state) { + public function blockForm(ViewsBlock $block, array &$form, FormStateInterface $form_state) { $allow_settings = array_filter($this->getOption('allow')); $block_configuration = $block->getConfiguration(); @@ -267,12 +268,12 @@ public function blockForm(ViewsBlock $block, array &$form, array &$form_state) { * The ViewsBlock plugin. * @param array $form * The form definition array for the block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @see \Drupal\views\Plugin\Block\ViewsBlock::blockValidate() */ - public function blockValidate(ViewsBlock $block, array $form, array &$form_state) { + public function blockValidate(ViewsBlock $block, array $form, FormStateInterface $form_state) { } /** @@ -282,12 +283,12 @@ public function blockValidate(ViewsBlock $block, array $form, array &$form_state * The ViewsBlock plugin. * @param array $form * The form definition array for the full block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * * @see \Drupal\views\Plugin\Block\ViewsBlock::blockSubmit() */ - public function blockSubmit(ViewsBlock $block, $form, &$form_state) { + public function blockSubmit(ViewsBlock $block, $form, FormStateInterface $form_state) { if (isset($form_state['values']['override']['items_per_page'])) { $block->setConfigurationValue('items_per_page', $form_state['values']['override']['items_per_page']); } diff --git a/core/modules/block/src/Tests/BlockInterfaceTest.php b/core/modules/block/src/Tests/BlockInterfaceTest.php index bd4c55cd1c3cb68b2cba0e2210a4058433e4801f..29097e55d471b3f9a9597a30dc14bf01d9c165b2 100644 --- a/core/modules/block/src/Tests/BlockInterfaceTest.php +++ b/core/modules/block/src/Tests/BlockInterfaceTest.php @@ -7,6 +7,7 @@ namespace Drupal\block\Tests; +use Drupal\Core\Form\FormState; use Drupal\simpletest\DrupalUnitTestBase; use Drupal\block\BlockInterface; @@ -118,7 +119,7 @@ public function testBlockInterface() { '#default_value' => 'My custom display message.', ), ); - $form_state = array(); + $form_state = new FormState(); // Ensure there are no form elements that do not belong to the plugin. $actual_form = $display_block->buildConfigurationForm(array(), $form_state); // Remove the visibility sections, as that just tests condition plugins. diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php index 9a4db70323472be62341d1811fbe9ac43c798865..255ba63efed1917971ba413f5278f5e5c350f6e3 100644 --- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php +++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php @@ -8,6 +8,7 @@ namespace Drupal\block_test\Plugin\Block; use Drupal\block\BlockBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; /** @@ -39,7 +40,7 @@ protected function blockAccess(AccountInterface $account) { /** * {@inheritdoc} */ - public function blockForm($form, &$form_state) { + public function blockForm($form, FormStateInterface $form_state) { $form['display_message'] = array( '#type' => 'textfield', '#title' => t('Display message'), @@ -51,7 +52,7 @@ public function blockForm($form, &$form_state) { /** * {@inheritdoc} */ - public function blockSubmit($form, &$form_state) { + public function blockSubmit($form, FormStateInterface $form_state) { $this->configuration['display_message'] = $form_state['values']['display_message']; } diff --git a/core/modules/block_content/src/BlockContentForm.php b/core/modules/block_content/src/BlockContentForm.php index 22ef45bc7e1c266d5e8e5534c55b76cbdb57d380..1524f4241e9203d5dd40341b10283f972d420883 100644 --- a/core/modules/block_content/src/BlockContentForm.php +++ b/core/modules/block_content/src/BlockContentForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -83,7 +84,7 @@ protected function prepareEntity() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $block = $this->entity; $account = $this->currentUser(); @@ -174,7 +175,7 @@ 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) { + public function submit(array $form, FormStateInterface $form_state) { // Build the block object from the submitted values. $block = parent::submit($form, $form_state); @@ -189,7 +190,7 @@ public function submit(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $block = $this->entity; $insert = $block->isNew(); $block->save(); @@ -236,7 +237,7 @@ public function save(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { if ($this->entity->isNew()) { $exists = $this->blockContentStorage->loadByProperties(array('info' => $form_state['values']['info'])); if (!empty($exists)) { diff --git a/core/modules/block_content/src/BlockContentTranslationHandler.php b/core/modules/block_content/src/BlockContentTranslationHandler.php index 148e2491b9def9e012ba65858d60ecc6e4b6d4cf..ca7a6d905fe9aee231a590151ffc45b4424309f7 100644 --- a/core/modules/block_content/src/BlockContentTranslationHandler.php +++ b/core/modules/block_content/src/BlockContentTranslationHandler.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\content_translation\ContentTranslationHandler; +use Drupal\Core\Form\FormStateInterface; /** * Defines the translation handler for custom blocks. @@ -18,7 +19,7 @@ class BlockContentTranslationHandler extends ContentTranslationHandler { /** * {@inheritdoc} */ - public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { + public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) { parent::entityFormAlter($form, $form_state, $entity); // Move the translation fieldset to a vertical tab. if (isset($form['translation'])) { diff --git a/core/modules/block_content/src/BlockContentTypeForm.php b/core/modules/block_content/src/BlockContentTypeForm.php index e64bfa3cf66ea67f3f96500e31bb45a71c8e62a8..025d673a6d56f4ddc1ae6d3d89ce428491a9d716 100644 --- a/core/modules/block_content/src/BlockContentTypeForm.php +++ b/core/modules/block_content/src/BlockContentTypeForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Form\FormStateInterface; /** * Base form for category edit forms. @@ -16,9 +17,9 @@ class BlockContentTypeForm extends EntityForm { /** - * Overrides \Drupal\Core\Entity\EntityForm::form(). + * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $block_type = $this->entity; @@ -87,7 +88,7 @@ public function form(array $form, array &$form_state) { /** * Overrides \Drupal\Core\Entity\EntityForm::save(). */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $block_type = $this->entity; $status = $block_type->save(); diff --git a/core/modules/block_content/src/Form/BlockContentDeleteForm.php b/core/modules/block_content/src/Form/BlockContentDeleteForm.php index 6367c87b5d04b1588d0ab127267eed2da3727ca1..88249ae28656550090588d1fc0f8c4e86d002bae 100644 --- a/core/modules/block_content/src/Form/BlockContentDeleteForm.php +++ b/core/modules/block_content/src/Form/BlockContentDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\block_content\Form; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -39,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $instances = $this->entity->getInstances(); $form['message'] = array( @@ -53,7 +54,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); drupal_set_message($this->t('Custom block %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('block_content', 'Custom block %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); diff --git a/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php b/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php index c4ef05a15917c5550cf38f221b2bce155d3913da..decda49dc235a7fefcf8a557638f40d9da6ab05a 100644 --- a/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php +++ b/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -67,7 +68,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $blocks = $this->queryFactory->get('block_content')->condition('type', $this->entity->id())->execute(); if (!empty($blocks)) { $caption = '

' . format_plural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $this->entity->label())) . '

'; @@ -82,7 +83,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); drupal_set_message(t('Custom block type %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('block_content', 'Custom block type %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); diff --git a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php index 49a53dc91a8d8e091a4ce0b305803fcaa91d53c7..8a5a4091001fc4883fbd16c5c2abd04eeddef121 100644 --- a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php +++ b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php @@ -11,6 +11,7 @@ use Drupal\block\BlockManagerInterface; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Session\AccountInterface; @@ -120,7 +121,7 @@ public function defaultConfiguration() { * * Adds body and description fields to the block configuration form. */ - public function blockForm($form, &$form_state) { + public function blockForm($form, FormStateInterface $form_state) { $form['block_content']['view_mode'] = array( '#type' => 'select', '#options' => $this->entityManager->getViewModeOptions('block_content'), @@ -133,9 +134,9 @@ public function blockForm($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::blockSubmit(). + * {@inheritdoc} */ - public function blockSubmit($form, &$form_state) { + public function blockSubmit($form, FormStateInterface $form_state) { // Invalidate the block cache to update custom block-based derivatives. if ($this->moduleHandler->moduleExists('block')) { $this->configuration['view_mode'] = $form_state['values']['block_content']['view_mode']; diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 1177ebeabb10d0179a1a2e2294d791a7157158fb..c791b68c49e4f8b6b20422af422165d445b0a92f 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -9,6 +9,7 @@ use Drupal\book\BookManagerInterface; use Drupal\Component\Utility\String; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\node\NodeInterface; @@ -159,7 +160,7 @@ function book_node_links_alter(array &$node_links, NodeInterface $node, array &$ * * @see book_pick_book_nojs_submit() */ -function book_form_node_form_alter(&$form, &$form_state, $form_id) { +function book_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) { $node = $form_state['controller']->getEntity(); $account = \Drupal::currentUser(); $access = $account->hasPermission('administer book outlines'); @@ -194,7 +195,7 @@ function book_form_node_form_alter(&$form, &$form_state, $form_id) { * * @todo: Remove this in favor of an entity field. */ -function book_node_builder($entity_type, NodeInterface $entity, &$form, &$form_state) { +function book_node_builder($entity_type, NodeInterface $entity, &$form, FormStateInterface $form_state) { $entity->book = $form_state['values']['book']; // Always save a revision for non-administrators. @@ -215,7 +216,7 @@ function book_node_builder($entity_type, NodeInterface $entity, &$form, &$form_s * @see book_form_update() * @see book_form_node_form_alter() */ -function book_pick_book_nojs_submit($form, &$form_state) { +function book_pick_book_nojs_submit($form, FormStateInterface $form_state) { $node = $form_state['controller']->getEntity(); $node->book = $form_state['values']['book']; $form_state['rebuild'] = TRUE; @@ -310,7 +311,7 @@ function book_node_predelete(EntityInterface $node) { /** * Implements hook_node_prepare_form(). */ -function book_node_prepare_form(NodeInterface $node, $operation, array &$form_state) { +function book_node_prepare_form(NodeInterface $node, $operation, FormStateInterface $form_state) { /** @var \Drupal\book\BookManagerInterface $book_manager */ $book_manager = \Drupal::service('book.manager'); diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index c491cf475ec06921dc385b0e650552b9e32f2d05..45f9adf2c9cb1d2c6a208a5a9f072854471c1253 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -11,6 +11,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -168,7 +169,7 @@ protected function findChildrenRelativeDepth(array $book_link) { /** * {@inheritdoc} */ - public function addFormElements(array $form, array &$form_state, NodeInterface $node, AccountInterface $account, $collapsed = TRUE) { + public function addFormElements(array $form, FormStateInterface $form_state, NodeInterface $node, AccountInterface $account, $collapsed = TRUE) { // If the form is being processed during the Ajax callback of our book bid // dropdown, then $form_state will hold the value that was selected. if (isset($form_state['values']['book'])) { diff --git a/core/modules/book/src/BookManagerInterface.php b/core/modules/book/src/BookManagerInterface.php index 81dfe080d0efdb006c140ffd8c77b536d1737103..72ca61ea82a44e61addfa92b11d38ed7fb0dc41b 100644 --- a/core/modules/book/src/BookManagerInterface.php +++ b/core/modules/book/src/BookManagerInterface.php @@ -7,6 +7,7 @@ namespace Drupal\book; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\node\NodeInterface; @@ -203,8 +204,8 @@ public function getBookParents(array $item, array $parent = array()); * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param \Drupal\node\NodeInterface $node * The node whose form is being viewed. * @param \Drupal\Core\Session\AccountInterface $account @@ -215,7 +216,7 @@ public function getBookParents(array $item, array $parent = array()); * @return array * The form structure, with the book elements added. */ - public function addFormElements(array $form, array &$form_state, NodeInterface $node, AccountInterface $account, $collapsed = TRUE); + public function addFormElements(array $form, FormStateInterface $form_state, NodeInterface $node, AccountInterface $account, $collapsed = TRUE); /** * Deletes node's entry from book table. diff --git a/core/modules/book/src/Form/BookAdminEditForm.php b/core/modules/book/src/Form/BookAdminEditForm.php index f52c2e4c1633cc16bc9fffdd2a23675710cacf2a..9a342f086fa694b13fb886cfa1c79f67975f75f4 100644 --- a/core/modules/book/src/Form/BookAdminEditForm.php +++ b/core/modules/book/src/Form/BookAdminEditForm.php @@ -11,6 +11,7 @@ use Drupal\Component\Utility\Crypt; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -68,7 +69,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, NodeInterface $node = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL) { $form['#title'] = $node->label(); $form['#node'] = $node; $this->bookAdminTable($node, $form); @@ -83,7 +84,7 @@ public function buildForm(array $form, array &$form_state, NodeInterface $node = /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { if ($form_state['values']['tree_hash'] != $form_state['values']['tree_current_hash']) { $this->setFormError('', $form_state, $this->t('This book has been modified by another user, the changes could not be saved.')); } @@ -92,7 +93,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Save elements in the same order as defined in post rather than the form. // This ensures parents are updated before their children, preventing orphans. $order = array_flip(array_keys($form_state['input']['table'])); diff --git a/core/modules/book/src/Form/BookOutlineForm.php b/core/modules/book/src/Form/BookOutlineForm.php index f4a97a185380aacfff1466755908c18aaf6a2157..82a07aadc3e2a5d9d7f5b6ec8a185bcaeae86be7 100644 --- a/core/modules/book/src/Form/BookOutlineForm.php +++ b/core/modules/book/src/Form/BookOutlineForm.php @@ -10,6 +10,7 @@ use Drupal\book\BookManagerInterface; use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -64,7 +65,7 @@ public function getBaseFormID() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form['#title'] = $this->entity->label(); if (!isset($this->entity->book)) { @@ -87,7 +88,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = $this->entity->book['original_bid'] ? $this->t('Update book outline') : $this->t('Add to book outline'); $actions['delete']['#value'] = $this->t('Remove from book outline'); @@ -100,7 +101,7 @@ protected function actions(array $form, array &$form_state) { * * @see book_remove_button_submit() */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $form_state['redirect_route'] = array( 'route_name' => 'node.view', 'route_parameters' => array( @@ -132,7 +133,7 @@ public function submit(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function delete(array $form, array &$form_state) { + public function delete(array $form, FormStateInterface $form_state) { $form_state['redirect_route'] = $this->entity->urlInfo('book-remove-form'); } diff --git a/core/modules/book/src/Form/BookRemoveForm.php b/core/modules/book/src/Form/BookRemoveForm.php index b24bc511ab5c99d42ee25c92f01a18119e9ee76f..8ea734292f30c753b765464b44bc04623e98ebed 100644 --- a/core/modules/book/src/Form/BookRemoveForm.php +++ b/core/modules/book/src/Form/BookRemoveForm.php @@ -9,6 +9,7 @@ use Drupal\book\BookManagerInterface; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -61,7 +62,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, NodeInterface $node = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL) { $this->node = $node; return parent::buildForm($form, $form_state); } @@ -103,7 +104,7 @@ public function getCancelUrl() { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { if ($this->bookManager->checkNodeIsRemovable($this->node)) { $this->bookManager->deleteFromBook($this->node->id()); drupal_set_message($this->t('The post has been removed from the book.')); diff --git a/core/modules/book/src/Form/BookSettingsForm.php b/core/modules/book/src/Form/BookSettingsForm.php index 140f8e55be08f0d1c1e7e5619a764ac690ba4d5f..4a7535e5391020de9646b104c94eeb1ca1a8f1de 100644 --- a/core/modules/book/src/Form/BookSettingsForm.php +++ b/core/modules/book/src/Form/BookSettingsForm.php @@ -8,6 +8,7 @@ namespace Drupal\book\Form; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Configure book settings for this site. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $types = node_type_get_names(); $config = $this->config('book.settings'); $form['book_allowed_types'] = array( @@ -50,7 +51,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $child_type = $form_state['values']['book_child_type']; if (empty($form_state['values']['book_allowed_types'][$child_type])) { $this->setFormError('book_child_type', $form_state, $this->t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => $this->t('Add child page')))); @@ -62,7 +63,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $allowed_types = array_filter($form_state['values']['book_allowed_types']); // We need to save the allowed types in an array ordered by machine_name so // that we can save them in the correct order if node type changes. diff --git a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php index 5e85d9973c3b25cbf71d36caa265b940a28a5570..51d0a0d71d7f026734faaa388fe98182ec96c645 100644 --- a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php +++ b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php @@ -9,6 +9,7 @@ use Drupal\block\BlockBase; use Drupal\book\BookManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RequestStack; @@ -82,9 +83,9 @@ public function defaultConfiguration() { } /** - * Overrides \Drupal\block\BlockBase::blockForm() + * {@inheritdoc} */ - function blockForm($form, &$form_state) { + function blockForm($form, FormStateInterface $form_state) { $options = array( 'all pages' => t('Show block on all pages'), 'book pages' => t('Show block only on book pages'), @@ -101,9 +102,9 @@ function blockForm($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::blockSubmit(). + * {@inheritdoc} */ - public function blockSubmit($form, &$form_state) { + public function blockSubmit($form, FormStateInterface $form_state) { $this->configuration['block_mode'] = $form_state['values']['book_block_mode']; } diff --git a/core/modules/ckeditor/src/CKEditorPluginConfigurableInterface.php b/core/modules/ckeditor/src/CKEditorPluginConfigurableInterface.php index 619eb5163623264a36ced615fefe62cbdc50030c..a5084fdf5c99491f4b4e6051b6ff7a7be8dfef7f 100644 --- a/core/modules/ckeditor/src/CKEditorPluginConfigurableInterface.php +++ b/core/modules/ckeditor/src/CKEditorPluginConfigurableInterface.php @@ -7,6 +7,7 @@ namespace Drupal\ckeditor; +use Drupal\Core\Form\FormStateInterface; use Drupal\editor\Entity\Editor; /** @@ -36,7 +37,7 @@ interface CKEditorPluginConfigurableInterface extends CKEditorPluginInterface { * * @param array $form * An empty form array to be populated with a configuration form, if any. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The state of the entire filter administration form. * @param \Drupal\editor\Entity\Editor $editor * A configured text editor object. @@ -44,6 +45,6 @@ interface CKEditorPluginConfigurableInterface extends CKEditorPluginInterface { * @return array|FALSE * A render array for the settings form, or FALSE if there is none. */ - public function settingsForm(array $form, array &$form_state, Editor $editor); + public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor); } diff --git a/core/modules/ckeditor/src/CKEditorPluginManager.php b/core/modules/ckeditor/src/CKEditorPluginManager.php index dab891d704cea8626973081a6dc83e1a04d3053e..289c906be2f83a534685b907cc94fd545649318a 100644 --- a/core/modules/ckeditor/src/CKEditorPluginManager.php +++ b/core/modules/ckeditor/src/CKEditorPluginManager.php @@ -8,6 +8,7 @@ namespace Drupal\ckeditor; use Drupal\Component\Utility\NestedArray; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; @@ -147,12 +148,12 @@ public function getButtons() { * * @param array &$form * A reference to 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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param \Drupal\editor\Entity\Editor $editor * A configured text editor object. */ - public function injectPluginSettingsForm(array &$form, array &$form_state, Editor $editor) { + public function injectPluginSettingsForm(array &$form, FormStateInterface $form_state, Editor $editor) { $definitions = $this->getDefinitions(); foreach (array_keys($definitions) as $plugin_id) { diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php index d9f411c5a0c176cc804a673ca6e2e474fb2b53a2..4a1329cca9c3920032567a5f125c44556d27c019 100644 --- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php +++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php @@ -9,6 +9,7 @@ use Drupal\ckeditor\CKEditorPluginBase; use Drupal\ckeditor\CKEditorPluginConfigurableInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\editor\Entity\Editor; /** @@ -66,7 +67,7 @@ public function getButtons() { * @see \Drupal\editor\Form\EditorImageDialog * @see editor_image_upload_settings_form() */ - public function settingsForm(array $form, array &$form_state, Editor $editor) { + public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) { form_load_include($form_state, 'inc', 'editor', 'editor.admin'); $form['image_upload'] = editor_image_upload_settings_form($editor); $form['image_upload']['#attached']['library'][] = 'ckeditor/drupal.ckeditor.drupalimage.admin'; @@ -83,7 +84,7 @@ public function settingsForm(array $form, array &$form_state, Editor $editor) { * @see \Drupal\editor\Form\EditorImageDialog * @see editor_image_upload_settings_form() */ - function validateImageUploadSettings(array $element, array &$form_state) { + function validateImageUploadSettings(array $element, FormStateInterface $form_state) { $settings = &$form_state['values']['editor']['settings']['plugins']['drupalimage']['image_upload']; $form_state['editor']->setImageUploadSettings($settings); unset($form_state['values']['editor']['settings']['plugins']['drupalimage']); diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php index 2184cf2a116e287ae12e3014eb807bd68a9d74aa..963436df361724cd39e5db9c66f41de9807452a5 100644 --- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php +++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php @@ -10,6 +10,7 @@ use Drupal\ckeditor\CKEditorPluginBase; use Drupal\ckeditor\CKEditorPluginConfigurableInterface; use Drupal\Component\Utility\NestedArray; +use Drupal\Core\Form\FormStateInterface; use Drupal\editor\Entity\Editor; /** @@ -66,7 +67,7 @@ public function getButtons() { /** * Implements \Drupal\ckeditor\Plugin\CKEditorPluginConfigurableInterface::settingsForm(). */ - public function settingsForm(array $form, array &$form_state, Editor $editor) { + public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) { // Defaults. $config = array('styles' => ''); $settings = $editor->getSettings(); @@ -94,7 +95,7 @@ public function settingsForm(array $form, array &$form_state, Editor $editor) { /** * #element_validate handler for the "styles" element in settingsForm(). */ - public function validateStylesValue(array $element, array &$form_state) { + public function validateStylesValue(array $element, FormStateInterface $form_state) { if ($this->generateStylesSetSetting($element['#value']) === FALSE) { form_error($element, $form_state, t('The provided list of styles is syntactically incorrect.')); } diff --git a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php index d538b60a6b049af344b52723dfa48d8c0ef5bd8e..b377f73b9bc8271f49fa0343813969d6c0e04efc 100644 --- a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php @@ -10,6 +10,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\ckeditor\CKEditorPluginManager; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManager; use Drupal\Core\Render\Element; use Drupal\editor\Plugin\EditorBase; @@ -127,7 +128,7 @@ public function getDefaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, EditorEntity $editor) { + public function settingsForm(array $form, FormStateInterface $form_state, EditorEntity $editor) { $settings = $editor->getSettings(); $ckeditor_settings_toolbar = array( @@ -234,7 +235,7 @@ public function settingsForm(array $form, array &$form_state, EditorEntity $edit /** * {@inheritdoc} */ - public function settingsFormSubmit(array $form, array &$form_state) { + public function settingsFormSubmit(array $form, FormStateInterface $form_state) { // Modify the toolbar settings by reference. The values in // $form_state['values']['editor']['settings'] will be saved directly by // editor_form_filter_admin_format_submit(). diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php index 171e3b3d384c5dbcee5713f7ba156ef85bb18a2e..4c43cb754c966d8be80737bf552ade44366530a9 100644 --- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php +++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php @@ -11,6 +11,7 @@ use Drupal\ckeditor\CKEditorPluginContextualInterface; use Drupal\ckeditor\CKEditorPluginConfigurableInterface; use Drupal\Component\Plugin\PluginBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\editor\Entity\Editor; /** @@ -61,7 +62,7 @@ function getFile() { /** * Implements \Drupal\ckeditor\Plugin\CKEditorPluginConfigurableInterface::settingsForm(). */ - function settingsForm(array $form, array &$form_state, Editor $editor) { + function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) { // Defaults. $config = array('ultra_llama_mode' => FALSE); $settings = $editor->getSettings(); diff --git a/core/modules/color/color.module b/core/modules/color/color.module index f0137cfc3f3ea5217ed76dd6f5a1fbb1287dffec..1f03e18faa9c0dc1e1473310f4a796414b80268f 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -9,6 +9,7 @@ use Drupal\Component\Utility\Environment; use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; /** @@ -44,7 +45,7 @@ function color_theme() { /** * Implements hook_form_FORM_ID_alter(). */ -function color_form_system_theme_settings_alter(&$form, &$form_state) { +function color_form_system_theme_settings_alter(&$form, FormStateInterface $form_state) { if (isset($form_state['build_info']['args'][0]) && ($theme = $form_state['build_info']['args'][0]) && color_get_info($theme) && function_exists('gd_info')) { $form['color'] = array( '#type' => 'details', @@ -166,7 +167,7 @@ function color_get_palette($theme, $default = FALSE) { * @see color_scheme_form_validate() * @see color_scheme_form_submit() */ -function color_scheme_form($complete_form, &$form_state, $theme) { +function color_scheme_form($complete_form, FormStateInterface $form_state, $theme) { $base = drupal_get_path('module', 'color'); $info = color_get_info($theme); @@ -286,14 +287,14 @@ function template_preprocess_color_scheme_form(&$variables) { * @param string|bool $input * The incoming input to populate the form element. If this is FALSE, * the element's default value should be returned. - * @param array $form_state - * A keyed array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return string * The data that will appear in the $form_state['values'] collection for this * element. Return nothing to use the default. */ -function color_palette_color_value($element, $input = FALSE, $form_state = array()) { +function color_palette_color_value($element, $input = FALSE, FormStateInterface $form_state) { // If we suspect a possible cross-site request forgery attack, only accept // hexadecimal CSS color strings from user input, to avoid problems when this // value is used in the JavaScript preview. @@ -329,7 +330,7 @@ function color_valid_hexadecimal_string($color) { * * @see color_scheme_form_submit() */ -function color_scheme_form_validate($form, &$form_state) { +function color_scheme_form_validate($form, FormStateInterface $form_state) { // Only accept hexadecimal CSS color strings to avoid XSS upon use. foreach ($form_state['values']['palette'] as $key => $color) { if (!color_valid_hexadecimal_string($color)) { @@ -343,7 +344,7 @@ function color_scheme_form_validate($form, &$form_state) { * * @see color_scheme_form_validate() */ -function color_scheme_form_submit($form, &$form_state) { +function color_scheme_form_submit($form, FormStateInterface $form_state) { // Get theme coloring info. if (!isset($form_state['values']['info'])) { diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index ab0df062c3405a01bd83d1dcb5d60159d238edcf..d5391f366b3b8739d97d67c7e5328175adcbf829 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -18,6 +18,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\entity\Entity\EntityViewDisplay; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; @@ -749,11 +750,13 @@ function comment_user_predelete($account) { * * @param \Drupal\comment\CommentInterface $comment * The comment entity to preview. + * @param Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * An array as expected by drupal_render(). */ -function comment_preview(CommentInterface $comment, array &$form_state) { +function comment_preview(CommentInterface $comment, FormStateInterface $form_state) { $preview_build = array(); $entity = $comment->getCommentedEntity(); diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index db4178d94f6d50badc095589b8923221f1649925..9701e49f779ac30633738084ef3261957f723079 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -13,6 +13,7 @@ use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; @@ -56,7 +57,7 @@ public function __construct(EntityManagerInterface $entity_manager, AccountInter /** * {@inheritdoc} */ - protected function init(array &$form_state) { + protected function init(FormStateInterface $form_state) { $comment = $this->entity; // Make the comment inherit the current content language unless specifically @@ -72,7 +73,7 @@ protected function init(array &$form_state) { /** * Overrides Drupal\Core\Entity\EntityForm::form(). */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { /** @var \Drupal\comment\CommentInterface $comment */ $comment = $this->entity; $entity = $this->entityManager->getStorage($comment->getCommentedEntityTypeId())->load($comment->getCommentedEntityId()); @@ -218,7 +219,7 @@ public function form(array $form, array &$form_state) { /** * Overrides Drupal\Core\Entity\EntityForm::actions(). */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $element = parent::actions($form, $form_state); /* @var \Drupal\comment\CommentInterface $comment */ $comment = $this->entity; @@ -255,7 +256,7 @@ protected function actions(array $form, array &$form_state) { /** * Overrides Drupal\Core\Entity\EntityForm::validate(). */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); $entity = $this->entity; @@ -289,7 +290,7 @@ public function validate(array $form, array &$form_state) { /** * Overrides EntityForm::buildEntity(). */ - public function buildEntity(array $form, array &$form_state) { + public function buildEntity(array $form, FormStateInterface $form_state) { $comment = parent::buildEntity($form, $form_state); if (!empty($form_state['values']['date']) && $form_state['values']['date'] instanceOf DrupalDateTime) { $comment->setCreatedTime($form_state['values']['date']->getTimestamp()); @@ -304,7 +305,7 @@ public function buildEntity(array $form, array &$form_state) { /** * Overrides Drupal\Core\Entity\EntityForm::submit(). */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { /** @var \Drupal\comment\CommentInterface $comment */ $comment = parent::submit($form, $form_state); @@ -346,9 +347,9 @@ public function submit(array $form, array &$form_state) { * @param $form * An associative array containing the structure of the form. * @param $form_state - * A reference to a keyed array containing the current state of the form. + * The current state of the form. */ - public function preview(array &$form, array &$form_state) { + public function preview(array &$form, FormStateInterface $form_state) { $comment = $this->entity; $form_state['comment_preview'] = comment_preview($comment, $form_state); $form_state['comment_preview']['#title'] = $this->t('Preview comment'); @@ -358,7 +359,7 @@ public function preview(array &$form, array &$form_state) { /** * Overrides Drupal\Core\Entity\EntityForm::save(). */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $comment = $this->entity; $entity = $comment->getCommentedEntity(); $field_name = $comment->getFieldName(); diff --git a/core/modules/comment/src/CommentTypeForm.php b/core/modules/comment/src/CommentTypeForm.php index 43367a57928c6e58b29b031bcba2e5341c8d8c80..332e911308d1248f543e9c45b4f063592e5f36fc 100644 --- a/core/modules/comment/src/CommentTypeForm.php +++ b/core/modules/comment/src/CommentTypeForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Form\FormStateInterface; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -58,7 +59,7 @@ public function __construct(EntityManagerInterface $entity_manager, LoggerInterf /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $comment_type = $this->entity; @@ -132,7 +133,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $comment_type = $this->entity; $status = $comment_type->save(); diff --git a/core/modules/comment/src/Form/CommentAdminOverview.php b/core/modules/comment/src/Form/CommentAdminOverview.php index fd8f6dc5ec5a5728a960b0c8400e10184f243513..b1d3cb7461918c4c5ae655520b00f8f348c06ebf 100644 --- a/core/modules/comment/src/Form/CommentAdminOverview.php +++ b/core/modules/comment/src/Form/CommentAdminOverview.php @@ -14,6 +14,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -92,15 +93,15 @@ public function getFormID() { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param string $type * The type of the overview form ('approval' or 'new'). * * @return array * The form structure. */ - public function buildForm(array $form, array &$form_state, $type = 'new') { + public function buildForm(array $form, FormStateInterface $form_state, $type = 'new') { // Build an 'Update options' form. $form['options'] = array( @@ -250,7 +251,7 @@ public function buildForm(array $form, array &$form_state, $type = 'new') { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $form_state['values']['comments'] = array_diff($form_state['values']['comments'], array(0)); // We can't execute any 'Update options' if no comments were selected. if (count($form_state['values']['comments']) == 0) { @@ -261,7 +262,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $operation = $form_state['values']['operation']; $cids = $form_state['values']['comments']; diff --git a/core/modules/comment/src/Form/CommentTypeDeleteForm.php b/core/modules/comment/src/Form/CommentTypeDeleteForm.php index 85092db47bb286daec375bf4aaebd5241ed98bf7..64da7c491fcb375eea0013abb2275ce06fe57109 100644 --- a/core/modules/comment/src/Form/CommentTypeDeleteForm.php +++ b/core/modules/comment/src/Form/CommentTypeDeleteForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\field\Entity\FieldStorageConfig; use Psr\Log\LoggerInterface; @@ -111,7 +112,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $comments = $this->queryFactory->get('comment')->condition('comment_type', $this->entity->id())->execute(); $entity_type = $this->entity->getTargetEntityTypeId(); $caption = ''; @@ -140,7 +141,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); $form_state['redirect_route']['route_name'] = 'comment.type_list'; drupal_set_message($this->t('Comment type %label has been deleted.', array('%label' => $this->entity->label()))); diff --git a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php index 5a0b062f14bf01a5787439f42a55ea9140704e6d..39fe5382527bec0f5e13b3383621a42fc0577f5a 100644 --- a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php +++ b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php @@ -10,6 +10,7 @@ use Drupal\comment\CommentStorageInterface; use Drupal\Component\Utility\String; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -82,7 +83,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $edit = $form_state['input']; $form['comments'] = array( @@ -116,7 +117,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state['values']['confirm']) { $this->commentStorage->delete($this->comments); $count = count($form_state['values']['comments']); diff --git a/core/modules/comment/src/Form/DeleteForm.php b/core/modules/comment/src/Form/DeleteForm.php index b8cbae629333ef2b8bbef5d1aedf25da52ed73dd..1ee7b4c4a5d50673c8085bfe30fc5755ef95dda4 100644 --- a/core/modules/comment/src/Form/DeleteForm.php +++ b/core/modules/comment/src/Form/DeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\comment\Form; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides the comment delete confirmation form. @@ -46,7 +47,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/comment/src/Plugin/Action/UnpublishByKeywordComment.php b/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php index ad59c96309007294f09f9cc426fcc92ecda1da5c..87ec9e7c8bcbf471845a90696c175219e53ac143 100644 --- a/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php +++ b/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Tags; use Drupal\Core\Action\ConfigurableActionBase; use Drupal\comment\CommentInterface; +use Drupal\Core\Form\FormStateInterface; /** * Unpublishes a comment containing certain keywords. @@ -49,7 +50,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['keywords'] = array( '#title' => t('Keywords'), '#type' => 'textarea', @@ -62,7 +63,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['keywords'] = Tags::explode($form_state['values']['keywords']); } diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index be7bf534290bcd92ec38e3719bfee9bf8d382264..e5ad723bd48ffd94f8553aaa13d51e0aba9dcd91 100644 --- a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -13,6 +13,7 @@ use Drupal\Core\Entity\EntityViewBuilderInterface; use Drupal\Core\Entity\EntityFormBuilderInterface; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FormatterBase; @@ -232,7 +233,7 @@ public function viewElements(FieldItemListInterface $items) { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element = array(); $element['pager_id'] = array( '#type' => 'select', diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php index 33a88b5f75e5a79993e6af8b13bcf0d06616dd52..57e41d8c4649556f67a2c0f52224b308eb59664b 100644 --- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php @@ -10,6 +10,7 @@ use Drupal\comment\CommentManagerInterface; use Drupal\comment\Entity\CommentType; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Session\AnonymousUserSession; @@ -98,7 +99,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { $element = array(); $settings = $this->getSettings(); @@ -188,7 +189,7 @@ public function isEmpty() { /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { $element = array(); // @todo Inject entity storage once typed-data supports container injection. diff --git a/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php b/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php index f9fdf73d6a5edb16cdc33bec71d0f407b00aa348..87309c513ba70b4ef81963c77250866933ea25b3 100644 --- a/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php +++ b/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php @@ -10,6 +10,7 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides a default comment widget. @@ -27,7 +28,7 @@ class CommentWidget extends WidgetBase { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $entity = $items->getEntity(); $element['status'] = array( @@ -89,7 +90,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen /** * {@inheritdoc} */ - public function massageFormValues(array $values, array $form, array &$form_state) { + public function massageFormValues(array $values, array $form, FormStateInterface $form_state) { // Add default values for statistics properties because we don't want to // have them in form. foreach ($values as &$value) { diff --git a/core/modules/comment/src/Plugin/views/field/Comment.php b/core/modules/comment/src/Plugin/views/field/Comment.php index 1a47a4af0d76959a0587f03a9c0e7996c9486a2e..25c001d5e622b38b5985ff7d2960eeae96b7879c 100644 --- a/core/modules/comment/src/Plugin/views/field/Comment.php +++ b/core/modules/comment/src/Plugin/views/field/Comment.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -60,7 +61,7 @@ protected function defineOptions() { /** * Provide link-to-comment option */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['link_to_comment'] = array( '#title' => t('Link this field to its comment'), '#description' => t("Enable to override this field's links."), diff --git a/core/modules/comment/src/Plugin/views/field/EntityLink.php b/core/modules/comment/src/Plugin/views/field/EntityLink.php index f84821029c920616167a2df62816546f7f784f5d..c1dae3907f818fae11204d6e5f0c5b0194c354ff 100644 --- a/core/modules/comment/src/Plugin/views/field/EntityLink.php +++ b/core/modules/comment/src/Plugin/views/field/EntityLink.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; @@ -32,7 +33,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['teaser'] = array( '#type' => 'checkbox', '#title' => t('Show teaser-style link'), diff --git a/core/modules/comment/src/Plugin/views/field/Link.php b/core/modules/comment/src/Plugin/views/field/Link.php index a57ff12580ffcf29c84d147f336bff637466c893..4a3842e9141f91c82b1930083fb0d1b05f1130e4 100644 --- a/core/modules/comment/src/Plugin/views/field/Link.php +++ b/core/modules/comment/src/Plugin/views/field/Link.php @@ -8,6 +8,7 @@ namespace Drupal\comment\Plugin\views\field; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\views\ResultRow; @@ -65,7 +66,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['text'] = array( '#type' => 'textfield', '#title' => t('Text to display'), diff --git a/core/modules/comment/src/Plugin/views/field/LinkEdit.php b/core/modules/comment/src/Plugin/views/field/LinkEdit.php index f6137ade107b11c69a25bc5f55ac912de8fcb7b3..76371434e98af008d7b6784f9488ff91d62b5988 100644 --- a/core/modules/comment/src/Plugin/views/field/LinkEdit.php +++ b/core/modules/comment/src/Plugin/views/field/LinkEdit.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -25,7 +26,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['destination'] = array( diff --git a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php index 336615723d4442c360a523f3baada944404e2f94..748291bd9c284f140cf4e8b598408cc7368f1257 100644 --- a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php +++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php @@ -9,6 +9,7 @@ use Drupal\Core\Database\Connection; use Drupal\comment\CommentInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\Numeric; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ResultRow; @@ -82,7 +83,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['link_to_comment'] = array( '#title' => t('Link this field to new comments'), '#description' => t("Enable to override this field's links."), diff --git a/core/modules/comment/src/Plugin/views/field/Username.php b/core/modules/comment/src/Plugin/views/field/Username.php index c400144a8e1e2cad8bc21f97c70dca6e230e31d5..b526dbcc50f217f49a6ff37220b88a0a3af85f1a 100644 --- a/core/modules/comment/src/Plugin/views/field/Username.php +++ b/core/modules/comment/src/Plugin/views/field/Username.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -39,7 +40,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['link_to_user'] = array( '#title' => t("Link this field to its user or an author's homepage"), '#type' => 'checkbox', diff --git a/core/modules/comment/src/Plugin/views/row/CommentRow.php b/core/modules/comment/src/Plugin/views/row/CommentRow.php index 2d347281c7d358d6b832d81ea3186fbe99ced143..5256b5662cce84bd53d1c483f6c6c37f403a61e5 100644 --- a/core/modules/comment/src/Plugin/views/row/CommentRow.php +++ b/core/modules/comment/src/Plugin/views/row/CommentRow.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\row\EntityRow; /** @@ -31,7 +32,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['links'] = array( diff --git a/core/modules/comment/src/Plugin/views/row/Rss.php b/core/modules/comment/src/Plugin/views/row/Rss.php index 8b8fc4a313e0098e9023e104ff9b1bb253d29634..d24eefe25d3ab2d7d4d44ac80beb88d43511b0f5 100644 --- a/core/modules/comment/src/Plugin/views/row/Rss.php +++ b/core/modules/comment/src/Plugin/views/row/Rss.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\row\RowPluginBase; /** @@ -36,7 +37,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['view_mode'] = array( diff --git a/core/modules/comment/src/Plugin/views/wizard/Comment.php b/core/modules/comment/src/Plugin/views/wizard/Comment.php index c2c4ff46561f00207e7c33e38c4d17018abd5899..5227f39dddb63fba71bc49c98e789833237bb2d9 100644 --- a/core/modules/comment/src/Plugin/views/wizard/Comment.php +++ b/core/modules/comment/src/Plugin/views/wizard/Comment.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Plugin\views\wizard; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\wizard\WizardPluginBase; /** @@ -73,7 +74,7 @@ protected function rowStyleOptions() { return $options; } - protected function buildFormStyle(array &$form, array &$form_state, $type) { + protected function buildFormStyle(array &$form, FormStateInterface $form_state, $type) { parent::buildFormStyle($form, $form_state, $type); $style_form =& $form['displays'][$type]['options']['style']; // Some style plugins don't support row plugins so stop here if that's the @@ -101,7 +102,7 @@ protected function buildFormStyle(array &$form, array &$form_state, $type) { /** * {@inheritdoc} */ - protected function pageDisplayOptions(array $form, array &$form_state) { + protected function pageDisplayOptions(array $form, FormStateInterface $form_state) { $display_options = parent::pageDisplayOptions($form, $form_state); $row_plugin = isset($form_state['values']['page']['style']['row_plugin']) ? $form_state['values']['page']['style']['row_plugin'] : NULL; $row_options = isset($form_state['values']['page']['style']['row_options']) ? $form_state['values']['page']['style']['row_options'] : array(); @@ -112,7 +113,7 @@ protected function pageDisplayOptions(array $form, array &$form_state) { /** * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::blockDisplayOptions(). */ - protected function blockDisplayOptions(array $form, array &$form_state) { + protected function blockDisplayOptions(array $form, FormStateInterface $form_state) { $display_options = parent::blockDisplayOptions($form, $form_state); $row_plugin = isset($form_state['values']['block']['style']['row_plugin']) ? $form_state['values']['block']['style']['row_plugin'] : NULL; $row_options = isset($form_state['values']['block']['style']['row_options']) ? $form_state['values']['block']['style']['row_options'] : array(); diff --git a/core/modules/config/src/Form/ConfigExportForm.php b/core/modules/config/src/Form/ConfigExportForm.php index c3518180f96cd65f2fccba6cf55edb1aa6dffcc9..e76a56c5824a4e7c0f3e35c9ec4e559da3e11db1 100644 --- a/core/modules/config/src/Form/ConfigExportForm.php +++ b/core/modules/config/src/Form/ConfigExportForm.php @@ -8,6 +8,7 @@ namespace Drupal\config\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Defines the configuration export form. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['description'] = array( '#markup' => '

' . $this->t('Use the export button below to download your site configuration.') . '

', ); @@ -38,7 +39,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['redirect_route']['route_name'] = 'config.export_download'; } diff --git a/core/modules/config/src/Form/ConfigImportForm.php b/core/modules/config/src/Form/ConfigImportForm.php index 97d039ee310d6849dc987744a13aee6706053770..00315e1650a5a40775a47f0f81ef9fb87c88b553 100644 --- a/core/modules/config/src/Form/ConfigImportForm.php +++ b/core/modules/config/src/Form/ConfigImportForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Archiver\ArchiveTar; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -53,7 +54,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['description'] = array( '#markup' => '

' . $this->t('Use the upload button below.') . '

', ); @@ -73,7 +74,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $file_upload = $this->getRequest()->files->get('files[import_tarball]', NULL, TRUE); if ($file_upload && $file_upload->isValid()) { $form_state['values']['import_tarball'] = $file_upload->getRealPath(); @@ -86,7 +87,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { if ($path = $form_state['values']['import_tarball']) { $this->configStorage->deleteAll(); try { diff --git a/core/modules/config/src/Form/ConfigSingleExportForm.php b/core/modules/config/src/Form/ConfigSingleExportForm.php index 14255b5d58742b44ca83d71208ea358617131835..28d1069095ac8f7b008c64731964ec1a809d2f17 100644 --- a/core/modules/config/src/Form/ConfigSingleExportForm.php +++ b/core/modules/config/src/Form/ConfigSingleExportForm.php @@ -12,6 +12,8 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormState; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -73,7 +75,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $config_type = NULL, $config_name = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $config_type = NULL, $config_name = NULL) { foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) { if ($definition->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) { $this->definitions[$entity_type] = $definition; @@ -121,10 +123,10 @@ public function buildForm(array $form, array &$form_state, $config_type = NULL, '#suffix' => '', ); if ($config_type && $config_name) { - $fake_form_state = array('values' => array( + $fake_form_state = new FormState(array('values' => array( 'config_type' => $config_type, 'config_name' => $config_name, - )); + ))); $form['export'] = $this->updateExport($form, $fake_form_state); } return $form; @@ -133,7 +135,7 @@ public function buildForm(array $form, array &$form_state, $config_type = NULL, /** * Handles switching the configuration type selector. */ - public function updateConfigurationType($form, &$form_state) { + public function updateConfigurationType($form, FormStateInterface $form_state) { $form['config_name']['#options'] = $this->findConfiguration($form_state['values']['config_type']); return $form['config_name']; } @@ -141,7 +143,7 @@ public function updateConfigurationType($form, &$form_state) { /** * Handles switching the export textarea. */ - public function updateExport($form, &$form_state) { + public function updateExport($form, FormStateInterface $form_state) { // Determine the full config name for the selected config entity. if ($form_state['values']['config_type'] !== 'system.simple') { $definition = $this->entityManager->getDefinition($form_state['values']['config_type']); @@ -197,7 +199,7 @@ protected function findConfiguration($config_type) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Nothing to submit. } diff --git a/core/modules/config/src/Form/ConfigSingleImportForm.php b/core/modules/config/src/Form/ConfigSingleImportForm.php index 0793c5889f4c9233c7a7c1e175671f055207e093..faff0e987b071b0df6c4c1e2edcf65d84696cc9f 100644 --- a/core/modules/config/src/Form/ConfigSingleImportForm.php +++ b/core/modules/config/src/Form/ConfigSingleImportForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Config\StorageInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -114,7 +115,7 @@ public function getQuestion() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // When this is the confirmation step fall through to the confirmation form. if ($this->data) { return parent::buildForm($form, $form_state); @@ -177,7 +178,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // The confirmation step needs no additional validation. if ($this->data) { return; @@ -232,7 +233,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // If this form has not yet been confirmed, store the values and rebuild. if (!$this->data) { $form_state['rebuild'] = TRUE; diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php index 7c48dd538e5adda0f65673f4fcce49b509fce6e7..a93c0ff2d757d707e21ee359033f1c41abe2053b 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -17,6 +17,7 @@ use Drupal\Core\Config\ConfigManagerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Config\StorageInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Config\StorageComparer; use Drupal\Core\Routing\UrlGeneratorInterface; @@ -152,7 +153,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', @@ -270,7 +271,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $config_importer = new ConfigImporter( $form_state['storage_comparer'], $this->eventDispatcher, diff --git a/core/modules/config/tests/config_test/src/ConfigTestForm.php b/core/modules/config/tests/config_test/src/ConfigTestForm.php index 8a680b207ece610886f390c29d020cd8f3aaea82..cbe4c6f2896e02ffae0ce60871d324bb7564e1db 100644 --- a/core/modules/config/tests/config_test/src/ConfigTestForm.php +++ b/core/modules/config/tests/config_test/src/ConfigTestForm.php @@ -8,6 +8,7 @@ namespace Drupal\config_test; use Drupal\Core\Entity\EntityForm; +use Drupal\Core\Form\FormStateInterface; /** * Form controller for the test config edit forms. @@ -15,9 +16,9 @@ class ConfigTestForm extends EntityForm { /** - * Overrides Drupal\Core\Entity\EntityForm::form(). + * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $entity = $this->entity; @@ -67,9 +68,9 @@ public function form(array $form, array &$form_state) { } /** - * Overrides Drupal\Core\Entity\EntityForm::save(). + * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $entity = $this->entity; $status = $entity->save(); diff --git a/core/modules/config/tests/config_test/src/Form/ConfigTestDeleteForm.php b/core/modules/config/tests/config_test/src/Form/ConfigTestDeleteForm.php index 63cdfd6498ca048dab715252a2fbf4ee92d5fa01..d344a4e29b6fd53b7cbb3efccb083160ff562758 100644 --- a/core/modules/config/tests/config_test/src/Form/ConfigTestDeleteForm.php +++ b/core/modules/config/tests/config_test/src/Form/ConfigTestDeleteForm.php @@ -8,6 +8,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -39,7 +40,7 @@ public function getCancelUrl() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); drupal_set_message(String::format('%label configuration has been deleted.', array('%label' => $this->entity->label()))); $form_state['redirect_route'] = $this->getCancelUrl(); diff --git a/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php b/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php index 9556be26d8181dcbaedc2a844dbdb157641af0cc..1930c3bf524d2a6833a71abc8d0e3d71ced681da 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php @@ -7,6 +7,7 @@ namespace Drupal\config_translation\Form; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\Request; /** @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL) { $form = parent::buildForm($form, $form_state, $request, $plugin_id, $langcode); $form['#title'] = $this->t('Add @language translation for %label', array( '%label' => $this->mapper->getTitle(), @@ -36,7 +37,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); drupal_set_message($this->t('Successfully saved @language translation.', array('@language' => $this->language->name))); } diff --git a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php index e064b1a2d077a96f02bf9816b7103d4066ceb89e..fc9c73004022529c02f2b05664d3cf6b5670db9b 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\language\ConfigurableLanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -115,7 +116,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL) { /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */ $mapper = $this->configMapperManager->createInstance($plugin_id); $mapper->populateFromRequest($request); @@ -133,7 +134,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($this->mapper->getConfigNames() as $name) { $this->languageManager->getLanguageConfigOverride($this->language->id, $name)->delete(); } diff --git a/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php b/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php index 565d07aee2926531b99b2e55d43a9bb0e3be4346..91e479731b74d266aa86d69d9b9a9b1ead06865c 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php @@ -7,6 +7,7 @@ namespace Drupal\config_translation\Form; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\Request; /** @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL) { $form = parent::buildForm($form, $form_state, $request, $plugin_id, $langcode); $form['#title'] = $this->t('Edit @language translation for %label', array( '%label' => $this->mapper->getTitle(), @@ -36,7 +37,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); drupal_set_message($this->t('Successfully updated @language translation.', array('@language' => $this->language->name))); } diff --git a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php index 5b6125ad9fc11cb990fa66ce4a12464f9c9e429d..29ed2c9672ffd8b5e3c155706bf4a115bd83b9ee 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php @@ -14,6 +14,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\BaseFormIdInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\language\Config\LanguageConfigOverride; use Drupal\language\ConfigurableLanguageManagerInterface; @@ -138,8 +139,8 @@ public function getBaseFormID() { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param \Symfony\Component\HttpFoundation\Request $request * (optional) Page request object. * @param string $plugin_id @@ -155,7 +156,7 @@ public function getBaseFormID() { * Throws an exception if the language code provided as a query parameter in * the request does not match an active language. */ - public function buildForm(array $form, array &$form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL) { /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */ $mapper = $this->configMapperManager->createInstance($plugin_id); $mapper->populateFromRequest($request); @@ -214,7 +215,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_values = $form_state['values']['config_names']; // For the form submission handling, use the raw data. diff --git a/core/modules/config_translation/src/FormElement/DateFormat.php b/core/modules/config_translation/src/FormElement/DateFormat.php index 2e089cb1bdaab926b42f7903dfcc5ffd271e1990..d00a71e575dae11d5621bfbb31e3f023d2353a19 100644 --- a/core/modules/config_translation/src/FormElement/DateFormat.php +++ b/core/modules/config_translation/src/FormElement/DateFormat.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\ReplaceCommand; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\TypedData\DataDefinitionInterface; @@ -46,7 +47,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte * * @param array $form * Form API array structure. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * Form state information. * * @return AjaxResponse @@ -54,7 +55,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte * the given format cannot be identified or was empty, the response will * be empty as well. */ - public static function ajaxSample(array $form, array $form_state) { + public static function ajaxSample(array $form, FormStateInterface $form_state) { $response = new AjaxResponse(); $format_value = NestedArray::getValue($form_state['values'], $form_state['triggering_element']['#array_parents']); diff --git a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module index d38be9733923a8b9c0e6bcbaf043a7a1530be976..582be7c32da48e8ff4be255edbf3e396c4f94a67 100644 --- a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module +++ b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module @@ -6,6 +6,7 @@ */ use Drupal\Core\Extension\Extension; +use Drupal\Core\Form\FormStateInterface; /** * Implements hook_system_info_alter(). @@ -47,7 +48,7 @@ function config_translation_test_config_translation_info_alter(&$info) { * * @see \Drupal\config_translation\Form\ConfigTranslationFormBase */ -function config_translation_test_form_config_translation_form_alter(&$form, &$form_state) { +function config_translation_test_form_config_translation_form_alter(&$form, FormStateInterface $form_state) { if (\Drupal::state()->get('config_translation_test_alter_form_alter')) { $form['#base_altered'] = TRUE; } @@ -60,7 +61,7 @@ function config_translation_test_form_config_translation_form_alter(&$form, &$fo * * @see \Drupal\config_translation\Form\ConfigTranslationAddForm */ -function config_translation_test_form_config_translation_add_form_alter(&$form, &$form_state) { +function config_translation_test_form_config_translation_add_form_alter(&$form, FormStateInterface $form_state) { if (\Drupal::state()->get('config_translation_test_alter_form_alter')) { $form['#altered'] = TRUE; } @@ -77,7 +78,7 @@ function config_translation_test_form_config_translation_add_form_alter(&$form, * * @see \Drupal\config_translation\Form\ConfigTranslationEditForm */ -function config_translation_test_form_config_translation_edit_form_alter(&$form, &$form_state) { +function config_translation_test_form_config_translation_edit_form_alter(&$form, FormStateInterface $form_state) { if (\Drupal::state()->get('config_translation_test_alter_form_alter')) { $form['#altered'] = TRUE; } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index e8485c11c1ae26d78ca90f72753ec6dbf7cfd812..bee5dcfb03132c8bb40b28386aedee4f4d632ee8 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -5,6 +5,7 @@ * Enables the use of personal and site-wide contact forms. */ +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; /** @@ -162,7 +163,7 @@ function contact_mail($key, &$message, $params) { * * @see \Drupal\user\ProfileForm::form() */ -function contact_form_user_form_alter(&$form, &$form_state) { +function contact_form_user_form_alter(&$form, FormStateInterface $form_state) { $form['contact'] = array( '#type' => 'details', '#title' => t('Contact settings'), @@ -185,7 +186,7 @@ function contact_form_user_form_alter(&$form, &$form_state) { /** * Submit callback for the user profile form to save the contact page setting. */ -function contact_user_profile_form_submit($form, &$form_state) { +function contact_user_profile_form_submit($form, FormStateInterface $form_state) { $account = $form_state['controller']->getEntity(); if ($account->id() && isset($form_state['values']['contact'])) { \Drupal::service('user.data')->set('contact', $account->id(), 'enabled', (int) $form_state['values']['contact']); @@ -199,7 +200,7 @@ function contact_user_profile_form_submit($form, &$form_state) { * * @see user_admin_settings() */ -function contact_form_user_admin_settings_alter(&$form, &$form_state) { +function contact_form_user_admin_settings_alter(&$form, FormStateInterface $form_state) { $form['contact'] = array( '#type' => 'details', '#title' => t('Contact settings'), @@ -221,7 +222,7 @@ function contact_form_user_admin_settings_alter(&$form, &$form_state) { * * @see contact_form_user_admin_settings_alter() */ -function contact_form_user_admin_settings_submit($form, &$form_state) { +function contact_form_user_admin_settings_submit($form, FormStateInterface $form_state) { \Drupal::config('contact.settings') ->set('user_default_enabled', $form_state['values']['contact_default_status']) ->save(); diff --git a/core/modules/contact/src/CategoryForm.php b/core/modules/contact/src/CategoryForm.php index fd315a60c1bfe57025a845127eb66ac3138bec69..df91084619682066bb141238ab54f1feb51ee8d7 100644 --- a/core/modules/contact/src/CategoryForm.php +++ b/core/modules/contact/src/CategoryForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Form\FormStateInterface; /** * Base form for category edit forms. @@ -18,7 +19,7 @@ class CategoryForm extends EntityForm { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $category = $this->entity; @@ -72,7 +73,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); // Validate and each email recipient. @@ -90,7 +91,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $category = $this->entity; $status = $category->save(); $contact_settings = $this->config('contact.settings'); diff --git a/core/modules/contact/src/Form/CategoryDeleteForm.php b/core/modules/contact/src/Form/CategoryDeleteForm.php index 9117a7511da21739a7bfc7741bab2440fd0a01e0..5fddb0855abed51c4a9ff8caa0e5f15a4462acd8 100644 --- a/core/modules/contact/src/Form/CategoryDeleteForm.php +++ b/core/modules/contact/src/Form/CategoryDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\contact\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -39,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); drupal_set_message($this->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/src/MessageForm.php b/core/modules/contact/src/MessageForm.php index d289f384dfd1a34bd3566650e2b502861be22fc7..30ac4105602082dc51391e34df210750954087f0 100644 --- a/core/modules/contact/src/MessageForm.php +++ b/core/modules/contact/src/MessageForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Flood\FloodInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; @@ -72,7 +73,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $user = $this->currentUser(); $message = $this->entity; $form = parent::form($form, $form_state, $message); @@ -150,7 +151,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function actions(array $form, array &$form_state) { + public function actions(array $form, FormStateInterface $form_state) { $elements = parent::actions($form, $form_state); $elements['submit']['#value'] = $this->t('Send message'); $elements['preview'] = array( @@ -169,7 +170,7 @@ public function actions(array $form, array &$form_state) { /** * Form submission handler for the 'preview' action. */ - public function preview(array $form, array &$form_state) { + public function preview(array $form, FormStateInterface $form_state) { $message = $this->entity; $message->preview = TRUE; $form_state['rebuild'] = TRUE; @@ -178,7 +179,7 @@ public function preview(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $user = $this->currentUser(); $language_interface = $this->languageManager->getCurrentLanguage(); @@ -271,7 +272,7 @@ public function save(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function init(array &$form_state) { + protected function init(FormStateInterface $form_state) { $message = $this->entity; // Make the message inherit the current content language unless specifically diff --git a/core/modules/contact/src/Plugin/views/field/ContactLink.php b/core/modules/contact/src/Plugin/views/field/ContactLink.php index 15313e0089cb0d8d949aa8c07736f7d1af504271..8b0ce91862a0d0415c58e861f196acdde43ea135 100644 --- a/core/modules/contact/src/Plugin/views/field/ContactLink.php +++ b/core/modules/contact/src/Plugin/views/field/ContactLink.php @@ -9,6 +9,7 @@ use Drupal\Core\Access\AccessManagerInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\user\Plugin\views\field\Link; use Drupal\views\ResultRow; @@ -84,7 +85,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['text']['#title'] = t('Link label'); $form['text']['#required'] = TRUE; diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 7e7e790eeacb26f35a942df98f793822c9b421c7..9b33f0e58f5ba92c5000b9b0bbd76dad6b242212 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -8,6 +8,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Render\Element; use Drupal\field\FieldInstanceConfigInterface; @@ -60,7 +61,7 @@ function content_translation_field_sync_widget(FieldDefinitionInterface $field) /** * (proxied) Implements hook_form_FORM_ID_alter(). */ -function _content_translation_form_language_content_settings_form_alter(array &$form, array &$form_state) { +function _content_translation_form_language_content_settings_form_alter(array &$form, FormStateInterface $form_state) { // Inject into the content language settings the translation settings if the // user has the required permission. if (!\Drupal::currentUser()->hasPermission('administer content translation')) { @@ -254,7 +255,7 @@ function _content_translation_preprocess_language_content_settings_table(&$varia * * @see content_translation_admin_settings_form_submit() */ -function content_translation_form_language_content_settings_validate(array $form, array &$form_state) { +function content_translation_form_language_content_settings_validate(array $form, FormStateInterface $form_state) { $settings = &$form_state['values']['settings']; foreach ($settings as $entity_type => $entity_settings) { foreach ($entity_settings as $bundle => $bundle_settings) { @@ -284,7 +285,7 @@ function content_translation_form_language_content_settings_validate(array $form * * @see content_translation_admin_settings_form_validate() */ -function content_translation_form_language_content_settings_submit(array $form, array &$form_state) { +function content_translation_form_language_content_settings_submit(array $form, FormStateInterface $form_state) { $entity_types = $form_state['values']['entity_types']; $settings = &$form_state['values']['settings']; diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 21144a5ff5f0f7b2d9dba19994a5ceb8f825580c..c79213a998f5dd5231e6fa82dca4ca5c4e17751a 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityFormInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\field\Entity\FieldInstanceConfig; @@ -366,8 +367,8 @@ function content_translation_controller($entity_type_id) { /** * Returns the entity form for the given form. * - * @param array $form_state - * The form state array holding the entity form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current form state holding the entity form. * * @return \Drupal\Core\Entity\EntityFormInterface; * An instance of the content translation form interface or FALSE if not an @@ -375,7 +376,7 @@ function content_translation_controller($entity_type_id) { * * @todo Move to \Drupal\content_translation\ContentTranslationManager. */ -function content_translation_form_controller(array $form_state) { +function content_translation_form_controller($form_state) { return isset($form_state['controller']) && $form_state['controller'] instanceof EntityFormInterface ? $form_state['controller'] : FALSE; } @@ -458,7 +459,7 @@ function content_translation_permission() { /** * Implements hook_form_alter(). */ -function content_translation_form_alter(array &$form, array &$form_state) { +function content_translation_form_alter(array &$form, FormStateInterface $form_state) { $form_controller = content_translation_form_controller($form_state); $entity = $form_controller ? $form_controller->getEntity() : NULL; @@ -644,7 +645,7 @@ function content_translation_entity_extra_field_info() { /** * Implements hook_form_FORM_ID_alter() for 'field_ui_instance_edit_form'. */ -function content_translation_form_field_ui_field_instance_edit_form_alter(array &$form, array &$form_state) { +function content_translation_form_field_ui_field_instance_edit_form_alter(array &$form, FormStateInterface $form_state) { $instance = $form_state['instance']; $bundle_is_translatable = content_translation_enabled($instance->entity_type, $instance->bundle); @@ -722,10 +723,10 @@ function content_translation_element_info_alter(&$type) { * The bundle of the entity being configured for translation. * @param array $form * The configuration form array. - * @param array $form_state - * The configuration form state array. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ -function content_translation_enable_widget($entity_type, $bundle, array &$form, array &$form_state) { +function content_translation_enable_widget($entity_type, $bundle, array &$form, FormStateInterface $form_state) { $key = $form_state['content_translation']['key']; if (!isset($form_state['language'][$key])) { $form_state['language'][$key] = array(); @@ -745,7 +746,7 @@ function content_translation_enable_widget($entity_type, $bundle, array &$form, * @return * Processed language configuration element. */ -function content_translation_language_configuration_element_process(array $element, array &$form_state, array &$form) { +function content_translation_language_configuration_element_process(array $element, FormStateInterface $form_state, array &$form) { if (empty($element['#content_translation_skip_alter']) && \Drupal::currentUser()->hasPermission('administer content translation')) { $form_state['content_translation']['key'] = $element['#name']; $context = $form_state['language'][$element['#name']]; @@ -772,7 +773,7 @@ function content_translation_language_configuration_element_process(array $eleme * * @see content_translation_language_configuration_element_submit() */ -function content_translation_language_configuration_element_validate($element, array &$form_state, array $form) { +function content_translation_language_configuration_element_validate($element, FormStateInterface $form_state, array $form) { $key = $form_state['content_translation']['key']; $values = $form_state['values'][$key]; if (!$values['language_show'] && $values['content_translation'] && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) { @@ -793,7 +794,7 @@ function content_translation_language_configuration_element_validate($element, a * * @see content_translation_language_configuration_element_validate() */ -function content_translation_language_configuration_element_submit(array $form, array &$form_state) { +function content_translation_language_configuration_element_submit(array $form, FormStateInterface $form_state) { $key = $form_state['content_translation']['key']; $context = $form_state['language'][$key]; $enabled = $form_state['values'][$key]['content_translation']; @@ -808,7 +809,7 @@ function content_translation_language_configuration_element_submit(array $form, /** * Implements hook_form_FORM_ID_alter() for language_content_settings_form(). */ -function content_translation_form_language_content_settings_form_alter(array &$form, array &$form_state) { +function content_translation_form_language_content_settings_form_alter(array &$form, FormStateInterface $form_state) { module_load_include('inc', 'content_translation', 'content_translation.admin'); _content_translation_form_language_content_settings_form_alter($form, $form_state); } diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php index 7510d2e0799005a8302ecf4781def2acfff2b810..d14a945d4f63fc001b8228b95f582c19124916ff 100644 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Render\Element; @@ -75,14 +76,14 @@ public function getTranslationAccess(EntityInterface $entity, $op) { /** * {@inheritdoc} */ - public function getSourceLangcode(array $form_state) { + public function getSourceLangcode($form_state) { return isset($form_state['content_translation']['source']) ? $form_state['content_translation']['source']->id : FALSE; } /** * {@inheritdoc} */ - public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { + public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) { $form_controller = content_translation_form_controller($form_state); $form_langcode = $form_controller->getFormLangcode($form_state); $entity_langcode = $entity->getUntranslated()->language()->id; @@ -371,7 +372,7 @@ protected function addTranslatabilityClue(&$element) { * * @see \Drupal\content_translation\ContentTranslationHandler::entityFormAlter() */ - public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, array &$form_state) { + public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) { $form_controller = content_translation_form_controller($form_state); $form_langcode = $form_controller->getFormLangcode($form_state); @@ -410,7 +411,7 @@ public function entityFormEntityBuild($entity_type, EntityInterface $entity, arr * * Validates the submitted content translation metadata. */ - function entityFormValidate($form, &$form_state) { + function entityFormValidate($form, FormStateInterface $form_state) { if (!empty($form_state['values']['content_translation'])) { $translation = $form_state['values']['content_translation']; // Validate the "authored by" field. @@ -429,7 +430,7 @@ function entityFormValidate($form, &$form_state) { * * Takes care of the source language change. */ - public function entityFormSourceChange($form, &$form_state) { + public function entityFormSourceChange($form, FormStateInterface $form_state) { $form_controller = content_translation_form_controller($form_state); $entity = $form_controller->getEntity(); $source = $form_state['values']['source_langcode']['source']; @@ -445,7 +446,7 @@ public function entityFormSourceChange($form, &$form_state) { * * Takes care of entity deletion. */ - function entityFormDelete($form, &$form_state) { + function entityFormDelete($form, FormStateInterface $form_state) { $form_controller = content_translation_form_controller($form_state); $entity = $form_controller->getEntity(); if (count($entity->getTranslationLanguages()) > 1) { @@ -458,7 +459,7 @@ function entityFormDelete($form, &$form_state) { * * Takes care of content translation deletion. */ - function entityFormDeleteTranslation($form, &$form_state) { + function entityFormDeleteTranslation($form, FormStateInterface $form_state) { $form_controller = content_translation_form_controller($form_state); $entity = $form_controller->getEntity(); $path = $entity->getSystemPath('drupal:content-translation-overview'); diff --git a/core/modules/content_translation/src/ContentTranslationHandlerInterface.php b/core/modules/content_translation/src/ContentTranslationHandlerInterface.php index c41fd2739f17c06a74ce73560969c1416f2ff8e9..67c4d0d00e1cefd5534679205d7f84648d9fec1c 100644 --- a/core/modules/content_translation/src/ContentTranslationHandlerInterface.php +++ b/core/modules/content_translation/src/ContentTranslationHandlerInterface.php @@ -8,6 +8,7 @@ namespace Drupal\content_translation; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormStateInterface; /** * Interface for providing content translation. @@ -37,13 +38,13 @@ public function getTranslationAccess(EntityInterface $entity, $op); /** * Retrieves the source language for the translation being created. * - * @param array $form_state - * The form state array. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return string * The source language code. */ - public function getSourceLangcode(array $form_state); + public function getSourceLangcode($form_state); /** * Marks translations as outdated. @@ -61,11 +62,11 @@ public function retranslate(EntityInterface $entity, $langcode = NULL); * * @param array $form * The entity form to be altered to provide the translation workflow. - * @param array $form_state - * The form state array. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param \Drupal\Core\Entity\EntityInterface $entity * The entity being created or edited. */ - public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity); + public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity); } diff --git a/core/modules/content_translation/src/Form/ContentTranslationDeleteForm.php b/core/modules/content_translation/src/Form/ContentTranslationDeleteForm.php index af2d3af0e4690c22a489a93558b0bc642c2cd5c2..a26512457353d895e16fc8a31f785bb7a1f60280 100644 --- a/core/modules/content_translation/src/Form/ContentTranslationDeleteForm.php +++ b/core/modules/content_translation/src/Form/ContentTranslationDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\content_translation\Form; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -39,7 +40,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $_entity_type_id = NULL, $language = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $_entity_type_id = NULL, $language = NULL) { $this->entity = $this->getRequest()->attributes->get($_entity_type_id); $this->language = language_load($language); return parent::buildForm($form, $form_state); @@ -69,7 +70,7 @@ public function getCancelUrl() { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Remove the translated values. $this->entity->removeTranslation($this->language->id); $this->entity->save(); diff --git a/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php b/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php index 2a6ec7957143ec0217678f0b649c1311a84bd0b0..9d234abf34a2981788d25cc30a718f2d2ea5212b 100644 --- a/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php +++ b/core/modules/content_translation/src/Plugin/views/field/TranslationLink.php @@ -7,6 +7,7 @@ namespace Drupal\content_translation\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\Core\Entity\EntityInterface; use Drupal\views\ResultRow; @@ -32,7 +33,7 @@ protected function defineOptions() { /** * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['text'] = array( '#type' => 'textfield', '#title' => t('Text to display'), diff --git a/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php b/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php index aff000c43eef384bb18be58e2480a57220ddd7a3..dd8c990a4bac987d2d4fd21ac1b06f4ea419df78 100644 --- a/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php +++ b/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php @@ -9,6 +9,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\UrlHelper; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; @@ -37,7 +38,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $all_fields = $this->view->display_handler->getFieldLabels(); // Offer to include only those fields that follow this one. $field_options = array_slice($all_fields, 0, array_search($this->options['id'], array_keys($all_fields))); diff --git a/core/modules/datetime/datetime.module b/core/modules/datetime/datetime.module index b5f98ddd516da81eda1aabdadda8ece5090039cd..e70bad37f11721c928b231d0a4d856596d747446 100644 --- a/core/modules/datetime/datetime.module +++ b/core/modules/datetime/datetime.module @@ -7,6 +7,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Datetime\DrupalDateTime; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Template\Attribute; use Drupal\datetime\DateHelper; @@ -119,10 +120,10 @@ function datetime_theme() { * * @param array $element * The form element whose value is being validated. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ -function datetime_datetime_widget_validate(&$element, &$form_state) { +function datetime_datetime_widget_validate(&$element, FormStateInterface $form_state) { if (!form_get_errors($form_state)) { $input_exists = FALSE; $input = NestedArray::getValue($form_state['values'], $element['#parents'], $input_exists); @@ -157,10 +158,10 @@ function datetime_datetime_widget_validate(&$element, &$form_state) { * * @param array $element * The form element whose value is being validated. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ -function datetime_datelist_widget_validate(&$element, &$form_state) { +function datetime_datelist_widget_validate(&$element, FormStateInterface $form_state) { if (!form_get_errors($form_state)) { $input_exists = FALSE; $input = NestedArray::getValue($form_state['values'], $element['#parents'], $input_exists); @@ -352,13 +353,13 @@ function template_preprocess_datetime_wrapper(&$variables) { * * @param array $element * The form element whose value is being processed. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * * @return array * The form element whose value has been processed. */ -function datetime_datetime_form_process($element, &$form_state) { +function datetime_datetime_form_process($element, FormStateInterface $form_state) { $format_settings = array(); // The value callback has populated the #value array. $date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL; @@ -527,10 +528,10 @@ function form_type_datetime_value($element, $input = FALSE) { * * @param array $element * The form element whose value is being validated. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ -function datetime_datetime_validate($element, &$form_state) { +function datetime_datetime_validate($element, FormStateInterface $form_state) { $input_exists = FALSE; $input = NestedArray::getValue($form_state['values'], $element['#parents'], $input_exists); @@ -675,10 +676,10 @@ function datetime_format_example($format) { * * @param array $element * The form element whose value is being processed. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ -function datetime_datelist_form_process($element, &$form_state) { +function datetime_datelist_form_process($element, FormStateInterface $form_state) { // Load translated date part labels from the appropriate calendar plugin. $date_helper = new DateHelper(); @@ -788,14 +789,12 @@ function datetime_datelist_form_process($element, &$form_state) { * @param array $element * The element being processed. * @param array|false $input - * - * @param array $form_state - * (optional) The current state of the form. Defaults to an empty array. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array - * */ -function form_type_datelist_value($element, $input = FALSE, &$form_state = array()) { +function form_type_datelist_value($element, $input = FALSE, FormStateInterface $form_state) { $parts = $element['#date_part_order']; $increment = $element['#date_increment']; @@ -871,10 +870,10 @@ function form_type_datelist_value($element, $input = FALSE, &$form_state = array * * @param array $element * The element being processed. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ -function datetime_datelist_validate($element, &$form_state) { +function datetime_datelist_validate($element, FormStateInterface $form_state) { $input_exists = FALSE; $input = NestedArray::getValue($form_state['values'], $element['#parents'], $input_exists); if ($input_exists) { @@ -1001,7 +1000,7 @@ function datetime_range_years($string, $date = NULL) { /** * Implements hook_form_BASE_FORM_ID_alter() for node forms. */ -function datetime_form_node_form_alter(&$form, &$form_state, $form_id) { +function datetime_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) { // Alter the 'Authored on' date to use datetime. $form['created']['#type'] = 'datetime'; $date_format = entity_load('date_format', 'html_date')->getPattern(); @@ -1013,7 +1012,7 @@ function datetime_form_node_form_alter(&$form, &$form_state, $form_id) { /** * Implements hook_node_prepare_form(). */ -function datetime_node_prepare_form(NodeInterface $node, $operation, array &$form_state) { +function datetime_node_prepare_form(NodeInterface $node, $operation, FormStateInterface $form_state) { // Prepare the 'Authored on' date to use datetime. $node->date = DrupalDateTime::createFromTimestamp($node->getCreatedTime()); } diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php index c282db6c82bc2934114d265652862c3f0b7cecd1..5bff36f326c9071a53f8141aabee760250e3ef74 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php @@ -12,6 +12,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Field\FormatterBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -162,7 +163,7 @@ function dateFormat($date) { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $time = new DrupalDateTime(); $format_types = $this->dateStorage->loadMultiple(); foreach ($format_types as $type => $type_info) { diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php index 75a59ec4eb96cd6600b55698f16853dbdb9657b0..4ed473b9866730671e3f138be934cd1c4a6ce79b 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemList; +use Drupal\Core\Form\FormStateInterface; /** * Represents a configurable entity datetime field. @@ -25,7 +26,7 @@ class DateTimeFieldItemList extends FieldItemList { /** * {@inheritdoc} */ - public function defaultValuesForm(array &$form, array &$form_state) { + public function defaultValuesForm(array &$form, FormStateInterface $form_state) { if (empty($this->getFieldDefinition()->default_value_function)) { $default_value = $this->getFieldDefinition()->default_value; @@ -48,12 +49,12 @@ public function defaultValuesForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function defaultValuesFormValidate(array $element, array &$form, array &$form_state) { } + public function defaultValuesFormValidate(array $element, array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ - public function defaultValuesFormSubmit(array $element, array &$form, array &$form_state) { + public function defaultValuesFormSubmit(array $element, array &$form, FormStateInterface $form_state) { if ($form_state['values']['default_value_input']['default_date']) { return array($form_state['values']['default_value_input']); } diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php index 615ca1e236c25eb48167a4dde856dab92c847023..992af1e828d8afbf753d14d3bee86176ebab3aab 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php @@ -8,6 +8,7 @@ namespace Drupal\datetime\Plugin\Field\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\Field\FieldItemBase; @@ -83,7 +84,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { $element = array(); $element['datetime_type'] = array( diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php index c9c3195a38bcb14a727536302bb05d73ffa6ae7d..6d05a063174c886769eb0916a317667604df538b 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php +++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php @@ -8,6 +8,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem; /** @@ -37,7 +38,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $date_order = $this->getSetting('date_order'); $time_type = $this->getSetting('time_type'); $increment = $this->getSetting('increment'); @@ -122,7 +123,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen /** * {@inheritdoc} */ - function settingsForm(array $form, array &$form_state) { + function settingsForm(array $form, FormStateInterface $form_state) { $element = parent::settingsForm($form, $form_state); $element['date_order'] = array( diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php index 00426c0f9c647ffa111bf91f9428cf3c92144fe8..a411eb441eaa409dcb8a7a9df71102cd6dd0f9c0 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php +++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php @@ -10,6 +10,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -60,7 +61,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { // We are nesting some sub-elements inside the parent, so we need a wrapper. // We also need to add another #title attribute at the top level for ease in // identifying this item in error messages. We do not want to display this diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module index b2068793e346e9b8831ead057586db1f5bccd7ea..c941c06b4482c4a9e6a8865eb1f476d580d7a5b9 100644 --- a/core/modules/dblog/dblog.module +++ b/core/modules/dblog/dblog.module @@ -11,6 +11,7 @@ * @see watchdog() */ +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; /** @@ -112,6 +113,6 @@ function dblog_form_system_logging_settings_alter(&$form, $form_state) { * * @see dblog_form_system_logging_settings_alter() */ -function dblog_logging_settings_submit($form, &$form_state) { +function dblog_logging_settings_submit($form, FormStateInterface $form_state) { \Drupal::config('dblog.settings')->set('row_limit', $form_state['values']['dblog_row_limit'])->save(); } diff --git a/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php b/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php index d20181bc9f20fba840e30f7febedf228b854af24..d2b6a89342f00cdabb423615608f5ad8ec7f5b7a 100644 --- a/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php +++ b/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php @@ -7,6 +7,7 @@ namespace Drupal\dblog\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\Core\Database\Connection; use Drupal\Core\Form\ConfirmFormBase; @@ -67,7 +68,7 @@ public function getCancelUrl() { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $_SESSION['dblog_overview_filter'] = array(); $this->connection->delete('watchdog')->execute(); drupal_set_message($this->t('Database log cleared.')); diff --git a/core/modules/dblog/src/Form/DblogClearLogForm.php b/core/modules/dblog/src/Form/DblogClearLogForm.php index 133ab439d2125a8cef91e01083493d511da92a72..f3781d4eb80e88e3024feb9be94b39ad04e51868 100644 --- a/core/modules/dblog/src/Form/DblogClearLogForm.php +++ b/core/modules/dblog/src/Form/DblogClearLogForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -53,7 +54,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['dblog_clear'] = array( '#type' => 'details', '#title' => $this->t('Clear log messages'), @@ -69,7 +70,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['redirect_route'] = new Url('dblog.confirm'); } diff --git a/core/modules/dblog/src/Form/DblogFilterForm.php b/core/modules/dblog/src/Form/DblogFilterForm.php index 2422472e5d2d7171bc0b334e98ed2b6fa89489d7..aae57840347749cdecb88376dd3b003b362db9b8 100644 --- a/core/modules/dblog/src/Form/DblogFilterForm.php +++ b/core/modules/dblog/src/Form/DblogFilterForm.php @@ -8,6 +8,7 @@ namespace Drupal\dblog\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides the database logging filter form. @@ -24,7 +25,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $filters = dblog_filters(); $form['filters'] = array( @@ -67,7 +68,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { if (empty($form_state['values']['type']) && empty($form_state['values']['severity'])) { $this->setFormError('type', $form_state, $this->t('You must select something to filter by.')); } @@ -76,7 +77,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $filters = dblog_filters(); foreach ($filters as $name => $filter) { if (isset($form_state['values'][$name])) { @@ -88,7 +89,7 @@ public function submitForm(array &$form, array &$form_state) { /** * Resets the filter form. */ - public function resetForm(array &$form, array &$form_state) { + public function resetForm(array &$form, FormStateInterface $form_state) { $_SESSION['dblog_overview_filter'] = array(); } diff --git a/core/modules/dblog/src/Plugin/views/field/DblogMessage.php b/core/modules/dblog/src/Plugin/views/field/DblogMessage.php index e6595d2d6b7cb0ba6977cec4d771aec6c1ce026e..6c94184599569b42d1c8b6a15c72182c8bf01f19 100644 --- a/core/modules/dblog/src/Plugin/views/field/DblogMessage.php +++ b/core/modules/dblog/src/Plugin/views/field/DblogMessage.php @@ -8,6 +8,7 @@ namespace Drupal\dblog\Plugin\views\field; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; @@ -46,7 +47,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['replace_variables'] = array( diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 40c1eb74135131dd2909d0a3ea0eea1169d635ff..4ee1dddfeabe2c04d8a076e02e46bf3c41fe0e8f 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -7,6 +7,7 @@ use Drupal\Component\Utility\Html; use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\editor\Entity\Editor; @@ -91,7 +92,7 @@ function editor_form_filter_admin_overview_alter(&$form, $form_state) { /** * Implements hook_form_BASE_FORM_ID_alter() for 'filter_format_form'. */ -function editor_form_filter_format_form_alter(&$form, &$form_state) { +function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_state) { if (!isset($form_state['editor'])) { $format_id = $form_state['controller']->getEntity()->id(); $form_state['editor'] = editor_load($format_id); @@ -168,7 +169,7 @@ function editor_form_filter_format_form_alter(&$form, &$form_state) { /** * Button submit handler for filter_format_form()'s 'editor_configure' button. */ -function editor_form_filter_admin_format_editor_configure($form, &$form_state) { +function editor_form_filter_admin_format_editor_configure($form, FormStateInterface $form_state) { $editor = $form_state['editor']; if (isset($form_state['values']['editor']['editor'])) { if ($form_state['values']['editor']['editor'] === '') { @@ -188,14 +189,14 @@ function editor_form_filter_admin_format_editor_configure($form, &$form_state) { /** * AJAX callback handler for filter_format_form(). */ -function editor_form_filter_admin_form_ajax($form, &$form_state) { +function editor_form_filter_admin_form_ajax($form, FormStateInterface $form_state) { return $form['editor']['settings']; } /** * Additional validate handler for filter_format_form(). */ -function editor_form_filter_admin_format_validate($form, &$form_state) { +function editor_form_filter_admin_format_validate($form, FormStateInterface $form_state) { // This validate handler is not applicable when using the 'Configure' button. if ($form_state['triggering_element']['#name'] === 'editor_configure') { return; @@ -213,7 +214,7 @@ function editor_form_filter_admin_format_validate($form, &$form_state) { /** * Additional submit handler for filter_format_form(). */ -function editor_form_filter_admin_format_submit($form, &$form_state) { +function editor_form_filter_admin_format_submit($form, FormStateInterface $form_state) { // Delete the existing editor if disabling or switching between editors. $format_id = $form_state['controller']->getEntity()->id(); $original_editor = editor_load($format_id); diff --git a/core/modules/editor/src/Form/EditorImageDialog.php b/core/modules/editor/src/Form/EditorImageDialog.php index 82524b60d3cf451d4dc2d08b2781ccad9b391fb8..f8c45e988c480f0669e0e1ce1280c52d43bae747 100644 --- a/core/modules/editor/src/Form/EditorImageDialog.php +++ b/core/modules/editor/src/Form/EditorImageDialog.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Bytes; use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\filter\Entity\FilterFormat; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\HtmlCommand; @@ -34,7 +35,7 @@ public function getFormId() { * @param \Drupal\filter\Entity\FilterFormat $filter_format * The filter format for which this dialog corresponds. */ - public function buildForm(array $form, array &$form_state, FilterFormat $filter_format = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, FilterFormat $filter_format = NULL) { // The default values are set directly from \Drupal::request()->request, // provided by the editor plugin opening the dialog. if (!isset($form_state['image_element'])) { @@ -184,7 +185,7 @@ public function buildForm(array $form, array &$form_state, FilterFormat $filter_ /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $response = new AjaxResponse(); // Convert any uploaded files from the FID values to data-editor-file-uuid diff --git a/core/modules/editor/src/Form/EditorLinkDialog.php b/core/modules/editor/src/Form/EditorLinkDialog.php index b0beb5bb3b609b2db099ec3b264ff477a244fce8..8f31c3c9afe52742f6a944811877d8d687dbd5d7 100644 --- a/core/modules/editor/src/Form/EditorLinkDialog.php +++ b/core/modules/editor/src/Form/EditorLinkDialog.php @@ -8,6 +8,7 @@ namespace Drupal\editor\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\filter\Entity\FilterFormat; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\HtmlCommand; @@ -32,7 +33,7 @@ public function getFormId() { * @param \Drupal\filter\Entity\FilterFormat $filter_format * The filter format for which this dialog corresponds. */ - public function buildForm(array $form, array &$form_state, FilterFormat $filter_format = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, FilterFormat $filter_format = NULL) { // The default values are set directly from \Drupal::request()->request, // provided by the editor plugin opening the dialog. $input = isset($form_state['input']['editor_object']) ? $form_state['input']['editor_object'] : array(); @@ -78,7 +79,7 @@ public function buildForm(array $form, array &$form_state, FilterFormat $filter_ /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $response = new AjaxResponse(); if (form_get_errors($form_state)) { diff --git a/core/modules/editor/src/Plugin/EditorBase.php b/core/modules/editor/src/Plugin/EditorBase.php index 32e44089fb09e00918e3fe8d9eef0ae0ab958e14..4cb1fe2fa9a50f15275aa53776b90010ae598d86 100644 --- a/core/modules/editor/src/Plugin/EditorBase.php +++ b/core/modules/editor/src/Plugin/EditorBase.php @@ -7,6 +7,7 @@ namespace Drupal\editor\Plugin; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\editor\Entity\Editor; use Drupal\editor\Plugin\EditorPluginInterface; @@ -54,20 +55,20 @@ public function getDefaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, Editor $editor) { + public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) { return $form; } /** * {@inheritdoc} */ - public function settingsFormValidate(array $form, array &$form_state) { + public function settingsFormValidate(array $form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ - public function settingsFormSubmit(array $form, array &$form_state) { + public function settingsFormSubmit(array $form, FormStateInterface $form_state) { } } diff --git a/core/modules/editor/src/Plugin/EditorPluginInterface.php b/core/modules/editor/src/Plugin/EditorPluginInterface.php index c6b6c5411fcbdafcae0cb97044f7f2e84c9bc590..10ad314e015015f012deeb302143793233cbc101 100644 --- a/core/modules/editor/src/Plugin/EditorPluginInterface.php +++ b/core/modules/editor/src/Plugin/EditorPluginInterface.php @@ -8,6 +8,7 @@ namespace Drupal\editor\Plugin; use Drupal\Component\Plugin\PluginInspectionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\editor\Entity\Editor; /** @@ -37,7 +38,7 @@ public function getDefaultSettings(); * * @param array $form * An empty form array to be populated with a configuration form, if any. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The state of the entire filter administration form. * @param \Drupal\editor\Entity\Editor $editor * A configured text editor object. @@ -45,7 +46,7 @@ public function getDefaultSettings(); * @return array * A render array for the settings form. */ - public function settingsForm(array $form, array &$form_state, Editor $editor); + public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor); /** * Validates the settings form for an editor. @@ -56,10 +57,10 @@ public function settingsForm(array $form, array &$form_state, Editor $editor); * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function settingsFormValidate(array $form, array &$form_state); + public function settingsFormValidate(array $form, FormStateInterface $form_state); /** * Modifies any values in the form state to prepare them for saving. @@ -69,10 +70,10 @@ public function settingsFormValidate(array $form, array &$form_state); * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function settingsFormSubmit(array $form, array &$form_state); + public function settingsFormSubmit(array $form, FormStateInterface $form_state); /** * Returns JavaScript settings to be attached. diff --git a/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php b/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php index 5015759dc42ade8a2879be713879a4ff98577a67..6937fb25f8e7104d3d0c82f91d74a860b154a5b1 100644 --- a/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php +++ b/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php @@ -7,6 +7,7 @@ namespace Drupal\editor_test\Plugin\Editor; +use Drupal\Core\Form\FormStateInterface; use Drupal\editor\Plugin\EditorBase; use Drupal\editor\Entity\Editor as EditorEntity; @@ -33,7 +34,7 @@ function getDefaultSettings() { /** * {@inheritdoc} */ - function settingsForm(array $form, array &$form_state, EditorEntity $editor) { + function settingsForm(array $form, FormStateInterface $form_state, EditorEntity $editor) { $form['foo'] = array( '#title' => t('Foo'), '#type' => 'textfield', diff --git a/core/modules/entity/src/Entity/EntityFormDisplay.php b/core/modules/entity/src/Entity/EntityFormDisplay.php index 836503274f91280c91905fba401e782f3e604fc0..6457e236602a0db41691fe85aa270e83a7b4d6a9 100644 --- a/core/modules/entity/src/Entity/EntityFormDisplay.php +++ b/core/modules/entity/src/Entity/EntityFormDisplay.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\Display\EntityFormDisplayInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\entity\EntityDisplayBase; /** @@ -148,7 +149,7 @@ public function getRenderer($field_name) { /** * {@inheritdoc} */ - public function buildForm(ContentEntityInterface $entity, array &$form, array &$form_state) { + public function buildForm(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state) { // Set #parents to 'top-level' by default. $form += array('#parents' => array()); @@ -197,7 +198,7 @@ public function processForm($element, $form_state, $form) { /** * {@inheritdoc} */ - public function extractFormValues(ContentEntityInterface $entity, array &$form, array &$form_state) { + public function extractFormValues(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state) { $extracted = array(); foreach ($entity as $name => $items) { if ($widget = $this->getRenderer($name)) { @@ -211,7 +212,7 @@ public function extractFormValues(ContentEntityInterface $entity, array &$form, /** * {@inheritdoc} */ - public function validateFormValues(ContentEntityInterface $entity, array &$form, array &$form_state) { + public function validateFormValues(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state) { foreach ($entity as $field_name => $items) { // Only validate the fields that actually appear in the form, and let the // widget assign the violations to the right form elements. diff --git a/core/modules/entity/src/Form/EntityDisplayModeAddForm.php b/core/modules/entity/src/Form/EntityDisplayModeAddForm.php index 49be44f55501fd49bd38420a3eaf2c6790e6ff6d..296fde24df4c0319f0efae06ac52a8c659070600 100644 --- a/core/modules/entity/src/Form/EntityDisplayModeAddForm.php +++ b/core/modules/entity/src/Form/EntityDisplayModeAddForm.php @@ -7,6 +7,7 @@ namespace Drupal\entity\Form; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -24,7 +25,7 @@ class EntityDisplayModeAddForm extends EntityDisplayModeFormBase { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $entity_type_id = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL) { $this->targetEntityTypeId = $entity_type_id; $form = parent::buildForm($form, $form_state); // Change replace_pattern to avoid undesired dots. @@ -37,7 +38,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); form_set_value($form['id'], $this->targetEntityTypeId . '.' . $form_state['values']['id'], $form_state); diff --git a/core/modules/entity/src/Form/EntityDisplayModeDeleteForm.php b/core/modules/entity/src/Form/EntityDisplayModeDeleteForm.php index 091d5fe7f40e05dff2f6e1bf618ac0decc82a54d..b76d56b0ce0d3c6321c32e1ce0ac074e293bd305 100644 --- a/core/modules/entity/src/Form/EntityDisplayModeDeleteForm.php +++ b/core/modules/entity/src/Form/EntityDisplayModeDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\entity\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -48,7 +49,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); $entity_type = $this->entity->getEntityType(); diff --git a/core/modules/entity/src/Form/EntityDisplayModeFormBase.php b/core/modules/entity/src/Form/EntityDisplayModeFormBase.php index e848413e0de9ac8c9d5a02bf9edb14612f6a106c..52e3388382f0f0385f0621762e96331d630e6d82 100644 --- a/core/modules/entity/src/Form/EntityDisplayModeFormBase.php +++ b/core/modules/entity/src/Form/EntityDisplayModeFormBase.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -64,7 +65,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - protected function init(array &$form_state) { + protected function init(FormStateInterface $form_state) { parent::init($form_state); $this->entityType = $this->entityManager->getDefinition($this->entity->getEntityTypeId()); } @@ -72,7 +73,7 @@ protected function init(array &$form_state) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form['label'] = array( '#type' => 'textfield', '#title' => t('Label'), @@ -102,13 +103,11 @@ public function form(array $form, array &$form_state) { * The entity ID. * @param array $element * The form element. - * @param array $form_state - * The form state. * * @return bool * TRUE if the display mode exists, FALSE otherwise. */ - public function exists($entity_id, array $element, array $form_state) { + public function exists($entity_id, array $element) { // Do not allow to add internal 'default' view mode. if ($entity_id == 'default') { return TRUE; @@ -122,7 +121,7 @@ public function exists($entity_id, array $element, array $form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { drupal_set_message(t('Saved the %label @entity-type.', array('%label' => $this->entity->label(), '@entity-type' => $this->entityType->getLowercaseLabel()))); $this->entity->save(); \Drupal::entityManager()->clearCachedFieldDefinitions(); diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index 7fcc560f6b41b0127ef6987801bf7cff52fcfbee..d1babc8daaf8764c2dba3389247a144a00cc6c06 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -7,6 +7,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Database\Query\AlterableInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\field\Entity\FieldStorageConfig; @@ -147,7 +148,7 @@ function _entity_reference_form_process_merge_parent($element) { /** * Form element validation handler; Filters the #value property of an element. */ -function _entity_reference_element_validate_filter(&$element, &$form_state) { +function _entity_reference_element_validate_filter(&$element, FormStateInterface $form_state) { $element['#value'] = array_filter($element['#value']); form_set_value($element, $element['#value'], $form_state); } @@ -167,7 +168,7 @@ function entity_reference_settings_ajax($form, $form_state) { * * @see entity_reference_field_instance_settings_form() */ -function entity_reference_settings_ajax_submit($form, &$form_state) { +function entity_reference_settings_ajax_submit($form, FormStateInterface $form_state) { $form_state['rebuild'] = TRUE; } diff --git a/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php index 269ad8c0e5af4310d6709aeb8f3c95ae7c4dc7de..032a36592263f8816e46a45675c4220f67a5c57c 100644 --- a/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\OptGroup; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\AllowedValuesInterface; @@ -159,7 +160,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { $element['target_type'] = array( '#type' => 'select', '#title' => t('Type of item to reference'), @@ -176,7 +177,7 @@ public function settingsForm(array &$form, array &$form_state, $has_data) { /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { $instance = $form_state['instance']; // Get all selection plugins for this entity type. @@ -247,10 +248,10 @@ public function instanceSettingsForm(array $form, array &$form_state) { * * @param array $form * The form where the settings form is being included in. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state of the (entire) configuration form. */ - public static function instanceSettingsFormValidate(array $form, array &$form_state) { + public static function instanceSettingsFormValidate(array $form, FormStateInterface $form_state) { if (isset($form_state['values']['instance'])) { unset($form_state['values']['instance']['settings']['handler_submit']); $form_state['instance']->settings = $form_state['values']['instance']['settings']; diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php index 15f1df117f4462d1516f1d1c6981d762f7967668..448343e9c01a409d5d596601265cf35ae3809560 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php @@ -8,6 +8,7 @@ namespace Drupal\entity_reference\Plugin\Field\FieldFormatter; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\entity_reference\RecursiveRenderingException; /** @@ -37,7 +38,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $elements['view_mode'] = array( '#type' => 'select', '#options' => \Drupal::entityManager()->getViewModeOptions($this->getFieldSetting('target_type')), diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php index 54a1ae786796f52a155ec995f649d0b56866b13e..154759f2329be01dd48b9dad67e72192a3b3dd62 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'entity reference label' formatter. @@ -36,7 +37,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $elements['link'] = array( '#title' => t('Link label to the referenced entity'), '#type' => 'checkbox', diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php b/core/modules/entity_reference/src/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php index 3d4bec31aafbc522298903086eae8b034dc580ad..25d854677ae06be5eceac9028c2c120f9963bd79 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php @@ -10,6 +10,7 @@ use Drupal\Core\Field\EntityReferenceFieldItemList; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; /** * Represents a configurable entity_reference entity field. @@ -73,7 +74,7 @@ public static function processDefaultValue($default_value, ContentEntityInterfac /** * {@inheritdoc} */ - public function defaultValuesFormSubmit(array $element, array &$form, array &$form_state) { + public function defaultValuesFormSubmit(array $element, array &$form, FormStateInterface $form_state) { $default_value = parent::defaultValuesFormSubmit($element, $form, $form_state); // Convert numeric IDs to UUIDs to ensure config deployability. diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteTagsWidget.php b/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteTagsWidget.php index f930de2890954a67662eea248e921161bc38a3e5..b289a0641cd4a9cc5cf163272a54590176935fba 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteTagsWidget.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteTagsWidget.php @@ -8,6 +8,7 @@ namespace Drupal\entity_reference\Plugin\Field\FieldWidget; use Drupal\Component\Utility\Tags; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'entity_reference autocomplete-tags' widget. @@ -39,7 +40,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function elementValidate($element, &$form_state, $form) { + public function elementValidate($element, FormStateInterface $form_state, $form) { $value = array(); // If a value was entered into the autocomplete. $handler = \Drupal::service('plugin.manager.entity_reference.selection')->getSelectionHandler($this->fieldDefinition); diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidget.php b/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidget.php index 234eb7ab19989ad91022ec620e056b09bd455d37..3633b5db593967ebaf691e1a4b0212d59678dddf 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidget.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidget.php @@ -8,6 +8,7 @@ namespace Drupal\entity_reference\Plugin\Field\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'entity_reference autocomplete' widget. @@ -57,7 +58,7 @@ protected function getEntityIds(FieldItemListInterface $items, $delta) { /** * {@inheritdoc} */ - public function elementValidate($element, &$form_state, $form) { + public function elementValidate($element, FormStateInterface $form_state, $form) { $auto_create = $this->getSelectionHandlerSetting('auto_create'); // If a value was entered into the autocomplete. diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php b/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php index 2ed1dfee063a3acf4760f5773cb87225109ad0a7..975ec4f1796966330b8c97762555e350aae2ebd5 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Tags; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\user\EntityOwnerInterface; use Symfony\Component\Validator\ConstraintViolationInterface; @@ -21,7 +22,7 @@ abstract class AutocompleteWidgetBase extends WidgetBase { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['match_operator'] = array( '#type' => 'radios', '#title' => t('Autocomplete matching'), @@ -70,7 +71,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $entity = $items->getEntity(); // Prepare the autocomplete route parameters. @@ -103,14 +104,14 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen /** * {@inheritdoc} */ - public function errorElement(array $element, ConstraintViolationInterface $error, array $form, array &$form_state) { + public function errorElement(array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state) { return $element['target_id']; } /** * Validates an element. */ - public function elementValidate($element, &$form_state, $form) { } + public function elementValidate($element, FormStateInterface $form_state, $form) { } /** * Gets the entity labels. diff --git a/core/modules/entity_reference/src/Plugin/Type/Selection/SelectionBroken.php b/core/modules/entity_reference/src/Plugin/Type/Selection/SelectionBroken.php index eab272ec8331d8dcabc5c5d8e2760001f72e6fce..37a526448d2cf056a7dcc69a0b76d814b06bc159 100644 --- a/core/modules/entity_reference/src/Plugin/Type/Selection/SelectionBroken.php +++ b/core/modules/entity_reference/src/Plugin/Type/Selection/SelectionBroken.php @@ -9,6 +9,7 @@ use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; /** * A null implementation of SelectionInterface. @@ -49,7 +50,7 @@ public function validateReferenceableEntities(array $ids) { /** * {@inheritdoc} */ - public function validateAutocompleteInput($input, &$element, &$form_state, $form, $strict = TRUE) { } + public function validateAutocompleteInput($input, &$element, FormStateInterface $form_state, $form, $strict = TRUE) { } /** * {@inheritdoc} diff --git a/core/modules/entity_reference/src/Plugin/Type/Selection/SelectionInterface.php b/core/modules/entity_reference/src/Plugin/Type/Selection/SelectionInterface.php index 28fc2c54b51e84b9f27b1f298c331de6f173a6e1..eb3b8aeabfc9bd014b2a16f487c70a9a65c6e894 100644 --- a/core/modules/entity_reference/src/Plugin/Type/Selection/SelectionInterface.php +++ b/core/modules/entity_reference/src/Plugin/Type/Selection/SelectionInterface.php @@ -9,6 +9,7 @@ use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; /** * Interface definition for Entity Reference Selection plugins. @@ -54,6 +55,10 @@ public function validateReferenceableEntities(array $ids); * Single string from autocomplete widget. * @param array $element * The form element to set a form error. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current form state. + * @param array $form + * The form. * @param boolean $strict * Whether to trigger a form error if an element from $input (eg. an entity) * is not found. Defaults to TRUE. @@ -63,7 +68,7 @@ public function validateReferenceableEntities(array $ids); * * @see \Drupal\entity_reference\Plugin\Field\FieldWidget::elementValidate() */ - public function validateAutocompleteInput($input, &$element, &$form_state, $form, $strict = TRUE); + public function validateAutocompleteInput($input, &$element, FormStateInterface $form_state, $form, $strict = TRUE); /** * Allows the selection to alter the SelectQuery generated by EntityFieldQuery. diff --git a/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php b/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php index 11ee6cd0b0d4bb50a16986b545f779a16ca3d25c..fbb653706b231139343863f69ecf501efa645db1 100644 --- a/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php +++ b/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php @@ -12,6 +12,7 @@ use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\entity_reference\Plugin\Type\Selection\SelectionInterface; /** @@ -229,7 +230,7 @@ public function validateReferenceableEntities(array $ids) { /** * {@inheritdoc} */ - public function validateAutocompleteInput($input, &$element, &$form_state, $form, $strict = TRUE) { + public function validateAutocompleteInput($input, &$element, FormStateInterface $form_state, $form, $strict = TRUE) { $bundled_entities = $this->getReferenceableEntities($input, '=', 6); $entities = array(); foreach ($bundled_entities as $entities_list) { diff --git a/core/modules/entity_reference/src/Plugin/views/row/EntityReference.php b/core/modules/entity_reference/src/Plugin/views/row/EntityReference.php index b975b0acd0218a8dc9ed10ab0d25b5b1f5a4516a..8434e971f39cbaa9746b2f1fc2a8a2b54c0bdf9e 100644 --- a/core/modules/entity_reference/src/Plugin/views/row/EntityReference.php +++ b/core/modules/entity_reference/src/Plugin/views/row/EntityReference.php @@ -7,6 +7,7 @@ namespace Drupal\entity_reference\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\row\Fields; /** @@ -38,7 +39,7 @@ protected function defineOptions() { /** * Overrides \Drupal\views\Plugin\views\row\Fields::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Expand the description of the 'Inline field' checkboxes. diff --git a/core/modules/entity_reference/src/Plugin/views/style/EntityReference.php b/core/modules/entity_reference/src/Plugin/views/style/EntityReference.php index 37a446b91c0cdb0516bb74bface10f88e1409193..d0b3bbe49860844a5aee789b1ec9cb00d27ea9a8 100644 --- a/core/modules/entity_reference/src/Plugin/views/style/EntityReference.php +++ b/core/modules/entity_reference/src/Plugin/views/style/EntityReference.php @@ -8,6 +8,7 @@ namespace Drupal\entity_reference\Plugin\views\style; use Drupal\Component\Utility\Xss; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\style\StylePluginBase; /** @@ -54,7 +55,7 @@ protected function defineOptions() { /** * Overrides \Drupal\views\Plugin\views\style\StylePluginBase\StylePluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $options = $this->displayHandler->getFieldLabels(TRUE); diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index 62a8c1cad43377c8708f74f804411a71b6d24b65..543561e7b0aa7ea91716734275c5da305a3e9999 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -105,7 +105,7 @@ function hook_field_widget_info_alter(array &$info) { * @param $element * The field widget form element as constructed by hook_field_widget_form(). * @param $form_state - * An associative array containing the current state of the form. + * The current state of the form. * @param $context * An associative array containing the following key-value pairs: * - form: The form structure to which widgets are being attached. This may be @@ -120,7 +120,7 @@ function hook_field_widget_info_alter(array &$info) { * @see \Drupal\Core\Field\WidgetBase::formSingleElement() * @see hook_field_widget_WIDGET_TYPE_form_alter() */ -function hook_field_widget_form_alter(&$element, &$form_state, $context) { +function hook_field_widget_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) { // Add a css class to widget form elements for all fields of type mytype. $field_definition = $context['items']->getFieldDefinition(); if ($field_definition->getType() == 'mytype') { @@ -139,7 +139,7 @@ function hook_field_widget_form_alter(&$element, &$form_state, $context) { * @param $element * The field widget form element as constructed by hook_field_widget_form(). * @param $form_state - * An associative array containing the current state of the form. + * The current state of the form. * @param $context * An associative array. See hook_field_widget_form_alter() for the structure * and content of the array. @@ -147,7 +147,7 @@ function hook_field_widget_form_alter(&$element, &$form_state, $context) { * @see \Drupal\Core\Field\WidgetBase::formSingleElement() * @see hook_field_widget_form_alter() */ -function hook_field_widget_WIDGET_TYPE_form_alter(&$element, &$form_state, $context) { +function hook_field_widget_WIDGET_TYPE_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) { // Code here will only act on widgets of type WIDGET_TYPE. For example, // hook_field_widget_mymodule_autocomplete_form_alter() will only act on // widgets of type 'mymodule_autocomplete'. diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 444a92dbf43232adf6fc1b43428cce1a5529a463..8bcb693e0a7862134d7eeb4a2dd5761753e9ed1c 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -10,6 +10,7 @@ use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Extension\Extension; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; /* @@ -344,7 +345,7 @@ function field_config_import_steps_alter(&$sync_steps, ConfigImporter $config_im * * @see \Drupal\field\ConfigImporterFieldPurger */ -function field_form_config_admin_import_form_alter(&$form, &$form_state) { +function field_form_config_admin_import_form_alter(&$form, FormStateInterface $form_state) { // Only display the message when there is a storage comparer available and the // form is not submitted. if (isset($form_state['storage_comparer']) && empty($form_state['input'])) { diff --git a/core/modules/field/src/Plugin/views/argument/FieldList.php b/core/modules/field/src/Plugin/views/argument/FieldList.php index 5bfd9350dd385526c04f443e515c41ad9b56d0b6..08c7756eed334daa119830598198962d5d173534 100644 --- a/core/modules/field/src/Plugin/views/argument/FieldList.php +++ b/core/modules/field/src/Plugin/views/argument/FieldList.php @@ -8,6 +8,7 @@ namespace Drupal\field\Plugin\views\argument; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\argument\Numeric; @@ -47,7 +48,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['summary']['human'] = array( diff --git a/core/modules/field/src/Plugin/views/argument/ListString.php b/core/modules/field/src/Plugin/views/argument/ListString.php index 02d049a55b8a0baf2a1aa93f16bd186f42398913..eee75e2d4a564dcc3e510cbdffc27eb4048e379e 100644 --- a/core/modules/field/src/Plugin/views/argument/ListString.php +++ b/core/modules/field/src/Plugin/views/argument/ListString.php @@ -8,6 +8,7 @@ namespace Drupal\field\Plugin\views\argument; use Drupal\Component\Utility\String as UtilityString; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\argument\String; @@ -48,7 +49,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['summary']['human'] = array( diff --git a/core/modules/field/src/Plugin/views/field/Field.php b/core/modules/field/src/Plugin/views/field/Field.php index ad3543b4652680aa3f884bd6386697a3d5ba3be1..e4103f38f73a8f5e4b067bbea5c1126f29bcce1c 100644 --- a/core/modules/field/src/Plugin/views/field/Field.php +++ b/core/modules/field/src/Plugin/views/field/Field.php @@ -16,6 +16,7 @@ use Drupal\Core\Field\FieldDefinition; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FormatterPluginManager; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManager; use Drupal\Core\Render\Element; @@ -435,7 +436,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $field = $this->getFieldDefinition(); @@ -516,7 +517,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Provide options for multiple value fields. */ - function multiple_options_form(&$form, &$form_state) { + function multiple_options_form(&$form, FormStateInterface $form_state) { $field = $this->getFieldDefinition(); $form['multiple_field_settings'] = array( @@ -639,7 +640,7 @@ function multiple_options_form(&$form, &$form_state) { /** * Extend the groupby form with group columns. */ - public function buildGroupByForm(&$form, &$form_state) { + public function buildGroupByForm(&$form, FormStateInterface $form_state) { parent::buildGroupByForm($form, $form_state); // With "field API" fields, the column target of the grouping function // and any additional grouping columns must be specified. @@ -672,7 +673,7 @@ public function buildGroupByForm(&$form, &$form_state) { ); } - public function submitGroupByForm(&$form, &$form_state) { + public function submitGroupByForm(&$form, FormStateInterface $form_state) { parent::submitGroupByForm($form, $form_state); $item = &$form_state['handler']->options; diff --git a/core/modules/field/src/Tests/FieldAttachOtherTest.php b/core/modules/field/src/Tests/FieldAttachOtherTest.php index 7356bcebaa11f05ca7085a476b60a4019a21bfdd..a74e4d28653fd92034df5f00205f20616fffae96 100644 --- a/core/modules/field/src/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/src/Tests/FieldAttachOtherTest.php @@ -7,6 +7,7 @@ namespace Drupal\field\Tests; +use Drupal\Core\Form\FormState; use Drupal\Core\Language\LanguageInterface; /** @@ -265,7 +266,7 @@ function testEntityFormDisplayBuildForm() { // Test generating widgets for all fields. $display = entity_get_form_display($entity_type, $this->instance->bundle, 'default'); $form = array(); - $form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $form_state = new FormState(); $display->buildForm($entity, $form, $form_state); $this->assertEqual($form[$this->field_name]['widget']['#title'], $this->instance->getLabel(), "First field's form title is {$this->instance->getLabel()}"); @@ -287,7 +288,7 @@ function testEntityFormDisplayBuildForm() { } } $form = array(); - $form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $form_state = new FormState(); $display->buildForm($entity, $form, $form_state); $this->assertFalse(isset($form[$this->field_name]), 'The first field does not exist in the form'); @@ -310,7 +311,7 @@ function testEntityFormDisplayExtractFormValues() { // Build the form for all fields. $display = entity_get_form_display($entity_type, $this->instance->bundle, 'default'); $form = array(); - $form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $form_state = new FormState(); $display->buildForm($entity_init, $form, $form_state); // Simulate incoming values. diff --git a/core/modules/field/src/Tests/FormTest.php b/core/modules/field/src/Tests/FormTest.php index 2457aa72a90753ca3f598543a6bcf62eaba8c7a8..262a96ddadda4e1066b752bc62026feb13e24daf 100644 --- a/core/modules/field/src/Tests/FormTest.php +++ b/core/modules/field/src/Tests/FormTest.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Form\FormState; /** * Tests field form handling. @@ -531,7 +532,7 @@ function testFieldFormAccess() { $display = entity_get_form_display($entity_type, $entity_type, 'default'); $form = array(); - $form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $form_state = new FormState(); $display->buildForm($entity, $form, $form_state); $this->assertFalse($form[$field_name_no_access]['#access'], 'Field #access is FALSE for the field without edit access.'); diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index 13c846dbbf89d335851caaaff27e7e17489cf6a0..499c8832e98dcdfc9e75326ed2462838ae91230b 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -2,6 +2,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\field\FieldStorageConfigInterface; +use Drupal\Core\Form\FormStateInterface; /** * @file @@ -115,7 +116,7 @@ function field_test_entity_display_build_alter(&$output, $context) { /** * Implements hook_field_widget_form_alter(). */ -function field_test_field_widget_form_alter(&$element, &$form_state, $context) { +function field_test_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) { $field_definition = $context['items']->getFieldDefinition(); switch ($field_definition->getName()) { case 'alter_test_text': diff --git a/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php b/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php index 89aa42c02f7e659aeb0a5d30d540b74bbeabf021..ea5a30e010c52cd46b2bd9e5ac0f06d805190966 100644 --- a/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php +++ b/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\entity\Entity\EntityFormDisplay; /** @@ -26,7 +27,7 @@ public function getFormId() { /** * {@inheritdoc] */ - public function buildForm(array $form, array &$form_state, EntityInterface $entity_1 = NULL, EntityInterface $entity_2 = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity_1 = NULL, EntityInterface $entity_2 = NULL) { // First entity. $form_state['entity_1'] = $entity_1; $form_state['form_display_1'] = EntityFormDisplay::collectRenderDisplay($entity_1, 'default'); @@ -57,7 +58,7 @@ public function buildForm(array $form, array &$form_state, EntityInterface $enti /** * {@inheritdoc] */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $entity_1 = $form_state['entity_1']; /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display_1 */ $form_display_1 = $form_state['form_display_1']; @@ -74,7 +75,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc] */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { /** @var \Drupal\Core\Entity\EntityInterface $entity_1 */ $entity_1 = $form_state['entity_1']; $entity_1->save(); diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php index 3e61ca1cea8b714c29574c3f4dca57b40510decb..d195a31d3e35a1ad33932ad1653ac0d1cb980cce 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'field_test_default' formatter. @@ -37,7 +38,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['test_formatter_setting'] = array( '#title' => t('Setting'), '#type' => 'textfield', diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php index 7cd25fb2c0c412a0fa393453b1709011e9d21f2d..84938ece0285679f0c30956f14f47e72bdb1e4a0 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'field_empty_setting' formatter. @@ -36,7 +37,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['field_empty_setting'] = array( '#title' => t('Setting'), '#type' => 'textfield', diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php index 1aeb570db846711f515530e5d3d5c261f5ca486e..a310ad3e321a8d867759ffde098e8ff43fa8db5e 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'field_test_multiple' formatter. @@ -37,7 +38,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['test_formatter_setting_multiple'] = array( '#title' => t('Setting'), '#type' => 'textfield', diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php index beb17e9de486d67df9834d84c906692dc9443f38..211c1cdf1b7ab7def3b665a9f8b99ce3f564400d 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'field_test_with_prepare_view' formatter. @@ -37,7 +38,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['test_formatter_setting_additional'] = array( '#title' => t('Setting'), '#type' => 'textfield', diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php index 45302e39c359ae9f39363808cbbcaf05624b2394..52349643798223f0ef0c980ed2de13175f290fcd 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php @@ -8,6 +8,7 @@ namespace Drupal\field_test\Plugin\Field\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\Field\FieldItemBase; @@ -76,7 +77,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { $form['test_field_storage_setting'] = array( '#type' => 'textfield', '#title' => t('Field test field storage setting'), @@ -91,7 +92,7 @@ public function settingsForm(array &$form, array &$form_state, $has_data) { /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { $form['test_instance_setting'] = array( '#type' => 'textfield', '#title' => t('Field test field instance setting'), diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php index 1fcc8bc20ef717b512bf99056a8cb00303811c61..71b8afaa54617b71082cfb22fc4f2389079bfcce 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\Validator\ConstraintViolationInterface; /** @@ -38,7 +39,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['test_widget_setting'] = array( '#type' => 'textfield', '#title' => t('Field test field widget setting'), @@ -61,7 +62,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element += array( '#type' => 'textfield', '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : '', @@ -72,7 +73,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen /** * {@inheritdoc} */ - public function errorElement(array $element, ConstraintViolationInterface $error, array $form, array &$form_state) { + public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) { return $element['value']; } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php index ac4609ce61fc7a60490f6739b17991e230fc17ea..5ad37f483d0ff7fa0f27f26bd7f37514ff6e1f9a 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\Validator\ConstraintViolationInterface; /** @@ -40,7 +41,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['test_widget_setting_multiple'] = array( '#type' => 'textfield', '#title' => t('Field test field widget setting'), @@ -63,7 +64,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $values = array(); foreach ($items as $item) { $values[] = $item->value; @@ -79,14 +80,14 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen /** * {@inheritdoc} */ - public function errorElement(array $element, ConstraintViolationInterface $error, array $form, array &$form_state) { + public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) { return $element; } /** * Element validation helper. */ - public static function multipleValidate($element, &$form_state) { + public static function multipleValidate($element, FormStateInterface $form_state) { $values = array_map('trim', explode(',', $element['#value'])); $items = array(); foreach ($values as $value) { diff --git a/core/modules/field_ui/field_ui.api.php b/core/modules/field_ui/field_ui.api.php index 070f020d911fb3830e6e082161d704604b803d51..b67d89b17b03a96496cff22665f496ed1d1fc82a 100644 --- a/core/modules/field_ui/field_ui.api.php +++ b/core/modules/field_ui/field_ui.api.php @@ -21,7 +21,7 @@ * The entity view mode. * @param array $form * The (entire) configuration form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. * * @return array @@ -54,7 +54,7 @@ function hook_field_formatter_third_party_settings_form(\Drupal\Core\Field\Forma * The entity form mode. * @param array $form * The (entire) configuration form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. * * @return array diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 4d475b4051b7dcfd2081295378bc91852537e696..336b5877c649eb0849d1f89f88c2686d7022f246 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -6,6 +6,7 @@ */ use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\entity\EntityViewModeInterface; @@ -198,7 +199,7 @@ function field_ui_entity_operation(EntityInterface $entity) { * * @see field_ui_form_node_type_form_alter() */ -function field_ui_form_node_type_form_submit($form, &$form_state) { +function field_ui_form_node_type_form_submit($form, FormStateInterface $form_state) { if ($form_state['triggering_element']['#parents'][0] === 'save_continue' && $route_info = FieldUI::getOverviewRouteInfo('node', $form_state['values']['type'])) { $form_state['redirect_route'] = $route_info; } diff --git a/core/modules/field_ui/src/DisplayOverview.php b/core/modules/field_ui/src/DisplayOverview.php index 3c55ec0afaae55ce36a703b4087f8026e8db9af1..6d5a677eddaded7c46e5b8c70788964bb0e79470 100644 --- a/core/modules/field_ui/src/DisplayOverview.php +++ b/core/modules/field_ui/src/DisplayOverview.php @@ -16,6 +16,7 @@ use Drupal\Core\Field\FieldTypePluginManager; use Drupal\Core\Field\FormatterInterface; use Drupal\Core\Field\PluginSettingsInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -77,7 +78,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $entity_type_id = NULL, $bundle = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $bundle = NULL) { if ($this->getRequest()->attributes->has('view_mode_name')) { $this->mode = $this->getRequest()->attributes->get('view_mode_name'); } @@ -88,7 +89,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL /** * {@inheritdoc} */ - protected function buildFieldRow(FieldDefinitionInterface $field_definition, EntityDisplayInterface $entity_display, array $form, array &$form_state) { + protected function buildFieldRow(FieldDefinitionInterface $field_definition, EntityDisplayInterface $entity_display, array $form, FormStateInterface $form_state) { $field_row = parent::buildFieldRow($field_definition, $entity_display, $form, $form_state); $field_name = $field_definition->getName(); @@ -233,7 +234,7 @@ protected function getFieldLabelOptions() { /** * {@inheritdoc} */ - protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, array &$form_state) { + protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) { $settings_form = array(); // Invoke hook_field_formatter_third_party_settings_form(), keying resulting // subforms by module name. diff --git a/core/modules/field_ui/src/DisplayOverviewBase.php b/core/modules/field_ui/src/DisplayOverviewBase.php index f4503137d7429e94e09db978ca609c91b4ef8138..e76b6b6dfa17cfe156730cec61280a7bfab3eb89 100644 --- a/core/modules/field_ui/src/DisplayOverviewBase.php +++ b/core/modules/field_ui/src/DisplayOverviewBase.php @@ -16,6 +16,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Field\PluginSettingsInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -116,7 +117,7 @@ protected function getFieldDefinitions() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $entity_type_id = NULL, $bundle = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $bundle = NULL) { parent::buildForm($form, $form_state, $entity_type_id, $bundle); if (empty($this->mode)) { @@ -127,10 +128,6 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL $extra_fields = $this->getExtraFields(); $entity_display = $this->getEntityDisplay($this->mode); - $form_state += array( - 'plugin_settings_edit' => NULL, - ); - $form += array( '#entity_type' => $this->entity_type, '#bundle' => $this->bundle, @@ -257,13 +254,13 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL * The entity display. * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * A table row array. */ - protected function buildFieldRow(FieldDefinitionInterface $field_definition, EntityDisplayInterface $entity_display, array $form, array &$form_state) { + protected function buildFieldRow(FieldDefinitionInterface $field_definition, EntityDisplayInterface $entity_display, array $form, FormStateInterface $form_state) { $field_name = $field_definition->getName(); $display_options = $entity_display->getComponent($field_name); $label = $field_definition->getLabel(); @@ -509,7 +506,7 @@ protected function buildExtraFieldRow($field_id, $extra_field, EntityDisplayInte /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_values = $form_state['values']; $display = $this->getEntityDisplay($this->mode); @@ -615,7 +612,7 @@ public function submitForm(array &$form, array &$form_state) { /** * Form submission handler for multistep buttons. */ - public function multistepSubmit($form, &$form_state) { + public function multistepSubmit($form, FormStateInterface $form_state) { $trigger = $form_state['triggering_element']; $op = $trigger['#op']; @@ -659,7 +656,7 @@ public function multistepSubmit($form, &$form_state) { /** * Ajax handler for multistep buttons. */ - public function multistepAjax($form, &$form_state) { + public function multistepAjax($form, FormStateInterface $form_state) { $trigger = $form_state['triggering_element']; $op = $trigger['#op']; @@ -887,13 +884,13 @@ abstract protected function getOverviewRoute($mode); * The field definition. * @param array $form * The (entire) configuration form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. * * @return array * The widget or formatter third party settings form. */ - abstract protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, array &$form_state); + abstract protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state); /** * Alters the widget or formatter settings summary. diff --git a/core/modules/field_ui/src/FieldOverview.php b/core/modules/field_ui/src/FieldOverview.php index c962dc9ca9f438729bc70cbb34741723e620cf45..ed2ef0b6639d0c1a908ab007d4c7f1266cec0625 100644 --- a/core/modules/field_ui/src/FieldOverview.php +++ b/core/modules/field_ui/src/FieldOverview.php @@ -12,6 +12,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\field_ui\OverviewBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -77,7 +78,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $entity_type_id = NULL, $bundle = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $bundle = NULL) { parent::buildForm($form, $form_state, $entity_type_id, $bundle); // Gather bundle information. @@ -281,7 +282,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $this->validateAddNew($form, $form_state); $this->validateAddExisting($form, $form_state); } @@ -291,12 +292,12 @@ public function validateForm(array &$form, array &$form_state) { * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @see \Drupal\field_ui\FieldOverview::validateForm() */ - protected function validateAddNew(array $form, array &$form_state) { + protected function validateAddNew(array $form, FormStateInterface $form_state) { $field = $form_state['values']['fields']['_add_new_field']; // Validate if any information was provided in the 'add new field' row. @@ -331,12 +332,12 @@ protected function validateAddNew(array $form, array &$form_state) { * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @see \Drupal\field_ui\FieldOverview::validate() */ - protected function validateAddExisting(array $form, array &$form_state) { + protected function validateAddExisting(array $form, FormStateInterface $form_state) { // The form element might be absent if no existing fields can be added to // this bundle. if (isset($form_state['values']['fields']['_add_existing_field'])) { @@ -361,7 +362,7 @@ protected function validateAddExisting(array $form, array &$form_state) { /** * Overrides \Drupal\field_ui\OverviewBase::submitForm(). */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $error = FALSE; $form_values = $form_state['values']['fields']; $destinations = array(); diff --git a/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php b/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php index 95f84f645ec2b35876d3468466d171eccebbfa8c..940d991da4a5131f2de1c95f6fa3286eedaee64c 100644 --- a/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php +++ b/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\field_ui\FieldUI; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -67,7 +68,7 @@ public function getCancelUrl() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $field_storage = $this->entity->getFieldStorageDefinition(); $bundles = entity_get_bundles(); $bundle_label = $bundles[$this->entity->entity_type][$this->entity->bundle]['label']; diff --git a/core/modules/field_ui/src/Form/FieldInstanceEditForm.php b/core/modules/field_ui/src/Form/FieldInstanceEditForm.php index 12f881dffc0a6de46ecebdcd23641c2852e51dbc..b03fd16340119133955b7dee71bfdfd9aa9d74f7 100644 --- a/core/modules/field_ui/src/Form/FieldInstanceEditForm.php +++ b/core/modules/field_ui/src/Form/FieldInstanceEditForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormBase; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\field\FieldInstanceConfigInterface; use Drupal\field_ui\FieldUI; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -62,7 +63,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, FieldInstanceConfigInterface $field_instance_config = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, FieldInstanceConfigInterface $field_instance_config = NULL) { $this->instance = $form_state['instance'] = $field_instance_config; $bundle = $this->instance->bundle; @@ -164,7 +165,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { if (isset($form['instance']['default_value'])) { $items = $form['#entity']->get($this->instance->getName()); $items->defaultValuesFormValidate($form['instance']['default_value'], $form, $form_state); @@ -174,7 +175,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Handle the default value. $default_value = array(); if (isset($form['instance']['default_value'])) { @@ -209,7 +210,7 @@ public function submitForm(array &$form, array &$form_state) { /** * Redirects to the field instance deletion form. */ - public function delete(array &$form, array &$form_state) { + public function delete(array &$form, FormStateInterface $form_state) { $destination = array(); $request = $this->getRequest(); if ($request->query->has('destination')) { diff --git a/core/modules/field_ui/src/Form/FieldStorageEditForm.php b/core/modules/field_ui/src/Form/FieldStorageEditForm.php index 7fb5819427724d24910c7623168ad604fb2343b9..830396c533b6e9426451605453896148f93601f8 100644 --- a/core/modules/field_ui/src/Form/FieldStorageEditForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageEditForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\TypedDataManager; use Drupal\field\FieldInstanceConfigInterface; use Drupal\field_ui\FieldUI; @@ -74,7 +75,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, FieldInstanceConfigInterface $field_instance_config = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, FieldInstanceConfigInterface $field_instance_config = NULL) { $this->instance = $form_state['instance'] = $field_instance_config; $form['#title'] = $this->instance->label(); @@ -159,7 +160,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // Validate field cardinality. $cardinality = $form_state['values']['field']['cardinality']; $cardinality_number = $form_state['values']['field']['cardinality_number']; @@ -171,7 +172,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_values = $form_state['values']; $field_values = $form_values['field']; diff --git a/core/modules/field_ui/src/FormDisplayOverview.php b/core/modules/field_ui/src/FormDisplayOverview.php index 3a2546ba102a90176d06ae7e587f6d852f08e420..4857a53ae2bcfca594fedee5267199e84826dcea 100644 --- a/core/modules/field_ui/src/FormDisplayOverview.php +++ b/core/modules/field_ui/src/FormDisplayOverview.php @@ -15,6 +15,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldTypePluginManager; use Drupal\Core\Field\PluginSettingsInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -76,7 +77,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $entity_type_id = NULL, $bundle = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $bundle = NULL) { if ($this->getRequest()->attributes->has('form_mode_name')) { $this->mode = $this->getRequest()->attributes->get('form_mode_name'); } @@ -87,7 +88,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL /** * {@inheritdoc} */ - protected function buildFieldRow(FieldDefinitionInterface $field_definition, EntityDisplayInterface $entity_display, array $form, array &$form_state) { + protected function buildFieldRow(FieldDefinitionInterface $field_definition, EntityDisplayInterface $entity_display, array $form, FormStateInterface $form_state) { $field_row = parent::buildFieldRow($field_definition, $entity_display, $form, $form_state); $field_name = $field_definition->getName(); @@ -183,7 +184,7 @@ protected function getOverviewRoute($mode) { /** * {@inheritdoc} */ - protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, array &$form_state) { + protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) { $settings_form = array(); // Invoke hook_field_widget_third_party_settings_form(), keying resulting // subforms by module name. diff --git a/core/modules/field_ui/src/OverviewBase.php b/core/modules/field_ui/src/OverviewBase.php index 17104e0e5e97d7c16324a4d75ac77cdb60047643..7132eda3ac1644a3d55fc0031b829bb286382ed7 100644 --- a/core/modules/field_ui/src/OverviewBase.php +++ b/core/modules/field_ui/src/OverviewBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -74,7 +75,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $entity_type_id = NULL, $bundle = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $bundle = NULL) { $entity_type = $this->entityManager->getDefinition($entity_type_id); $this->bundleEntityType = $entity_type->getBundleEntityType(); if (!isset($form_state['bundle'])) { @@ -89,9 +90,9 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } /** diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 824be6d8c13670078c4705b0e67cfb734aaaa6d1..a48a7a78d78a7282ca54f6e5a129372427d95a25 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -8,6 +8,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\file\Entity\File; @@ -686,8 +687,8 @@ function file_cron() { * @param $form_field_name * A string that is the associative array key of the upload form element in * the form array. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param $validators * An optional, associative array of callback functions used to validate the * file. See file_validate() for a full discussion of the array format. @@ -1103,7 +1104,7 @@ function file_token_info() { * * This function is assigned as a #process callback in file_element_info(). */ -function file_managed_file_process($element, &$form_state, $form) { +function file_managed_file_process($element, FormStateInterface $form_state, $form) { // Append the '-upload' to the #id so the field label's 'for' attribute // corresponds with the file element. $element['#id'] .= '-upload'; @@ -1250,7 +1251,7 @@ function file_managed_file_process($element, &$form_state, $form) { * * This function is assigned as a #value_callback in file_element_info(). */ -function file_managed_file_value(&$element, $input, &$form_state) { +function file_managed_file_value(&$element, $input, FormStateInterface $form_state) { // Find the current value of this field. $fids = !empty($input['fids']) ? explode(' ', $input['fids']) : array(); foreach ($fids as $key => $fid) { @@ -1326,7 +1327,7 @@ function file_managed_file_value(&$element, $input, &$form_state) { * This function is assigned as a #element_validate callback in * file_element_info(). */ -function file_managed_file_validate(&$element, &$form_state) { +function file_managed_file_validate(&$element, FormStateInterface $form_state) { // If referencing an existing file, only allow if there are existing // references. This prevents unmanaged files from being deleted if this // item were to be deleted. @@ -1364,7 +1365,7 @@ function file_managed_file_validate(&$element, &$form_state) { * * @see file_managed_file_process() */ -function file_managed_file_submit($form, &$form_state) { +function file_managed_file_submit($form, FormStateInterface $form_state) { // Determine whether it was the upload or the remove button that was clicked, // and set $element to the managed_file element that contains that button. $parents = $form_state['triggering_element']['#array_parents']; @@ -1428,14 +1429,14 @@ function file_managed_file_submit($form, &$form_state) { * * @param $element * The FAPI element whose values are being saved. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return * An array of file entities for each file that was saved, keyed by its file * ID, or FALSE if no files were saved. */ -function file_managed_file_save_upload($element, array &$form_state) { +function file_managed_file_save_upload($element, FormStateInterface $form_state) { $upload_name = implode('_', $element['#parents']); $file_upload = \Drupal::request()->files->get("files[$upload_name]", NULL, TRUE); if (empty($file_upload)) { diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php b/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php index 43dbefa9dacb0040fbbcacbba8e6ba4f95e66d24..f8ee03c84eead7d7d76abdf020bc9df72989e62c 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php @@ -8,6 +8,7 @@ namespace Drupal\file\Plugin\Field\FieldType; use Drupal\Core\Field\EntityReferenceFieldItemList; +use Drupal\Core\Form\FormStateInterface; /** * Represents a configurable entity file field. @@ -17,7 +18,7 @@ class FileFieldItemList extends EntityReferenceFieldItemList { /** * {@inheritdoc} */ - public function defaultValuesForm(array &$form, array &$form_state) { } + public function defaultValuesForm(array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php index a56448a457f9ed2751404d45561beb03cf1219cc..9f80a6ff612c877b8a07bcd2afe5e9138a84103b 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Bytes; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\DataDefinition; /** @@ -106,7 +107,7 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { $element = array(); $element['#attached']['library'][] = 'file/drupal.file'; @@ -148,7 +149,7 @@ public function settingsForm(array &$form, array &$form_state, $has_data) { /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { $element = array(); $settings = $this->getSettings(); @@ -208,7 +209,7 @@ public function instanceSettingsForm(array $form, array &$form_state) { * This function is assigned as an #element_validate callback in * instanceSettingsForm(). */ - public static function validateDirectory($element, &$form_state) { + public static function validateDirectory($element, FormStateInterface $form_state) { // Strip slashes from the beginning and end of $element['file_directory']. $value = trim($element['#value'], '\\/'); form_set_value($element, $value, $form_state); @@ -224,7 +225,7 @@ public static function validateDirectory($element, &$form_state) { * Commas are allowed by the end-user, but ultimately the value will be stored * as a space-separated list for compatibility with file_validate_extensions(). */ - public static function validateExtensions($element, &$form_state) { + public static function validateExtensions($element, FormStateInterface $form_state) { if (!empty($element['#value'])) { $extensions = preg_replace('/([, ]+\.?)/', ' ', trim(strtolower($element['#value']))); $extensions = array_filter(explode(' ', $extensions)); @@ -247,7 +248,7 @@ public static function validateExtensions($element, &$form_state) { * This function is assigned as an #element_validate callback in * instanceSettingsForm(). */ - public static function validateMaxFilesize($element, &$form_state) { + public static function validateMaxFilesize($element, FormStateInterface $form_state) { if (!empty($element['#value']) && !is_numeric(Bytes::toInt($element['#value']))) { form_error($element, $form_state, t('The "!name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', array('!name' => t($element['title'])))); } diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index 5f71e9a38cd37b0d7113c80a379f1ff4b21d7589..9a03fe41d78fd25780dce6e8943e53962ffa9f5b 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -12,6 +12,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; /** @@ -39,7 +40,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['progress_indicator'] = array( '#type' => 'radios', '#title' => t('Progress indicator'), @@ -69,7 +70,7 @@ public function settingsSummary() { * * Special handling for draggable multiple widgets and 'add more' button. */ - protected function formMultipleElements(FieldItemListInterface $items, array &$form, array &$form_state) { + protected function formMultipleElements(FieldItemListInterface $items, array &$form, FormStateInterface $form_state) { $field_name = $this->fieldDefinition->getName(); $parents = $form['#parents']; @@ -186,7 +187,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $field_settings = $this->getFieldSettings(); // The field settings include defaults for the field type. However, this @@ -256,7 +257,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen /** * {@inheritdoc} */ - public function massageFormValues(array $values, array $form, array &$form_state) { + public function massageFormValues(array $values, array $form, FormStateInterface $form_state) { // Since file upload widget now supports uploads of more than one file at a // time it always returns an array of fids. We have to translate this to a // single fid, as field expects single value. @@ -306,7 +307,7 @@ public static function value($element, $input = FALSE, $form_state) { * * This validator is used only when cardinality not set to 1 or unlimited. */ - public static function validateMultipleCount($element, &$form_state, $form) { + public static function validateMultipleCount($element, FormStateInterface $form_state, $form) { $parents = $element['#parents']; $values = NestedArray::getValue($form_state['values'], $parents); @@ -341,7 +342,7 @@ public static function validateMultipleCount($element, &$form_state, $form) { * * This method is assigned as a #process callback in formElement() method. */ - public static function process($element, &$form_state, $form) { + public static function process($element, FormStateInterface $form_state, $form) { $item = $element['#value']; $item['fids'] = $element['fids']['#value']; @@ -419,7 +420,7 @@ public static function process($element, &$form_state, $form) { * This method on is assigned as a #process callback in formMultipleElements() * method. */ - public static function processMultiple($element, &$form_state, $form) { + public static function processMultiple($element, FormStateInterface $form_state, $form) { $element_children = Element::children($element, TRUE); $count = count($element_children); @@ -484,7 +485,7 @@ protected static function getDescriptionFromElement($element) { * * @see file_managed_file_submit() */ - public static function submit($form, &$form_state) { + public static function submit($form, FormStateInterface $form_state) { // During the form rebuild, formElement() will create field item widget // elements using re-indexed deltas, so clear out $form_state['input'] to // avoid a mismatch between old and new deltas. The rebuilt elements will diff --git a/core/modules/file/src/Plugin/views/field/Extension.php b/core/modules/file/src/Plugin/views/field/Extension.php index 1272e2fe915cb51e844d527459e1b528835d24f3..ba53c816989f4bd671262f4c69a02ff6703f5923 100644 --- a/core/modules/file/src/Plugin/views/field/Extension.php +++ b/core/modules/file/src/Plugin/views/field/Extension.php @@ -7,6 +7,7 @@ namespace Drupal\file\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; @@ -31,7 +32,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['extension_detect_tar'] = array( '#type' => 'checkbox', diff --git a/core/modules/file/src/Plugin/views/field/File.php b/core/modules/file/src/Plugin/views/field/File.php index 0ce77e8f2bf169c3449e5790b7b0505844fe48a0..135ff7f28e876e6ad0a6b4f8ae190376375514b1 100644 --- a/core/modules/file/src/Plugin/views/field/File.php +++ b/core/modules/file/src/Plugin/views/field/File.php @@ -7,6 +7,7 @@ namespace Drupal\file\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -41,7 +42,7 @@ protected function defineOptions() { /** * Provide link to file option */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['link_to_file'] = array( '#title' => t('Link this field to download the file'), '#description' => t("Enable to override this field's links."), diff --git a/core/modules/file/src/Plugin/views/field/FileMime.php b/core/modules/file/src/Plugin/views/field/FileMime.php index fd1c35531b4a6c352d0feefcea61ad3b2f92f31a..5576e34d7d963524e8ee13b94f3ef9486aa44200 100644 --- a/core/modules/file/src/Plugin/views/field/FileMime.php +++ b/core/modules/file/src/Plugin/views/field/FileMime.php @@ -7,6 +7,7 @@ namespace Drupal\file\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -24,7 +25,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['filemime_image'] = array( '#title' => t('Display an icon representing the file type, instead of the MIME text (such as "image/jpeg")'), '#type' => 'checkbox', diff --git a/core/modules/file/src/Plugin/views/field/Uri.php b/core/modules/file/src/Plugin/views/field/Uri.php index 04497b17c294061932f00e243b58ed4bf4522b07..2d2c481f9ec7abe7f186e505f0721397dcab02c7 100644 --- a/core/modules/file/src/Plugin/views/field/Uri.php +++ b/core/modules/file/src/Plugin/views/field/Uri.php @@ -7,6 +7,7 @@ namespace Drupal\file\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -22,7 +23,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['file_download_path'] = array( '#title' => t('Display download path instead of file storage URI'), '#description' => t('This will provide the full download URL rather than the internal filestream address.'), diff --git a/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php b/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php index 84b2760bd3cdadc88df46b421b7abaf859d84db1..19264ccac01dedf11ce4f47cab627d373edceeda 100644 --- a/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php +++ b/core/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php @@ -8,6 +8,7 @@ namespace Drupal\file_module_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form controller for file_module_test module. @@ -26,8 +27,8 @@ public function getFormId() { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param bool $tree * (optional) If the form should use #tree. Defaults to TRUE. * @param bool $extended @@ -37,7 +38,7 @@ public function getFormId() { * @param array $default_fids * (optional) Any default file IDs to use. */ - public function buildForm(array $form, array &$form_state, $tree = TRUE, $extended = TRUE, $multiple = FALSE, $default_fids = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $tree = TRUE, $extended = TRUE, $multiple = FALSE, $default_fids = NULL) { $form['#tree'] = (bool) $tree; $form['nested']['file'] = array( @@ -70,7 +71,7 @@ public function buildForm(array $form, array &$form_state, $tree = TRUE, $extend /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { if ($form['#tree']) { $uploads = $form_state['values']['nested']['file']; } diff --git a/core/modules/file/tests/file_test/src/Form/FileTestForm.php b/core/modules/file/tests/file_test/src/Form/FileTestForm.php index f2d6dc2316d73902cf21bfce78ded1f51a4fc91b..68ebf611f644073d6256fe9ab0f20ae182fd4e76 100644 --- a/core/modules/file/tests/file_test/src/Form/FileTestForm.php +++ b/core/modules/file/tests/file_test/src/Form/FileTestForm.php @@ -7,6 +7,7 @@ namespace Drupal\file_test\Form; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormStateInterface; /** * File test form class. @@ -23,7 +24,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['file_test_upload'] = array( '#type' => 'file', '#title' => t('Upload a file'), @@ -72,12 +73,12 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) {} + public function validateForm(array &$form, FormStateInterface $form_state) {} /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Process the upload and perform validation. Note: we're using the // form value for the $replace parameter. if (!empty($form_state['values']['file_subdir'])) { diff --git a/core/modules/filter/src/FilterFormatAddForm.php b/core/modules/filter/src/FilterFormatAddForm.php index 5a0e83ef50574143511674ad261a93c6eee0782a..8c6ad4ab0f804617dc789dad04d67282ca4b1efe 100644 --- a/core/modules/filter/src/FilterFormatAddForm.php +++ b/core/modules/filter/src/FilterFormatAddForm.php @@ -7,6 +7,8 @@ namespace Drupal\filter; +use Drupal\Core\Form\FormStateInterface; + /** * Provides a form for adding a filter format. */ @@ -15,14 +17,14 @@ class FilterFormatAddForm extends FilterFormatFormBase { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { return parent::form($form, $form_state); } /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); drupal_set_message($this->t('Added text format %format.', array('%format' => $this->entity->label()))); return $this->entity; diff --git a/core/modules/filter/src/FilterFormatEditForm.php b/core/modules/filter/src/FilterFormatEditForm.php index a1448a078fbe2ac9e0966b13dcea1eaff0145f3b..ab437ace291c46b6521accb67bbcf8f21eb93bc3 100644 --- a/core/modules/filter/src/FilterFormatEditForm.php +++ b/core/modules/filter/src/FilterFormatEditForm.php @@ -7,6 +7,7 @@ namespace Drupal\filter; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -17,7 +18,7 @@ class FilterFormatEditForm extends FilterFormatFormBase { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { if (!$this->entity->status()) { throw new NotFoundHttpException(); } @@ -31,7 +32,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); drupal_set_message($this->t('The text format %format has been updated.', array('%format' => $this->entity->label()))); return $this->entity; diff --git a/core/modules/filter/src/FilterFormatFormBase.php b/core/modules/filter/src/FilterFormatFormBase.php index 7a23b937cd6485768003e789ea3c44066f105fde..fce0b93e2bb842bf3618f3f005ceb606fafde27f 100644 --- a/core/modules/filter/src/FilterFormatFormBase.php +++ b/core/modules/filter/src/FilterFormatFormBase.php @@ -10,6 +10,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Form\FormStateInterface; use Drupal\filter\Plugin\Filter\FilterNull; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -47,7 +48,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $format = $this->entity; $is_fallback = ($format->id() == $this->config('filter.settings')->get('fallback_format')); @@ -209,7 +210,7 @@ public function exists($format_id) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); // @todo Move trimming upstream. @@ -233,7 +234,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); // Add the submitted form values to the text format, and save it. @@ -265,7 +266,7 @@ public function submit(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = $this->t('Save configuration'); return $actions; diff --git a/core/modules/filter/src/FilterFormatListBuilder.php b/core/modules/filter/src/FilterFormatListBuilder.php index 4f1a5cb147b49fb3c08a0895ba86a8cc3f6997ae..0003cfafdbd40ad414e61fa01b6bdf08c1604b7c 100644 --- a/core/modules/filter/src/FilterFormatListBuilder.php +++ b/core/modules/filter/src/FilterFormatListBuilder.php @@ -13,6 +13,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -136,15 +137,16 @@ public function getDefaultOperations(EntityInterface $entity) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $form['actions']['submit']['#value'] = $this->t('Save changes'); return $form; } + /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); filter_formats_reset(); diff --git a/core/modules/filter/src/Form/FilterDisableForm.php b/core/modules/filter/src/Form/FilterDisableForm.php index af661592bb5b75a7fea329908281329a5dca54f3..a6b7b88b38a676cfc07b0b806f30abe1c3ccc0c5 100644 --- a/core/modules/filter/src/Form/FilterDisableForm.php +++ b/core/modules/filter/src/Form/FilterDisableForm.php @@ -8,6 +8,7 @@ namespace Drupal\filter\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -46,7 +47,7 @@ public function getDescription() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->disable()->save(); drupal_set_message($this->t('Disabled text format %format.', array('%format' => $this->entity->label()))); diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php index 6549168a0874f9b83c0b33be33882ed0cba44906..b76933ec5b0375acec5e42ca22ecd08b50dd09e4 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php +++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php @@ -8,6 +8,7 @@ namespace Drupal\filter\Plugin\Filter; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\filter\FilterProcessResult; use Drupal\filter\Plugin\FilterBase; @@ -31,7 +32,7 @@ class FilterHtml extends FilterBase { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $form['allowed_html'] = array( '#type' => 'textfield', '#title' => $this->t('Allowed HTML tags'), diff --git a/core/modules/filter/src/Plugin/Filter/FilterUrl.php b/core/modules/filter/src/Plugin/Filter/FilterUrl.php index d717f2c4a67854b0277f0a6571f335606c57ca35..a915052ae85f72dfd4f33e1b09dc4c8928c86e67 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterUrl.php +++ b/core/modules/filter/src/Plugin/Filter/FilterUrl.php @@ -7,6 +7,7 @@ namespace Drupal\filter\Plugin\Filter; +use Drupal\Core\Form\FormStateInterface; use Drupal\filter\FilterProcessResult; use Drupal\filter\Plugin\FilterBase; @@ -27,7 +28,7 @@ class FilterUrl extends FilterBase { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $form['filter_url_length'] = array( '#type' => 'number', '#title' => $this->t('Maximum link text length'), diff --git a/core/modules/filter/src/Plugin/FilterBase.php b/core/modules/filter/src/Plugin/FilterBase.php index 5314ad7655a178987fb1e3f547057f1d4598a9dd..de9613f8b8b8cb38b03a6a86d5011d59bddfce59 100644 --- a/core/modules/filter/src/Plugin/FilterBase.php +++ b/core/modules/filter/src/Plugin/FilterBase.php @@ -7,6 +7,7 @@ namespace Drupal\filter\Plugin; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\PluginBase; /** @@ -146,7 +147,7 @@ public function getDescription() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { // Implementations should work with and return $form. Returning an empty // array here allows the text format administration form to identify whether // the filter plugin has any settings form elements. diff --git a/core/modules/filter/src/Plugin/FilterInterface.php b/core/modules/filter/src/Plugin/FilterInterface.php index dbbc490e4e5b6a6c442c21974243c2b2b97d65e1..aa2438b62b0c795628d8e195e14a6a1322a95392 100644 --- a/core/modules/filter/src/Plugin/FilterInterface.php +++ b/core/modules/filter/src/Plugin/FilterInterface.php @@ -9,6 +9,7 @@ use Drupal\Component\Plugin\PluginInspectionInterface; use Drupal\Component\Plugin\ConfigurablePluginInterface; +use Drupal\Core\Form\FormStateInterface; /** * Defines the interface for text processing filter plugins. @@ -132,14 +133,14 @@ public function getDescription(); * * @param array $form * A minimally prepopulated form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The state of the (entire) configuration form. * * @return array * The $form array with additional form elements for the settings of this * filter. The submitted form values should match $this->settings. */ - public function settingsForm(array $form, array &$form_state); + public function settingsForm(array $form, FormStateInterface $form_state); /** * Prepares the text for processing. diff --git a/core/modules/filter/tests/filter_test/src/Form/FilterTestFormatForm.php b/core/modules/filter/tests/filter_test/src/Form/FilterTestFormatForm.php index be8cd123138313fe9e8faacf3aa6cff821572a0f..8f90746cc4b813e9e5aa8a328d99b192143eea03 100644 --- a/core/modules/filter/tests/filter_test/src/Form/FilterTestFormatForm.php +++ b/core/modules/filter/tests/filter_test/src/Form/FilterTestFormatForm.php @@ -7,6 +7,7 @@ namespace Drupal\filter_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Shows a test form for testing the 'text_format' form element. @@ -23,7 +24,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // This ensures that the parent array key makes it into the HTML ID of the // form elements. $form['#tree'] = TRUE; @@ -109,7 +110,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 32443a9705efc6d586aad25a97c894e0cbcba5a2..425b597bbfa74d4a8bb00bcc9e1676639aeb2a42 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Xss; use Drupal\Core\Entity\EntityInterface; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; /** @@ -198,7 +199,7 @@ function forum_uri($forum) { * Checks in particular that the node is assigned only a "leaf" term in the * forum taxonomy. */ -function forum_node_validate(EntityInterface $node, $form, &$form_state) { +function forum_node_validate(EntityInterface $node, $form, FormStateInterface $form_state) { if (\Drupal::service('forum_manager')->checkNodeType($node)) { // vocabulary is selected, not a "container" term. if (!$node->taxonomy_forums->isEmpty()) { @@ -384,7 +385,7 @@ function forum_comment_delete(CommentInterface $comment) { /** * Implements hook_form_BASE_FORM_ID_alter(). */ -function forum_form_taxonomy_vocabulary_form_alter(&$form, &$form_state, $form_id) { +function forum_form_taxonomy_vocabulary_form_alter(&$form, FormStateInterface $form_state, $form_id) { $vid = \Drupal::config('forum.settings')->get('vocabulary'); $vocabulary = $form_state['controller']->getEntity(); if ($vid == $vocabulary->id()) { @@ -406,7 +407,7 @@ function forum_form_taxonomy_vocabulary_form_alter(&$form, &$form_state, $form_i /** * Implements hook_form_FORM_ID_alter() for taxonomy_term_form(). */ -function forum_form_taxonomy_term_form_alter(&$form, &$form_state, $form_id) { +function forum_form_taxonomy_term_form_alter(&$form, FormStateInterface $form_state, $form_id) { $vid = \Drupal::config('forum.settings')->get('vocabulary'); if (isset($form['vid']['#value']) && $form['vid']['#value'] == $vid) { // Hide multiple parents select from forum terms. @@ -417,7 +418,7 @@ function forum_form_taxonomy_term_form_alter(&$form, &$form_state, $form_id) { /** * Implements hook_form_BASE_FORM_ID_alter() for node_form(). */ -function forum_form_node_form_alter(&$form, &$form_state, $form_id) { +function forum_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) { $node = $form_state['controller']->getEntity(); if (isset($node->taxonomy_forums) && !$node->isNew()) { $forum_terms = $node->taxonomy_forums; diff --git a/core/modules/forum/src/Form/ContainerForm.php b/core/modules/forum/src/Form/ContainerForm.php index 1918bd080e1393354ac63169e2193b5ebeb5f109..e167d74e0833e6562bb96cac9045129241fbfade 100644 --- a/core/modules/forum/src/Form/ContainerForm.php +++ b/core/modules/forum/src/Form/ContainerForm.php @@ -7,6 +7,8 @@ namespace Drupal\forum\Form; +use Drupal\Core\Form\FormStateInterface; + /** * Base form for container term edit forms. */ @@ -22,7 +24,7 @@ class ContainerForm extends ForumForm { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $taxonomy_term = $this->entity; // Build the bulk of the form from the parent forum form. $form = parent::form($form, $form_state, $taxonomy_term); @@ -40,7 +42,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $is_new = $this->entity->isNew(); $this->entity->forum_container = TRUE; $term = parent::save($form, $form_state); diff --git a/core/modules/forum/src/Form/DeleteForm.php b/core/modules/forum/src/Form/DeleteForm.php index 6071fb8de37bfcbd32ac2ae15b3986995ce3aa0c..94cdf1126ce77171b14508ebac856efd7402f4d3 100644 --- a/core/modules/forum/src/Form/DeleteForm.php +++ b/core/modules/forum/src/Form/DeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\forum\Form; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\taxonomy\TermInterface; @@ -54,7 +55,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, TermInterface $taxonomy_term = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, TermInterface $taxonomy_term = NULL) { $this->taxonomyTerm = $taxonomy_term; return parent::buildForm($form, $form_state); @@ -63,7 +64,7 @@ public function buildForm(array $form, array &$form_state, TermInterface $taxono /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->taxonomyTerm->delete(); drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', array('%label' => $this->taxonomyTerm->label()))); watchdog('forum', 'forum: deleted %label and all its sub-forums.', array('%label' => $this->taxonomyTerm->label()), WATCHDOG_NOTICE); diff --git a/core/modules/forum/src/Form/ForumForm.php b/core/modules/forum/src/Form/ForumForm.php index fc20134ac856afa6879a6e838e180892c06c4a36..300738058b413cce79ea05b6aa1cd17c18b88c04 100644 --- a/core/modules/forum/src/Form/ForumForm.php +++ b/core/modules/forum/src/Form/ForumForm.php @@ -7,6 +7,7 @@ namespace Drupal\forum\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\taxonomy\TermForm; /** @@ -31,7 +32,7 @@ class ForumForm extends TermForm { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $taxonomy_term = $this->entity; // Build the bulk of the form from the parent taxonomy term form. $form = parent::form($form, $form_state, $taxonomy_term); @@ -61,7 +62,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function buildEntity(array $form, array &$form_state) { + public function buildEntity(array $form, FormStateInterface $form_state) { $term = parent::buildEntity($form, $form_state); // Assign parents from forum parent select field. @@ -73,7 +74,7 @@ public function buildEntity(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $term = $this->entity; $term_storage = $this->entityManager->getStorage('taxonomy_term'); $status = $term_storage->save($term); @@ -98,7 +99,7 @@ public function save(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); if (!$this->entity->isNew() && $this->entity->hasLinkTemplate('forum-delete-form')) { diff --git a/core/modules/forum/src/Form/Overview.php b/core/modules/forum/src/Form/Overview.php index 98c3febf99e605ab1ae9c8e409ac6608d7fc4716..98688ab03a5f16d83bbcb0a206031d562d9d607c 100644 --- a/core/modules/forum/src/Form/Overview.php +++ b/core/modules/forum/src/Form/Overview.php @@ -8,6 +8,7 @@ namespace Drupal\forum\Form; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\taxonomy\Form\OverviewTerms; use Drupal\Core\Config\ConfigFactoryInterface; @@ -60,7 +61,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $forum_config = $this->config('forum.settings'); $vid = $forum_config->get('vocabulary'); $vocabulary = $this->entityManager->getStorage('taxonomy_vocabulary')->load($vid); diff --git a/core/modules/forum/src/ForumSettingsForm.php b/core/modules/forum/src/ForumSettingsForm.php index dbe486f15bf0b39ecf90ad0db0b2e64e4456b704..51b42a38a90295dc1f4ac904a1d183f0668c0d76 100644 --- a/core/modules/forum/src/ForumSettingsForm.php +++ b/core/modules/forum/src/ForumSettingsForm.php @@ -8,6 +8,7 @@ namespace Drupal\forum; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Configure forum settings for this site. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('forum.settings'); $options = array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500); @@ -63,7 +64,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('forum.settings') ->set('topics.hot_threshold', $form_state['values']['forum_hot_topic']) ->set('topics.page_limit', $form_state['values']['forum_per_page']) diff --git a/core/modules/forum/src/Plugin/Block/ForumBlockBase.php b/core/modules/forum/src/Plugin/Block/ForumBlockBase.php index 6a5b4922d4cf241eb506d0560eb5ba97c2cf23fc..b9bab0217160d635bd2aa5c087460d9b0a225667 100644 --- a/core/modules/forum/src/Plugin/Block/ForumBlockBase.php +++ b/core/modules/forum/src/Plugin/Block/ForumBlockBase.php @@ -8,6 +8,7 @@ namespace Drupal\forum\Plugin\Block; use Drupal\block\BlockBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Cache\Cache; @@ -61,9 +62,9 @@ protected function blockAccess(AccountInterface $account) { } /** - * Overrides \Drupal\block\BlockBase::blockForm(). + * {@inheritdoc} */ - public function blockForm($form, &$form_state) { + public function blockForm($form, FormStateInterface $form_state) { $range = range(2, 20); $form['block_count'] = array( '#type' => 'select', @@ -75,9 +76,9 @@ public function blockForm($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::blockSubmit(). + * {@inheritdoc} */ - public function blockSubmit($form, &$form_state) { + public function blockSubmit($form, FormStateInterface $form_state) { $this->configuration['block_count'] = $form_state['values']['block_count']; } diff --git a/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php index ca9a27644aca2e104e585dd0b2536b25138e9a96..4a7d0c1417a98809163339a14ab52e891572adfc 100644 --- a/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php +++ b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php @@ -7,6 +7,7 @@ namespace Drupal\history\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -54,7 +55,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); if (\Drupal::moduleHandler()->moduleExists('comment')) { $form['comments'] = array( diff --git a/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php index 0648fecca02f2a2e6f3b968ea36b3d932e96d6df..70866c80395f3e03587889a7b2c2b85f68ce494f 100644 --- a/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php +++ b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php @@ -7,6 +7,7 @@ namespace Drupal\history\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\filter\FilterPluginBase; /** @@ -31,7 +32,7 @@ public function usesGroupBy() { return FALSE; } - public function buildExposeForm(&$form, &$form_state) { + public function buildExposeForm(&$form, FormStateInterface $form_state) { parent::buildExposeForm($form, $form_state); // @todo There are better ways of excluding required and multiple (object flags) unset($form['expose']['required']); @@ -39,7 +40,7 @@ public function buildExposeForm(&$form, &$form_state) { unset($form['expose']['remember']); } - protected function valueForm(&$form, &$form_state) { + protected function valueForm(&$form, FormStateInterface $form_state) { // Only present a checkbox for the exposed filter itself. There's no way // to tell the difference between not checked and the default value, so // specifying the default value via the views UI is meaningless. diff --git a/core/modules/image/src/ConfigurableImageEffectBase.php b/core/modules/image/src/ConfigurableImageEffectBase.php index ce421642bdd6df0472d3166881820238e9cc4cf8..7b391b523c910c1916d317a11a2c5913e4c783dc 100644 --- a/core/modules/image/src/ConfigurableImageEffectBase.php +++ b/core/modules/image/src/ConfigurableImageEffectBase.php @@ -7,6 +7,8 @@ namespace Drupal\image; +use Drupal\Core\Form\FormStateInterface; + /** * Provides a base class for configurable image effects. */ @@ -15,13 +17,13 @@ abstract class ConfigurableImageEffectBase extends ImageEffectBase implements Co /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/image/src/Form/ImageEffectAddForm.php b/core/modules/image/src/Form/ImageEffectAddForm.php index 1efeab1872304a7ec5196ba18ea4c28a5f661048..e491d0791433860166e869a11586f8925768b822 100644 --- a/core/modules/image/src/Form/ImageEffectAddForm.php +++ b/core/modules/image/src/Form/ImageEffectAddForm.php @@ -8,6 +8,7 @@ namespace Drupal\image\Form; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\image\ImageEffectManager; use Drupal\image\ImageStyleInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -46,7 +47,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { $form = parent::buildForm($form, $form_state, $image_style, $image_effect); $form['#title'] = $this->t('Add %label effect', array('%label' => $this->imageEffect->label())); diff --git a/core/modules/image/src/Form/ImageEffectDeleteForm.php b/core/modules/image/src/Form/ImageEffectDeleteForm.php index c925da81b3fb72a36a8b5f7a6bb4afa12d0eb5bb..761fd21096fd59357fda1ebd808b48cd24ebf7c4 100644 --- a/core/modules/image/src/Form/ImageEffectDeleteForm.php +++ b/core/modules/image/src/Form/ImageEffectDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\image\Form; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\image\ImageStyleInterface; /** @@ -60,7 +61,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { $this->imageStyle = $image_style; $this->imageEffect = $this->imageStyle->getEffect($image_effect); @@ -70,7 +71,7 @@ public function buildForm(array $form, array &$form_state, ImageStyleInterface $ /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->imageStyle->deleteImageEffect($this->imageEffect); drupal_set_message($this->t('The image effect %name has been deleted.', array('%name' => $this->imageEffect->label()))); $form_state['redirect_route'] = $this->imageStyle->urlInfo('edit-form'); diff --git a/core/modules/image/src/Form/ImageEffectEditForm.php b/core/modules/image/src/Form/ImageEffectEditForm.php index f949e6c825c7e5a5a8365c7c18fbe3eee74650f0..1e2ba85ca0d2fd4d73b9fa4a353d3d11f4626330 100644 --- a/core/modules/image/src/Form/ImageEffectEditForm.php +++ b/core/modules/image/src/Form/ImageEffectEditForm.php @@ -7,6 +7,7 @@ namespace Drupal\image\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\image\ImageStyleInterface; /** @@ -17,7 +18,7 @@ class ImageEffectEditForm extends ImageEffectFormBase { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { $form = parent::buildForm($form, $form_state, $image_style, $image_effect); $form['#title'] = $this->t('Edit %label effect', array('%label' => $this->imageEffect->label())); diff --git a/core/modules/image/src/Form/ImageEffectFormBase.php b/core/modules/image/src/Form/ImageEffectFormBase.php index 6cc8d1d0a215805a250034148eefbc532c23aa85..6f3268ef88c8d6fdb9cae76fd4bc84ac122d933e 100644 --- a/core/modules/image/src/Form/ImageEffectFormBase.php +++ b/core/modules/image/src/Form/ImageEffectFormBase.php @@ -8,6 +8,8 @@ namespace Drupal\image\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormState; +use Drupal\Core\Form\FormStateInterface; use Drupal\image\ConfigurableImageEffectInterface; use Drupal\image\ImageStyleInterface; use Drupal\Component\Plugin\Exception\PluginNotFoundException; @@ -53,7 +55,7 @@ public function getFormId() { * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ - public function buildForm(array $form, array &$form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { $this->imageStyle = $image_style; try { $this->imageEffect = $this->prepareImageEffect($image_effect); @@ -101,27 +103,32 @@ public function buildForm(array $form, array &$form_state, ImageStyleInterface $ /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // The image effect configuration is stored in the 'data' key in the form, // pass that through for validation. - $effect_data = array( - 'values' => &$form_state['values']['data'] - ); + $effect_data = new FormState(array( + 'values' => $form_state['values']['data'], + )); $this->imageEffect->validateConfigurationForm($form, $effect_data); + // Update the original form values. + $form_state['values']['data'] = $effect_data['values']; } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { form_state_values_clean($form_state); // The image effect configuration is stored in the 'data' key in the form, // pass that through for submission. - $effect_data = array( - 'values' => &$form_state['values']['data'] - ); + $effect_data = new FormState(array( + 'values' => $form_state['values']['data'], + )); $this->imageEffect->submitConfigurationForm($form, $effect_data); + // Update the original form values. + $form_state['values']['data'] = $effect_data['values']; + $this->imageEffect->setWeight($form_state['values']['weight']); if (!$this->imageEffect->getUuid()) { $this->imageStyle->addImageEffect($this->imageEffect->getConfiguration()); diff --git a/core/modules/image/src/Form/ImageStyleAddForm.php b/core/modules/image/src/Form/ImageStyleAddForm.php index 64c2a37dc99116acb07acc02477473846a15c652..7d34a1d9c4fbfd2f69e7a8a38b99b003288f2f60 100644 --- a/core/modules/image/src/Form/ImageStyleAddForm.php +++ b/core/modules/image/src/Form/ImageStyleAddForm.php @@ -7,6 +7,8 @@ namespace Drupal\image\Form; +use Drupal\Core\Form\FormStateInterface; + /** * Controller for image style addition forms. */ @@ -15,7 +17,7 @@ class ImageStyleAddForm extends ImageStyleFormBase { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { parent::save($form, $form_state); drupal_set_message($this->t('Style %name was created.', array('%name' => $this->entity->label()))); } @@ -23,7 +25,7 @@ public function save(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function actions(array $form, array &$form_state) { + public function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = $this->t('Create new style'); diff --git a/core/modules/image/src/Form/ImageStyleDeleteForm.php b/core/modules/image/src/Form/ImageStyleDeleteForm.php index 20f393b7b3ab6d42a0dd3d848a92cd8b58b85513..41ca653fd28cc4ae49dc83d3a7ad35cf00d9fc3b 100644 --- a/core/modules/image/src/Form/ImageStyleDeleteForm.php +++ b/core/modules/image/src/Form/ImageStyleDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\image\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -46,7 +47,7 @@ public function getDescription() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $replacement_styles = array_diff_key(image_style_options(), array($this->entity->id() => '')); $form['replacement'] = array( '#title' => $this->t('Replacement style'), @@ -61,7 +62,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/src/Form/ImageStyleEditForm.php b/core/modules/image/src/Form/ImageStyleEditForm.php index 8b27119cadea2443078fe51bcad67915177c8a48..f861ef1a411720016ddc8aaa23259b4eda760fd6 100644 --- a/core/modules/image/src/Form/ImageStyleEditForm.php +++ b/core/modules/image/src/Form/ImageStyleEditForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\image\ConfigurableImageEffectInterface; use Drupal\image\ImageEffectManager; use Drupal\Component\Utility\String; @@ -52,7 +53,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Edit style %name', array('%name' => $this->entity->label())); $form['#tree'] = TRUE; $form['#attached']['css'][drupal_get_path('module', 'image') . '/css/image.admin.css'] = array(); @@ -155,7 +156,7 @@ public function form(array $form, array &$form_state) { /** * Validate handler for image effect. */ - public function effectValidate($form, &$form_state) { + public function effectValidate($form, FormStateInterface $form_state) { if (!$form_state['values']['new']) { $this->setFormError('new', $form_state, $this->t('Select an effect to add.')); } @@ -164,7 +165,7 @@ public function effectValidate($form, &$form_state) { /** * Submit handler for image effect. */ - public function effectSave($form, &$form_state) { + public function effectSave($form, FormStateInterface $form_state) { // Update image effect weights. if (!empty($form_state['values']['effects'])) { @@ -214,7 +215,7 @@ public function effectSave($form, &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { // Update image effect weights. if (!empty($form_state['values']['effects'])) { @@ -228,7 +229,7 @@ public function save(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function actions(array $form, array &$form_state) { + public function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = $this->t('Update style'); @@ -253,7 +254,7 @@ protected function updateEffectWeights(array $effects) { /** * {@inheritdoc} */ - protected function copyFormValuesToEntity(EntityInterface $entity, array $form, array &$form_state) { + protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) { foreach ($form_state['values'] as $key => $value) { // Do not copy effects here, see self::updateEffectWeights(). if ($key != 'effects') { diff --git a/core/modules/image/src/Form/ImageStyleFlushForm.php b/core/modules/image/src/Form/ImageStyleFlushForm.php index 9839a8a9857c667f411ce547357c99b7470a95a3..5212ba03f027c4e128d368bbdb4d3b9c2138fc8f 100644 --- a/core/modules/image/src/Form/ImageStyleFlushForm.php +++ b/core/modules/image/src/Form/ImageStyleFlushForm.php @@ -8,6 +8,7 @@ namespace Drupal\image\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -46,7 +47,7 @@ public function getCancelUrl() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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'] = $this->getCancelUrl(); diff --git a/core/modules/image/src/Form/ImageStyleFormBase.php b/core/modules/image/src/Form/ImageStyleFormBase.php index efac805628ff472bbdc16db978b9c80bc99741a5..ad4ce5ccc271e1940f726163ecfdfc68db60821f 100644 --- a/core/modules/image/src/Form/ImageStyleFormBase.php +++ b/core/modules/image/src/Form/ImageStyleFormBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -52,7 +53,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form['label'] = array( '#type' => 'textfield', @@ -75,7 +76,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $this->entity->save(); $form_state['redirect_route'] = $this->entity->urlInfo('edit-form'); } diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php index c14ab917de680b1d3b06670daf752b5ae3ade2de..069178df434b2251ea8fb90fb83bba9b35d7c14b 100644 --- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php +++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php @@ -8,6 +8,7 @@ namespace Drupal\image\Plugin\Field\FieldFormatter; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'image' formatter. @@ -35,7 +36,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $image_styles = image_style_options(FALSE); $element['image_style'] = array( '#title' => t('Image style'), diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php index c2e8737d5ef8e475d621e85d9764ad2122699cd0..d1489c80137632ebae85b335841f2eced9787221 100644 --- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php @@ -8,6 +8,7 @@ namespace Drupal\image\Plugin\Field\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\file\Plugin\Field\FieldType\FileItem; @@ -152,7 +153,7 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { $element = array(); // We need the field-level 'default_image' setting, and $this->getSettings() @@ -182,7 +183,7 @@ public function settingsForm(array &$form, array &$form_state, $has_data) { /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { // Get base form from FileItem::instanceSettingsForm(). $element = parent::instanceSettingsForm($form, $form_state); @@ -313,7 +314,7 @@ public function preSave() { /** * Element validate function for resolution fields. */ - public static function validateResolution($element, &$form_state) { + public static function validateResolution($element, FormStateInterface $form_state) { if (!empty($element['x']['#value']) || !empty($element['y']['#value'])) { foreach (array('x', 'y') as $dimension) { if (!$element[$dimension]['#value']) { @@ -383,10 +384,10 @@ protected function defaultImageForm(array &$element, array $settings) { * * @param array $element * The form element to process. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. */ - public static function validateDefaultImageForm(array &$element, array &$form_state) { + public static function validateDefaultImageForm(array &$element, FormStateInterface $form_state) { // Consolidate the array value of this field to a single FID as #extended // for default image is not TRUE and this is a single value. if (isset($element['fids']['#value'][0])) { diff --git a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php index 0ba9e7e8cb2a168a290583e75a8d8f1520cf0bf5..c38ccba8c7511cb8493c2d9284931212b5752385 100644 --- a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php +++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Component\Utility\NestedArray; +use Drupal\Core\Form\FormStateInterface; use Drupal\file\Plugin\Field\FieldWidget\FileWidget; /** @@ -37,7 +38,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element = parent::settingsForm($form, $form_state); $element['preview_image_style'] = array( @@ -82,7 +83,7 @@ public function settingsSummary() { * * Special handling for draggable multiple widgets and 'add more' button. */ - protected function formMultipleElements(FieldItemListInterface $items, array &$form, array &$form_state) { + protected function formMultipleElements(FieldItemListInterface $items, array &$form, FormStateInterface $form_state) { $elements = parent::formMultipleElements($items, $form, $form_state); $cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality(); @@ -109,7 +110,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element = parent::formElement($items, $delta, $element, $form, $form_state); $field_settings = $this->getFieldSettings(); @@ -144,7 +145,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen * * This method is assigned as a #process callback in formElement() method. */ - public static function process($element, &$form_state, $form) { + public static function process($element, FormStateInterface $form_state, $form) { $item = $element['#value']; $item['fids'] = $element['fids']['#value']; @@ -227,7 +228,7 @@ public static function process($element, &$form_state, $form) { * This is separated in a validate function instead of a #required flag to * avoid being validated on the process callback. */ - public static function validateRequiredFields($element, &$form_state) { + public static function validateRequiredFields($element, FormStateInterface $form_state) { // Only do validation if the function is triggered from other places than // the image process form. if (!in_array('file_managed_file_submit', $form_state['triggering_element']['#submit'])) { diff --git a/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php index 42f65611bf86a479d721087b8c679bd063018b3e..0edac982749d6a1ffa86ef28e621c2719a91b1a4 100644 --- a/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php @@ -7,6 +7,7 @@ namespace Drupal\image\Plugin\ImageEffect; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Image\ImageInterface; /** @@ -59,7 +60,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); $form['anchor'] = array( '#type' => 'radios', diff --git a/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php index f7d495d654ec7f90d526a7e78b23950741c052ab..15f00805bfd28b9328d7e926af38a24b885e1807 100644 --- a/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php @@ -7,6 +7,7 @@ namespace Drupal\image\Plugin\ImageEffect; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Image\ImageInterface; use Drupal\image\ConfigurableImageEffectBase; @@ -67,7 +68,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['width'] = array( '#type' => 'number', '#title' => t('Width'), @@ -90,7 +91,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { parent::submitConfigurationForm($form, $form_state); $this->configuration['height'] = $form_state['values']['height']; diff --git a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php index 49529cd995fe6f9b811f0d1fa536c0d9300ea4f1..7f29aaff1180c2cff0a0930c81af13312ef6bf18 100644 --- a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php @@ -7,6 +7,7 @@ namespace Drupal\image\Plugin\ImageEffect; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Image\ImageInterface; use Drupal\Core\Utility\Color; use Drupal\image\ConfigurableImageEffectBase; @@ -97,7 +98,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['degrees'] = array( '#type' => 'number', '#default_value' => $this->configuration['degrees'], @@ -126,7 +127,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { if (!Color::validateHex($form_state['values']['bgcolor'])) { form_set_error('bgcolor', $form_state, $this->t('Background color must be a hexadecimal color value.')); } @@ -135,7 +136,7 @@ public function validateConfigurationForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { parent::submitConfigurationForm($form, $form_state); $this->configuration['degrees'] = $form_state['values']['degrees']; diff --git a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php index e1d8ec57cf90cabcfe98a4d9139b952b1b14e426..a5dae9a7cd35a1aec2367c08985d585f5e92381c 100644 --- a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php @@ -8,6 +8,7 @@ namespace Drupal\image\Plugin\ImageEffect; use Drupal\Component\Utility\Image; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Image\ImageInterface; /** @@ -66,7 +67,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); $form['width']['#required'] = FALSE; $form['height']['#required'] = FALSE; @@ -82,7 +83,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { parent::validateConfigurationForm($form, $form_state); if (empty($form_state['values']['width']) && empty($form_state['values']['height'])) { form_set_error('data', $form_state, $this->t('Width and height can not both be blank.')); @@ -92,7 +93,7 @@ public function validateConfigurationForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { parent::submitConfigurationForm($form, $form_state); $this->configuration['upscale'] = $form_state['values']['upscale']; diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 5ac331bf1c3edf47ad3943ed6451af218bb7e721..0909511d957985f2894bcd321298e0703cee8c74 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -5,6 +5,7 @@ * Add language handling functionality to Drupal. */ +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\PhpStorage\PhpStorageFactory; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Routing\RouteMatchInterface; @@ -214,7 +215,7 @@ function language_configuration_element_default_options() { /** * Process handler for the language_configuration form element. */ -function language_configuration_element_process($element, &$form_state, &$form) { +function language_configuration_element_process($element, FormStateInterface $form_state, &$form) { $options = isset($element['#options']) ? $element['#options'] : array(); // Avoid validation failure since we are moving the '#options' key in the // nested 'language' select element. @@ -265,7 +266,7 @@ function language_configuration_element_process($element, &$form_state, &$form) /** * Submit handler for the forms that have a language_configuration element. */ -function language_configuration_element_submit(&$form, &$form_state) { +function language_configuration_element_submit(&$form, FormStateInterface $form_state) { // Iterate through all the language_configuration elements and save their // values. if (isset($form_state['language'])) { @@ -650,7 +651,7 @@ function language_set_browser_drupal_langcode_mappings($mappings) { * * @see language_system_regional_settings_form_submit() */ -function language_form_system_regional_settings_alter(&$form, &$form_state) { +function language_form_system_regional_settings_alter(&$form, FormStateInterface $form_state) { $languages = \Drupal::languageManager()->getLanguages(); $default = \Drupal::languageManager()->getDefaultLanguage(); foreach ($languages as $key => $language) { @@ -673,7 +674,7 @@ function language_form_system_regional_settings_alter(&$form, &$form_state) { * * @see language_form_system_regional_settings_alter() */ -function language_system_regional_settings_form_submit($form, &$form_state) { +function language_system_regional_settings_form_submit($form, FormStateInterface $form_state) { $languages = \Drupal::languageManager()->getLanguages(); $language = $languages[$form_state['values']['site_default_language']]; $language->default = TRUE; diff --git a/core/modules/language/src/Form/ContentLanguageSettingsForm.php b/core/modules/language/src/Form/ContentLanguageSettingsForm.php index 4738a1871dda2f87951ee0e33b673338f6a85de8..47c136e8e958e4336c5a95ef86bd60b1579de238 100644 --- a/core/modules/language/src/Form/ContentLanguageSettingsForm.php +++ b/core/modules/language/src/Form/ContentLanguageSettingsForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -58,7 +59,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $entity_types = $this->entityManager->getDefinitions(); $labels = array(); $default = array(); @@ -146,7 +147,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $config = $this->config('language.settings'); foreach ($form_state['values']['settings'] as $entity_type => $entity_settings) { foreach ($entity_settings as $bundle => $bundle_settings) { diff --git a/core/modules/language/src/Form/LanguageAddForm.php b/core/modules/language/src/Form/LanguageAddForm.php index 3eb0bc613ce89a1328f1d4e8759d9ce38f8e7d66..692cae9bd5a952ccfe4429ff23dbd6076e5ed793 100644 --- a/core/modules/language/src/Form/LanguageAddForm.php +++ b/core/modules/language/src/Form/LanguageAddForm.php @@ -7,6 +7,7 @@ namespace Drupal\language\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\language\Form\LanguageFormBase; use Drupal\Core\Language\Language; @@ -26,7 +27,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Add language'); $predefined_languages = $this->languageManager->getStandardLanguageListWithoutConfigured(); @@ -81,7 +82,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $langcode = $form_state['values']['predefined_langcode']; if ($langcode == 'custom') { $langcode = $form_state['values']['langcode']; @@ -109,7 +110,7 @@ public function submitForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function actions(array $form, array &$form_state) { + public function actions(array $form, FormStateInterface $form_state) { // No actions needed. return array(); } @@ -117,7 +118,7 @@ public function actions(array $form, array &$form_state) { /** * Validates the language addition form on custom language button. */ - public function validateCustom(array $form, array &$form_state) { + public function validateCustom(array $form, FormStateInterface $form_state) { if ($form_state['values']['predefined_langcode'] == 'custom') { $langcode = $form_state['values']['langcode']; // Reuse the editing form validation routine if we add a custom language. @@ -135,7 +136,7 @@ public function validateCustom(array $form, array &$form_state) { /** * Element specific validator for the Add language button. */ - public function validatePredefined($form, &$form_state) { + public function validatePredefined($form, FormStateInterface $form_state) { $langcode = $form_state['values']['predefined_langcode']; if ($langcode == 'custom') { $this->setFormError('predefined_langcode', $form_state, $this->t('Fill in the language details and save the language with Add custom language.')); diff --git a/core/modules/language/src/Form/LanguageDeleteForm.php b/core/modules/language/src/Form/LanguageDeleteForm.php index 8ef8aec68813448af17e934be2eef2bed0802bd7..db158e00a0d4175f1709a24e6e4ae0183388ef63 100644 --- a/core/modules/language/src/Form/LanguageDeleteForm.php +++ b/core/modules/language/src/Form/LanguageDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\language\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -84,7 +85,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $langcode = $this->entity->id(); // Warn and redirect user when attempting to delete the default language. @@ -105,7 +106,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/language/src/Form/LanguageEditForm.php b/core/modules/language/src/Form/LanguageEditForm.php index 2dacdc2785b5d61626bb94bbfa1e34521e1dec9c..f5d7498e174e5f18c607cac08f7b378ea1524c48 100644 --- a/core/modules/language/src/Form/LanguageEditForm.php +++ b/core/modules/language/src/Form/LanguageEditForm.php @@ -7,6 +7,7 @@ namespace Drupal\language\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\language\Form\LanguageFormBase; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $this->commonForm($form); return parent::form($form, $form_state); } @@ -33,7 +34,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function actions(array $form, array &$form_state) { + public function actions(array $form, FormStateInterface $form_state) { $actions['submit'] = array( '#type' => 'submit', '#value' => $this->t('Save language'), @@ -46,7 +47,7 @@ public function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Prepare a language object for saving. $languages = language_list(); $langcode = $form_state['values']['langcode']; diff --git a/core/modules/language/src/Form/LanguageFormBase.php b/core/modules/language/src/Form/LanguageFormBase.php index 583787abc631a920e8ac6380ea3557df4c9af581..880a017e986ba2a411e2cd3cd36f61a389c8243b 100644 --- a/core/modules/language/src/Form/LanguageFormBase.php +++ b/core/modules/language/src/Form/LanguageFormBase.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\EntityForm; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\language\ConfigurableLanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -96,7 +97,7 @@ public function commonForm(array &$form) { /** * Validates the language editing element. */ - public function validateCommon(array $form, array &$form_state) { + public function validateCommon(array $form, FormStateInterface $form_state) { // Ensure sane field values for langcode and name. if (!isset($form['langcode_view']) && preg_match('@[^a-zA-Z_-]@', $form_state['values']['langcode'])) { $this->setFormError('langcode', $form_state, $this->t('%field may only contain characters a-z, underscores, or hyphens.', array('%field' => $form['langcode']['#title']))); diff --git a/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php b/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php index 3fa4a864243debc21537344183e537e31c237c7c..43fd8b49310b7fa6fbc6dd63407a415e5adb1338 100644 --- a/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php +++ b/core/modules/language/src/Form/NegotiationBrowserDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\language\Form; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\HttpFoundation\Request; @@ -47,7 +48,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $browser_langcode = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $browser_langcode = NULL) { $this->browserLangcode = $browser_langcode; $form = parent::buildForm($form, $form_state); @@ -58,7 +59,7 @@ public function buildForm(array $form, array &$form_state, $browser_langcode = N /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $mappings = language_get_browser_drupal_langcode_mappings(); if (array_key_exists($this->browserLangcode, $mappings)) { diff --git a/core/modules/language/src/Form/NegotiationBrowserForm.php b/core/modules/language/src/Form/NegotiationBrowserForm.php index f82e54a90e8e5c7e7b4bc88f921b789dc6ae6736..9d1177bd769e4c10658f41b98a931deee3a10b31 100644 --- a/core/modules/language/src/Form/NegotiationBrowserForm.php +++ b/core/modules/language/src/Form/NegotiationBrowserForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\language\ConfigurableLanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -55,7 +56,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = array(); // Initialize a language list to the ones available, including English. @@ -128,7 +129,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // Array to check if all browser language codes are unique. $unique_values = array(); @@ -167,7 +168,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $mappings = $form_state['mappings']; if (!empty($mappings)) { $config = $this->config('language.mappings'); diff --git a/core/modules/language/src/Form/NegotiationConfigureForm.php b/core/modules/language/src/Form/NegotiationConfigureForm.php index a6d241f32b63d6014d3c2c3624768e24e3668413..afc39aa1b61fd4732d9f6dababac2a3de209f38c 100644 --- a/core/modules/language/src/Form/NegotiationConfigureForm.php +++ b/core/modules/language/src/Form/NegotiationConfigureForm.php @@ -14,6 +14,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\language\ConfigurableLanguageManagerInterface; use Drupal\language\LanguageNegotiatorInterface; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSelected; @@ -93,7 +94,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $configurable = $this->languageTypes->get('configurable'); $form = array( @@ -127,7 +128,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $configurable_types = $form['#language_types']; $stored_values = $this->languageTypes->get('configurable'); diff --git a/core/modules/language/src/Form/NegotiationSelectedForm.php b/core/modules/language/src/Form/NegotiationSelectedForm.php index 47d61eb23c2aaf25ddf74c8569ad126349858907..f88daa81f604c6ff41f0922612b4c516a240db47 100644 --- a/core/modules/language/src/Form/NegotiationSelectedForm.php +++ b/core/modules/language/src/Form/NegotiationSelectedForm.php @@ -7,6 +7,7 @@ namespace Drupal\language\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Form\ConfigFormBase; @@ -23,9 +24,9 @@ public function getFormId() { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('language.negotiation'); $form['selected_langcode'] = array( '#type' => 'language_select', @@ -38,9 +39,9 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('language.negotiation') ->set('selected_langcode', $form_state['values']['selected_langcode']) ->save(); diff --git a/core/modules/language/src/Form/NegotiationSessionForm.php b/core/modules/language/src/Form/NegotiationSessionForm.php index 13936af8d77018b974c8c04d451c5400dc7c72ba..ef4cb3dbf0cbfc13a0265574df1082704a117566 100644 --- a/core/modules/language/src/Form/NegotiationSessionForm.php +++ b/core/modules/language/src/Form/NegotiationSessionForm.php @@ -8,6 +8,7 @@ namespace Drupal\language\Form; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Configure the session language negotiation method for this site. @@ -22,9 +23,9 @@ public function getFormId() { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('language.negotiation'); $form['language_negotiation_session_param'] = array( '#title' => t('Request/session parameter'), @@ -39,9 +40,9 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('language.settings') ->set('session.parameter', $form_state['values']['language_negotiation_session_param']) ->save(); diff --git a/core/modules/language/src/Form/NegotiationUrlForm.php b/core/modules/language/src/Form/NegotiationUrlForm.php index d8c24905b8271691f27520e5049fe8142c943263..96cbbb8a2cc3b5fc9b7b1c53b8604584ca859a85 100644 --- a/core/modules/language/src/Form/NegotiationUrlForm.php +++ b/core/modules/language/src/Form/NegotiationUrlForm.php @@ -8,6 +8,7 @@ namespace Drupal\language\Form; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl; /** @@ -23,9 +24,9 @@ public function getFormId() { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { global $base_url; $config = $this->config('language.negotiation'); @@ -96,7 +97,7 @@ public function buildForm(array $form, array &$form_state) { /** * Implements \Drupal\Core\Form\FormInterface::validateForm(). */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $languages = language_list(); // Count repeated values for uniqueness check. @@ -158,9 +159,9 @@ public function validateForm(array &$form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Save selected format (prefix or domain). $this->config('language.negotiation') ->set('url.source', $form_state['values']['language_negotiation_url_part']) diff --git a/core/modules/language/src/LanguageListBuilder.php b/core/modules/language/src/LanguageListBuilder.php index c5bd66a30f6af7bdc3fdea9113c42d40efb70eee..3c28810dd46676b5f73d2741631f89c487cde672 100644 --- a/core/modules/language/src/LanguageListBuilder.php +++ b/core/modules/language/src/LanguageListBuilder.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\Entity\DraggableListBuilder; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormStateInterface; /** * Defines a class to build a listing of language entities. @@ -75,7 +76,7 @@ public function buildRow(EntityInterface $entity) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $form[$this->entitiesKey]['#languages'] = $this->entities; $form['actions']['submit']['#value'] = t('Save configuration'); @@ -85,7 +86,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $language_manager = \Drupal::languageManager(); diff --git a/core/modules/language/src/Plugin/Condition/Language.php b/core/modules/language/src/Plugin/Condition/Language.php index 46a99cb11b822178762089cd642a4a86a70b9667..3ae2b09a751c6210aaa484360181d6e9c84fd096 100644 --- a/core/modules/language/src/Plugin/Condition/Language.php +++ b/core/modules/language/src/Plugin/Condition/Language.php @@ -8,6 +8,7 @@ namespace Drupal\language\Plugin\Condition; use Drupal\Core\Condition\ConditionPluginBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; /** @@ -27,7 +28,7 @@ class Language extends ConditionPluginBase { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { if (\Drupal::languageManager()->isMultilingual()) { // Fetch languages. $languages = language_list(LanguageInterface::STATE_ALL); @@ -55,7 +56,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['langcodes'] = array_filter($form_state['values']['langcodes']); parent::submitConfigurationForm($form, $form_state); } diff --git a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php index a213d5cd95c8002f0e809c32da9e09d91069955c..f9a0e1bb743d0c847dde0ba78a9c7d920eacf02d 100644 --- a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php +++ b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElement.php @@ -7,6 +7,7 @@ namespace Drupal\language_elements_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * A form containing a language configuration element. @@ -23,7 +24,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $conf = language_get_default_configuration('some_custom_type', 'some_bundle'); $form['lang_configuration'] = array( @@ -46,6 +47,6 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php index bf531497187e3afe83463b7844ca4d8c75d55911..130c069e9aba2506234f2cd13a2a842cc8827a8c 100644 --- a/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php +++ b/core/modules/language/tests/language_elements_test/src/Form/LanguageConfigurationElementTest.php @@ -7,6 +7,7 @@ namespace Drupal\language_elements_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * A form containing a language select element. @@ -23,7 +24,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => t('Language select'), '#type' => 'language_select', @@ -35,6 +36,6 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php index 37df04984fa73fa874109121450dc4afff2876a1..0c08d66f53347f2945ee4bc678078ec48cd311f6 100644 --- a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php +++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FormatterBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\link\LinkItemInterface; @@ -42,7 +43,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $elements = parent::settingsForm($form, $form_state); $elements['trim_length'] = array( diff --git a/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php b/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php index 850c19e58864da0ccd685819786792d8abe27084..f8639bb6f127bfc654dffe6089b8a80079c5d159 100644 --- a/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php +++ b/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\MapDataDefinition; use Drupal\link\LinkItemInterface; @@ -104,7 +105,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { $element = array(); $element['link_type'] = array( diff --git a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php index 27072ee2cd8e685ac0e4c682a14027af18d87cf8..568f64cbbf0a4478da2c5bea0744003a32b17fa2 100644 --- a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php +++ b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\ParamConverter\ParamNotConvertedException; use Drupal\Core\Routing\MatchingRouteNotFoundException; use Drupal\Core\Url; @@ -42,7 +43,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $default_url_value = NULL; if (isset($items[$delta]->url)) { @@ -138,7 +139,7 @@ protected function supportsExternalLinks() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $elements = parent::settingsForm($form, $form_state); $elements['placeholder_url'] = array( @@ -190,7 +191,7 @@ public function settingsSummary() { * * Conditionally requires the link title if a URL value was filled in. */ - public function validateTitle(&$element, &$form_state, $form) { + public function validateTitle(&$element, FormStateInterface $form_state, $form) { if ($element['url']['#value'] !== '' && $element['title']['#value'] === '') { $element['title']['#required'] = TRUE; \Drupal::formBuilder()->setError($element['title'], $form_state, $this->t('!name field is required.', array('!name' => $element['title']['#title']))); @@ -200,7 +201,7 @@ public function validateTitle(&$element, &$form_state, $form) { /** * {@inheritdoc} */ - public function massageFormValues(array $values, array $form, array &$form_state) { + public function massageFormValues(array $values, array $form, FormStateInterface $form_state) { foreach ($values as &$value) { if (!empty($value['url'])) { try { diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 0728d0762f6fead89f7406a4f8cda68847d0e86a..7f40bf4a3509e6fcf7b19bfd0153ac4be191af32 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -14,6 +14,7 @@ use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\Xss; use Drupal\Core\Cache\Cache; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\Language; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\StringTranslation\TranslationWrapper; @@ -647,7 +648,7 @@ function locale_library_alter(array &$library, $name) { /** * Implements hook_form_FORM_ID_alter() for language_admin_overview_form(). */ -function locale_form_language_admin_overview_form_alter(&$form, &$form_state) { +function locale_form_language_admin_overview_form_alter(&$form, FormStateInterface $form_state) { $languages = $form['languages']['#languages']; $total_strings = \Drupal::service('locale.storage')->countStrings(); @@ -700,7 +701,7 @@ function locale_form_language_admin_overview_form_alter(&$form, &$form_state) { /** * Implements hook_form_FORM_ID_alter() for language_admin_add_form(). */ -function locale_form_language_admin_add_form_alter(&$form, &$form_state) { +function locale_form_language_admin_add_form_alter(&$form, FormStateInterface $form_state) { $form['predefined_submit']['#submit'][] = 'locale_form_language_admin_add_form_alter_submit'; $form['custom_language']['submit']['#submit'][] = 'locale_form_language_admin_add_form_alter_submit'; } @@ -736,7 +737,7 @@ function locale_form_language_admin_add_form_alter_submit($form, $form_state) { /** * Implements hook_form_FORM_ID_alter() for language_admin_edit_form(). */ -function locale_form_language_admin_edit_form_alter(&$form, &$form_state) { +function locale_form_language_admin_edit_form_alter(&$form, FormStateInterface $form_state) { if ($form['langcode']['#type'] == 'value' && $form['langcode']['#value'] == 'en') { $form['locale_translate_english'] = array( '#title' => t('Enable interface translation to English'), diff --git a/core/modules/locale/src/Form/ExportForm.php b/core/modules/locale/src/Form/ExportForm.php index ea4a153fe03968285fe64cd6e4dc6293595b803d..5177c694d862bc5f59bad75d07ce5bac11ae741c 100644 --- a/core/modules/locale/src/Form/ExportForm.php +++ b/core/modules/locale/src/Form/ExportForm.php @@ -9,6 +9,7 @@ use Drupal\Component\Gettext\PoStreamWriter; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\locale\PoDatabaseReader; @@ -56,7 +57,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $languages = $this->languageManager->getLanguages(); $language_options = array(); foreach ($languages as $langcode => $language) { @@ -127,7 +128,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // If template is required, language code is not given. if ($form_state['values']['langcode'] != LanguageInterface::LANGCODE_SYSTEM) { $language = $this->languageManager->getLanguage($form_state['values']['langcode']); diff --git a/core/modules/locale/src/Form/ImportForm.php b/core/modules/locale/src/Form/ImportForm.php index 544dc36f287de67a16987016c5f2e7b0d8989fda..d74328e978afc700787b881dd15ad93290739c13 100644 --- a/core/modules/locale/src/Form/ImportForm.php +++ b/core/modules/locale/src/Form/ImportForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\Language; use Drupal\language\ConfigurableLanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -71,7 +72,7 @@ public function getFormID() { /** * Form constructor for the translation import screen. */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $languages = $this->languageManager->getLanguages(); // Initialize a language list to the ones available, including English if we @@ -157,7 +158,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $this->file = file_save_upload('file', $form['file']['#upload_validators'], 'translations://', 0); // Ensure we have the file uploaded. @@ -169,7 +170,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Add language, if not yet supported. $language = $this->languageManager->getLanguage($form_state['values']['langcode']); if (empty($language)) { diff --git a/core/modules/locale/src/Form/LocaleSettingsForm.php b/core/modules/locale/src/Form/LocaleSettingsForm.php index e1b13d07016005b61c20cc8d4f44d21e73851b40..3846aafe3ec58c6e5db7f94b8a7ffb042849c9e3 100644 --- a/core/modules/locale/src/Form/LocaleSettingsForm.php +++ b/core/modules/locale/src/Form/LocaleSettingsForm.php @@ -7,6 +7,7 @@ namespace Drupal\locale\Form; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Configure locale settings for this site. @@ -21,9 +22,9 @@ public function getFormId() { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('locale.settings'); $form['update_interval_days'] = array( @@ -83,7 +84,7 @@ public function buildForm(array $form, array &$form_state) { /** * Implements \Drupal\Core\Form\FormInterface::validateForm(). */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); if (empty($form['#translation_directory']) && $form_state['values']['use_source'] == LOCALE_TRANSLATION_USE_SOURCE_LOCAL) { @@ -92,9 +93,9 @@ public function validateForm(array &$form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state['values']; $config = $this->config('locale.settings'); diff --git a/core/modules/locale/src/Form/TranslateEditForm.php b/core/modules/locale/src/Form/TranslateEditForm.php index c01accbffd6d8914093f096d5918b88576f2394a..6c582d3d38afe385e1b0388b9dfca7e00f741947 100644 --- a/core/modules/locale/src/Form/TranslateEditForm.php +++ b/core/modules/locale/src/Form/TranslateEditForm.php @@ -8,6 +8,7 @@ namespace Drupal\locale\Form; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\locale\SourceString; @@ -26,7 +27,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $filter_values = $this->translateFilterValues(); $langcode = $filter_values['langcode']; @@ -158,7 +159,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $langcode = $form_state['values']['langcode']; foreach ($form_state['values']['strings'] as $lid => $translations) { foreach ($translations['translations'] as $key => $value) { @@ -174,7 +175,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $langcode = $form_state['values']['langcode']; $updated = array(); diff --git a/core/modules/locale/src/Form/TranslateFilterForm.php b/core/modules/locale/src/Form/TranslateFilterForm.php index 213935abbb55d853200c53ddf5313dcb1df546c8..a9be9f5b0d95dd89c2bd7a40031afec804ffd52f 100644 --- a/core/modules/locale/src/Form/TranslateFilterForm.php +++ b/core/modules/locale/src/Form/TranslateFilterForm.php @@ -7,6 +7,8 @@ namespace Drupal\locale\Form; +use Drupal\Core\Form\FormStateInterface; + /** * Provides a filtered translation edit form. */ @@ -22,7 +24,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $filters = $this->translateFilters(); $filter_values = $this->translateFilterValues(); @@ -82,7 +84,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $filters = $this->translateFilters(); foreach ($filters as $name => $filter) { if (isset($form_state['values'][$name])) { @@ -95,7 +97,7 @@ public function submitForm(array &$form, array &$form_state) { /** * Provides a submit handler for the reset button. */ - public function resetForm(array &$form, array &$form_state) { + public function resetForm(array &$form, FormStateInterface $form_state) { $_SESSION['locale_translate_filter'] = array(); $form_state['redirect_route']['route_name'] = 'locale.translate_page'; } diff --git a/core/modules/locale/src/Form/TranslationStatusForm.php b/core/modules/locale/src/Form/TranslationStatusForm.php index a1c7e3496c77b8ec12e6a28ecd0439db0e86a9fc..b09658f71f06fe49d74e3fc75ad19205c1411016 100644 --- a/core/modules/locale/src/Form/TranslationStatusForm.php +++ b/core/modules/locale/src/Form/TranslationStatusForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\State\StateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -67,7 +68,7 @@ public function getFormID() { * * @ingroup forms */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $languages = locale_translatable_language_list(); $status = locale_translation_get_status(); $options = array(); @@ -264,7 +265,7 @@ protected function createInfoString($project_info) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // Check if a language has been selected. 'tableselect' doesn't. if (!array_filter($form_state['values']['langcodes'])) { $this->setFormError('', $this->t('Select a language to update.')); @@ -274,7 +275,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->moduleHandler->loadInclude('locale', 'fetch.inc'); $langcodes = array_filter($form_state['values']['langcodes']); $projects = array_filter($form_state['values']['projects_update']); diff --git a/core/modules/menu_link_content/src/Form/MenuLinkContentDeleteForm.php b/core/modules/menu_link_content/src/Form/MenuLinkContentDeleteForm.php index 4951cfbc563f47cf8cb6359e8cd35e6a82546265..7d79bd5ea8976d728d3a72f8470453f323807ed4 100644 --- a/core/modules/menu_link_content/src/Form/MenuLinkContentDeleteForm.php +++ b/core/modules/menu_link_content/src/Form/MenuLinkContentDeleteForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\ContentEntityConfirmFormBase; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -65,7 +66,7 @@ public function getCancelUrl() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $t_args = array('%title' => $this->entity->getTitle()); $this->entity->delete(); drupal_set_message($this->t('The menu link %title has been deleted.', $t_args)); diff --git a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php index 7b5d6ef96f2af2ee3be5aae51159c68b019dd560..727d8b24b2599e40643c5cdc97322b1d96e40c31 100644 --- a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php +++ b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php @@ -12,6 +12,7 @@ use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Menu\Form\MenuLinkFormInterface; @@ -143,7 +144,7 @@ public function setMenuLinkInstance(MenuLinkInterface $menu_link) { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $this->setOperation('default'); $this->init($form_state); @@ -153,14 +154,14 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { $this->doValidate($form, $form_state); } /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { // Remove button and internal Form API values from submitted values. parent::submit($form, $form_state); $this->save($form, $form_state); @@ -209,7 +210,7 @@ protected function extractUrl($url) { /** * {@inheritdoc} */ - public function extractFormValues(array &$form, array &$form_state) { + public function extractFormValues(array &$form, FormStateInterface $form_state) { $new_definition = array(); $new_definition['expanded'] = !empty($form_state['values']['expanded']['value']) ? 1 : 0; $new_definition['hidden'] = empty($form_state['values']['enabled']) ? 1 : 0; @@ -240,7 +241,7 @@ public function extractFormValues(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); // We always show the internal path here. @@ -314,7 +315,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $element = parent::actions($form, $form_state); $element['submit']['#button_type'] = 'primary'; $element['delete']['#access'] = $this->entity->access('delete'); @@ -325,7 +326,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { $this->doValidate($form, $form_state); parent::validate($form, $form_state); @@ -334,7 +335,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function buildEntity(array $form, array &$form_state) { + public function buildEntity(array $form, FormStateInterface $form_state) { /** @var \Drupal\menu_link_content\Entity\MenuLinkContentInterface $entity */ $entity = parent::buildEntity($form, $form_state); $new_definition = $this->extractFormValues($form, $form_state); @@ -355,7 +356,7 @@ public function buildEntity(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { // The entity is rebuilt in parent::submit(). $menu_link = $this->entity; $saved = $menu_link->save(); @@ -383,10 +384,10 @@ public function save(array $form, array &$form_state) { * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - protected function doValidate(array $form, array &$form_state) { + protected function doValidate(array $form, FormStateInterface $form_state) { $extracted = $this->extractUrl($form_state['values']['url']); // If both URL and route_name are empty, the entered value is not valid. diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index 79cd051e5b61b64348928d31f4883f7620e2657f..8dbb4e2c1cddfde721e54fdb90acceecde74493b 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\block\BlockPluginInterface; use Drupal\Core\Menu\MenuLinkInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\menu_link_content\Entity\MenuLinkContent; @@ -245,7 +246,7 @@ function menu_ui_node_predelete(EntityInterface $node) { /** * Implements hook_node_prepare_form(). */ -function menu_ui_node_prepare_form(NodeInterface $node, $operation, array &$form_state) { +function menu_ui_node_prepare_form(NodeInterface $node, $operation, FormStateInterface $form_state) { if (empty($form_state['menu_link_definition'])) { // Prepare the node for the edit form so that $node->menu always exists. $node_type_config = \Drupal::config('menu.entity.node.' . $node->getType()); diff --git a/core/modules/menu_ui/src/Form/MenuDeleteForm.php b/core/modules/menu_ui/src/Form/MenuDeleteForm.php index 5c3cd961911171dce755a95101aa235f9564aef6..2332b40ec94b61d5bf18d1456e0bffdb0f7ecea7 100644 --- a/core/modules/menu_ui/src/Form/MenuDeleteForm.php +++ b/core/modules/menu_ui/src/Form/MenuDeleteForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Menu\MenuLinkManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -92,7 +93,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $form_state['redirect_route'] = new Url('menu_ui.overview_page'); // Locked menus may not be deleted. diff --git a/core/modules/menu_ui/src/Form/MenuLinkEditForm.php b/core/modules/menu_ui/src/Form/MenuLinkEditForm.php index cbe096c05e729ae3acd49f2dca3de6183de863ff..ebd691f78dbdc9b2a996cc6b5356ff6a8bfb45bc 100644 --- a/core/modules/menu_ui/src/Form/MenuLinkEditForm.php +++ b/core/modules/menu_ui/src/Form/MenuLinkEditForm.php @@ -9,6 +9,7 @@ use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Menu\MenuLinkInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -60,7 +61,7 @@ public function getFormId() { * @param \Drupal\Core\Menu\MenuLinkInterface $menu_link_plugin * The plugin instance to use for this form. */ - public function buildForm(array $form, array &$form_state, MenuLinkInterface $menu_link_plugin = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, MenuLinkInterface $menu_link_plugin = NULL) { $form['menu_link_id'] = array( '#type' => 'value', '#value' => $menu_link_plugin->getPluginId(), @@ -83,14 +84,14 @@ public function buildForm(array $form, array &$form_state, MenuLinkInterface $me /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $form['#plugin_form']->validateConfigurationForm($form, $form_state); } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $link = $form['#plugin_form']->submitConfigurationForm($form, $form_state); drupal_set_message($this->t('The menu link has been saved.')); diff --git a/core/modules/menu_ui/src/Form/MenuLinkResetForm.php b/core/modules/menu_ui/src/Form/MenuLinkResetForm.php index 6bb22e1218b93a34f1c871e9617c19463b8d9bb5..09cfb87c40a297c662c233736177b74123e8d440 100644 --- a/core/modules/menu_ui/src/Form/MenuLinkResetForm.php +++ b/core/modules/menu_ui/src/Form/MenuLinkResetForm.php @@ -7,6 +7,7 @@ namespace Drupal\menu_ui\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Menu\MenuLinkManagerInterface; @@ -92,7 +93,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, MenuLinkInterface $menu_link_plugin = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, MenuLinkInterface $menu_link_plugin = NULL) { $this->link = $menu_link_plugin; $form = parent::buildForm($form, $form_state); @@ -102,7 +103,7 @@ public function buildForm(array $form, array &$form_state, MenuLinkInterface $me /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->link = $this->menuLinkManager->resetLink($this->link->getPluginId()); drupal_set_message($this->t('The menu link was reset to its default settings.')); $form_state['redirect_route'] = $this->getCancelUrl(); diff --git a/core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php index 5e32eafce309298bbf035a2d816f5190085d74f4..d115736a4e9b5710adbe2c61887d0b0539fd559c 100644 --- a/core/modules/menu_ui/src/MenuForm.php +++ b/core/modules/menu_ui/src/MenuForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Menu\MenuLinkManagerInterface; use Drupal\Core\Menu\MenuLinkTreeElement; @@ -94,7 +95,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $menu = $this->entity; if ($this->operation == 'edit') { @@ -173,7 +174,7 @@ public function menuNameExists($value) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $menu = $this->entity; if (!$menu->isNew() || $menu->isLocked()) { $this->submitOverviewForm($form, $form_state); @@ -208,12 +209,12 @@ public function save(array $form, array &$form_state) { * Forms integrating this section should call menu_overview_form_submit() from * their form submit handler. */ - protected function buildOverviewForm(array &$form, array &$form_state) { + protected function buildOverviewForm(array &$form, FormStateInterface $form_state) { // Ensure that menu_overview_form_submit() knows the parents of this form // section. $form['#tree'] = TRUE; $form['#theme'] = 'menu_overview_form'; - $form_state += array('menu_overview_form_parents' => array()); + $form_state->setIfNotExists('menu_overview_form_parents', array()); $form['#attached']['css'] = array(drupal_get_path('module', 'menu') . '/css/menu.admin.css'); @@ -350,7 +351,7 @@ protected function buildOverviewTreeForm($tree, $delta) { * This function takes great care in saving parent items first, then items * underneath them. Saving items in the incorrect order can break the tree. */ - protected function submitOverviewForm(array $complete_form, array &$form_state) { + protected function submitOverviewForm(array $complete_form, FormStateInterface $form_state) { // Form API supports constructing and validating self-contained sections // within forms, but does not allow to handle the form section's submission // equally separated yet. Therefore, we use a $form_state key to point to diff --git a/core/modules/menu_ui/src/MenuSettingsForm.php b/core/modules/menu_ui/src/MenuSettingsForm.php index 73bc7d7a015ac43d30df7082b23ac534abe85c91..77c3c157de329386e2c0a612ad6e541f43060f13 100644 --- a/core/modules/menu_ui/src/MenuSettingsForm.php +++ b/core/modules/menu_ui/src/MenuSettingsForm.php @@ -8,6 +8,7 @@ namespace Drupal\menu_ui; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Select the menus to be used for the main and secondary links for this site. @@ -22,9 +23,9 @@ public function getFormId() { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('menu_ui.settings'); $form['intro'] = array( '#type' => 'item', @@ -58,9 +59,9 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('menu_ui.settings') ->set('main_links', $form_state['values']['menu_main_links_source']) ->set('secondary_links', $form_state['values']['menu_secondary_links_source']) diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index 56154d17816b7fe08e2df255343c50bbc721c2ec..9ac1c40b8f594c1edd3d0ae9496e0855b5f7e9fe 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -420,11 +420,11 @@ function hook_node_update_index(\Drupal\node\NodeInterface $node, $langcode) { * @param $form * The form being used to edit the node. * @param $form_state - * The form state array. + * The current state of the form. * * @ingroup entity_crud */ -function hook_node_validate(\Drupal\node\NodeInterface $node, $form, &$form_state) { +function hook_node_validate(\Drupal\node\NodeInterface $node, $form, \Drupal\Core\Form\FormStateInterface $form_state) { if (isset($node->end) && isset($node->start)) { if ($node->start > $node->end) { form_set_error('time', $form_state, t('An event may not end before it starts.')); @@ -447,11 +447,11 @@ function hook_node_validate(\Drupal\node\NodeInterface $node, $form, &$form_stat * @param $form * The form being used to edit the node. * @param $form_state - * The form state array. + * The current state of the form. * * @ingroup entity_crud */ -function hook_node_submit(\Drupal\node\NodeInterface $node, $form, &$form_state) { +function hook_node_submit(\Drupal\node\NodeInterface $node, $form, \Drupal\Core\Form\FormStateInterface $form_state) { // Decompose the selected menu parent option into 'menu_name' and 'parent', if // the form used the default parent selection widget. if (!empty($form_state['values']['menu']['parent'])) { diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 1a27d145f2377e07338d662c7d4e7d7730c7b328..fdec8ba9fc63cba3dae3bcefad1c377d9967aba5 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -9,6 +9,7 @@ */ use Drupal\Component\Utility\Xss; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; @@ -1053,7 +1054,7 @@ function node_view_multiple($nodes, $view_mode = 'teaser', $langcode = NULL) { * @see taxonomy_term_page() * @see node_form_system_site_information_settings_form_submit() */ -function node_form_system_site_information_settings_form_alter(&$form, &$form_state, $form_id) { +function node_form_system_site_information_settings_form_alter(&$form, FormStateInterface $form_state, $form_id) { $options = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30); $form['front_page']['default_nodes_main'] = array( '#type' => 'select', @@ -1071,7 +1072,7 @@ function node_form_system_site_information_settings_form_alter(&$form, &$form_st * * @see node_form_system_site_information_settings_form_alter() */ -function node_form_system_site_information_settings_form_submit($form, &$form_state) { +function node_form_system_site_information_settings_form_submit($form, FormStateInterface $form_state) { \Drupal::config('node.settings') ->set('items_per_page', $form_state['values']['default_nodes_main']) ->save(); @@ -1084,7 +1085,7 @@ function node_form_system_site_information_settings_form_submit($form, &$form_st * * @see node_form_system_themes_admin_form_submit() */ -function node_form_system_themes_admin_form_alter(&$form, &$form_state, $form_id) { +function node_form_system_themes_admin_form_alter(&$form, FormStateInterface $form_state, $form_id) { $form['admin_theme']['use_admin_theme'] = array( '#type' => 'checkbox', '#title' => t('Use the administration theme when editing or creating content'), @@ -1098,7 +1099,7 @@ function node_form_system_themes_admin_form_alter(&$form, &$form_state, $form_id * * @see node_form_system_themes_admin_form_alter() */ -function node_form_system_themes_admin_form_submit($form, &$form_state) { +function node_form_system_themes_admin_form_submit($form, FormStateInterface $form_state) { \Drupal::config('node.settings') ->set('use_admin_theme', $form_state['values']['use_admin_theme']) ->save(); diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index 9757596de3c623b01c6476659c45d152c3754b6b..e848f3e56f3c6d05a00a292c6209344f61cf56d9 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -10,6 +10,7 @@ */ use Drupal\Component\Utility\Xss; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Drupal\node\NodeInterface; @@ -48,7 +49,7 @@ function template_preprocess_node_add_list(&$variables) { * * @see node_form_build_preview() */ -function node_preview(NodeInterface $node, array &$form_state) { +function node_preview(NodeInterface $node, FormStateInterface $form_state) { if ($node->access('create') || $node->access('update')) { $node->changed = REQUEST_TIME; diff --git a/core/modules/node/src/Form/DeleteMultiple.php b/core/modules/node/src/Form/DeleteMultiple.php index 4044098f1b8c9c041f87acdcc5af456eaeeb436c..a067ccb0693bf4d04d55d9566792c0dbbfdbdcb2 100644 --- a/core/modules/node/src/Form/DeleteMultiple.php +++ b/core/modules/node/src/Form/DeleteMultiple.php @@ -11,6 +11,7 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Url; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\user\TempStoreFactory; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -95,7 +96,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $this->nodes = $this->tempStoreFactory->get('node_multiple_delete_confirm')->get(\Drupal::currentUser()->id()); if (empty($this->nodes)) { return new RedirectResponse(url('admin/content', array('absolute' => TRUE))); @@ -115,7 +116,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state['values']['confirm'] && !empty($this->nodes)) { $this->storage->delete($this->nodes); $this->tempStoreFactory->get('node_multiple_delete_confirm')->delete(\Drupal::currentUser()->id()); diff --git a/core/modules/node/src/Form/NodeDeleteForm.php b/core/modules/node/src/Form/NodeDeleteForm.php index 3b5a6156f83b7311aba175468902e56125b380a7..19faa67a5e5fca5c11108bdc694daa4088393f9f 100644 --- a/core/modules/node/src/Form/NodeDeleteForm.php +++ b/core/modules/node/src/Form/NodeDeleteForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\ContentEntityConfirmFormBase; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -71,7 +72,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/src/Form/NodeRevisionDeleteForm.php b/core/modules/node/src/Form/NodeRevisionDeleteForm.php index 3f240e4403f4a96b9cd1b17bb387db3fa800d744..0ab753dc0a46c7f459a900d341c2c14677e92c77 100644 --- a/core/modules/node/src/Form/NodeRevisionDeleteForm.php +++ b/core/modules/node/src/Form/NodeRevisionDeleteForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -106,7 +107,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $node_revision = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $node_revision = NULL) { $this->revision = $this->nodeStorage->loadRevision($node_revision); $form = parent::buildForm($form, $form_state); @@ -116,7 +117,7 @@ public function buildForm(array $form, array &$form_state, $node_revision = NULL /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->nodeStorage->deleteRevision($this->revision->getRevisionId()); watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId())); diff --git a/core/modules/node/src/Form/NodeRevisionRevertForm.php b/core/modules/node/src/Form/NodeRevisionRevertForm.php index a1e7c454a8cf960d11392942f65cff6de3b920e1..147036fab8c2e6da4f4b0d27cb21f0e72eba2b40 100644 --- a/core/modules/node/src/Form/NodeRevisionRevertForm.php +++ b/core/modules/node/src/Form/NodeRevisionRevertForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -89,7 +90,7 @@ public function getDescription() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $node_revision = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $node_revision = NULL) { $this->revision = $this->nodeStorage->loadRevision($node_revision); $form = parent::buildForm($form, $form_state); @@ -99,7 +100,7 @@ public function buildForm(array $form, array &$form_state, $node_revision = NULL /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->revision->setNewRevision(); // Make this the new default revision for the node. $this->revision->isDefaultRevision(TRUE); diff --git a/core/modules/node/src/Form/NodeTypeDeleteConfirm.php b/core/modules/node/src/Form/NodeTypeDeleteConfirm.php index fdd71e8bdfa6675cb1fed6cd7046b7e3ff2a2d17..0c23ced81c57258009ba9e2e50daa457d70d9e85 100644 --- a/core/modules/node/src/Form/NodeTypeDeleteConfirm.php +++ b/core/modules/node/src/Form/NodeTypeDeleteConfirm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Database\Connection; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -67,7 +68,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $num_nodes = $this->database->query("SELECT COUNT(*) FROM {node} WHERE type = :type", array(':type' => $this->entity->id()))->fetchField(); if ($num_nodes) { $caption = '

' . format_plural($num_nodes, '%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', '%type is used by @count pieces of content on your site. You may not remove %type until you have removed all of the %type content.', array('%type' => $this->entity->label())) . '

'; @@ -82,7 +83,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/src/Form/RebuildPermissionsForm.php b/core/modules/node/src/Form/RebuildPermissionsForm.php index 490c3d2149947bc13e4cd58680e2a8ba62a40913..9f8da72e943b7326d530c851e2cb412ed54749d0 100644 --- a/core/modules/node/src/Form/RebuildPermissionsForm.php +++ b/core/modules/node/src/Form/RebuildPermissionsForm.php @@ -8,6 +8,7 @@ namespace Drupal\node\Form; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; class RebuildPermissionsForm extends ConfirmFormBase { @@ -50,7 +51,7 @@ public function getDescription() { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { node_access_rebuild(TRUE); $form_state['redirect_route'] = $this->getCancelUrl(); } diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index 69d91a5d7766c5d9e9b2bca936e8a6deed30f1ef..bf4b869fb81bc2b82325b4deb9fb12368e9c4e1d 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\ContentEntityForm; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Component\Utility\String; @@ -43,9 +44,9 @@ protected function prepareEntity() { } /** - * Overrides Drupal\Core\Entity\EntityForm::form(). + * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { /** @var \Drupal\node\NodeInterface $node */ $node = $this->entity; @@ -209,9 +210,9 @@ public function form(array $form, array &$form_state) { } /** - * Overrides Drupal\Core\Entity\EntityForm::actions(). + * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $element = parent::actions($form, $form_state); $node = $this->entity; $preview_mode = $this->settings['preview']; @@ -290,9 +291,9 @@ protected function actions(array $form, array &$form_state) { } /** - * Overrides Drupal\Core\Entity\EntityForm::validate(). + * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { $node = $this->buildEntity($form, $form_state); if ($node->id() && (node_last_changed($node->id(), $this->getFormLangcode($form_state)) > $node->getChangedTime())) { @@ -331,10 +332,8 @@ public function validate(array $form, array &$form_state) { * 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 submit(array $form, FormStateInterface $form_state) { // Build the node object from the submitted values. $node = parent::submit($form, $form_state); @@ -364,9 +363,9 @@ public function submit(array $form, array &$form_state) { * @param $form * An associative array containing the structure of the form. * @param $form_state - * A reference to a keyed array containing the current state of the form. + * The current state of the form. */ - public function preview(array $form, array &$form_state) { + public function preview(array $form, FormStateInterface $form_state) { // @todo Remove this: we should not have explicit includes in autoloaded // classes. module_load_include('inc', 'node', 'node.pages'); @@ -380,9 +379,9 @@ public function preview(array $form, array &$form_state) { * @param $form * An associative array containing the structure of the form. * @param $form_state - * A reference to a keyed array containing the current state of the form. + * The current state of the form. */ - public function publish(array $form, array &$form_state) { + public function publish(array $form, FormStateInterface $form_state) { $node = $this->entity; $node->setPublished(TRUE); return $node; @@ -394,9 +393,9 @@ public function publish(array $form, array &$form_state) { * @param $form * An associative array containing the structure of the form. * @param $form_state - * A reference to a keyed array containing the current state of the form. + * The current state of the form. */ - public function unpublish(array $form, array &$form_state) { + public function unpublish(array $form, FormStateInterface $form_state) { $node = $this->entity; $node->setPublished(FALSE); return $node; @@ -405,7 +404,7 @@ public function unpublish(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function buildEntity(array $form, array &$form_state) { + public function buildEntity(array $form, FormStateInterface $form_state) { /** @var \Drupal\node\NodeInterface $entity */ $entity = parent::buildEntity($form, $form_state); // A user might assign the node author by entering a user name in the node @@ -426,11 +425,10 @@ public function buildEntity(array $form, array &$form_state) { return $entity; } - /** - * Overrides Drupal\Core\Entity\EntityForm::save(). + * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $node = $this->entity; $insert = $node->isNew(); $node->save(); diff --git a/core/modules/node/src/NodeTranslationHandler.php b/core/modules/node/src/NodeTranslationHandler.php index 21ab7e082508a68156ad94bc56a30dfdf5a10e90..02afb6c26bb643f401a37003dfbb1c8bcd6a8c1e 100644 --- a/core/modules/node/src/NodeTranslationHandler.php +++ b/core/modules/node/src/NodeTranslationHandler.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\content_translation\ContentTranslationHandler; +use Drupal\Core\Form\FormStateInterface; /** * Defines the translation handler for nodes. @@ -18,7 +19,7 @@ class NodeTranslationHandler extends ContentTranslationHandler { /** * {@inheritdoc} */ - public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { + public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) { parent::entityFormAlter($form, $form_state, $entity); // Move the translation fieldset to a vertical tab. @@ -73,7 +74,7 @@ protected function entityFormTitle(EntityInterface $entity) { /** * {@inheritdoc} */ - public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, array &$form_state) { + public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) { if (isset($form_state['values']['content_translation'])) { $form_controller = content_translation_form_controller($form_state); $translation = &$form_state['values']['content_translation']; diff --git a/core/modules/node/src/NodeTypeForm.php b/core/modules/node/src/NodeTypeForm.php index ec00d507ff45b5e71fc6f0578288749de38d226f..f8cf92791751829113b4a37246a220f822fdb49b 100644 --- a/core/modules/node/src/NodeTypeForm.php +++ b/core/modules/node/src/NodeTypeForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Component\Utility\String; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Form\FormStateInterface; /** * Form controller for node type forms. @@ -19,7 +20,7 @@ class NodeTypeForm extends EntityForm { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $type = $this->entity; @@ -152,7 +153,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = t('Save content type'); $actions['delete']['#value'] = t('Delete content type'); @@ -162,7 +163,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); $id = trim($form_state['values']['type']); @@ -175,7 +176,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $type = $this->entity; $type->type = trim($type->id()); $type->name = trim($type->name); diff --git a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php index 7823ccb04ae0ebacf44b5ec6352c7725c1e0fe3f..b2ead476bd117dd741eab3d9850d21c62e8b9812 100644 --- a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php +++ b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php @@ -9,6 +9,7 @@ use Drupal\Core\Action\ConfigurableActionBase; use Drupal\Core\Database\Connection; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -77,7 +78,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $description = t('The username of the user to which you would like to assign ownership.'); $count = $this->connection->query("SELECT COUNT(*) FROM {users}")->fetchField(); $owner_name = ''; @@ -117,7 +118,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { $exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users} WHERE name = :name', 0, 1, array(':name' => $form_state['values']['owner_name']))->fetchField(); if (!$exists) { form_set_error('owner_name', $form_state, t('Enter a valid username.')); @@ -127,7 +128,7 @@ public function validateConfigurationForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['owner_uid'] = $this->connection->query('SELECT uid from {users} WHERE name = :name', array(':name' => $form_state['values']['owner_name']))->fetchField(); } diff --git a/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php b/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php index 6fb4674e3fe2280386a7716159a57b69a8b6fb5f..7dab8be862b0e3c5c327e568ff6015aa8a3bf5fc 100644 --- a/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php +++ b/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\Tags; use Drupal\Core\Action\ConfigurableActionBase; +use Drupal\Core\Form\FormStateInterface; /** * Unpublishes a node containing certain keywords. @@ -47,7 +48,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['keywords'] = array( '#title' => t('Keywords'), '#type' => 'textarea', @@ -60,7 +61,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['keywords'] = Tags::explode($form_state['values']['keywords']); } diff --git a/core/modules/node/src/Plugin/Block/SyndicateBlock.php b/core/modules/node/src/Plugin/Block/SyndicateBlock.php index ace314a721cb9264771204e0ba165b826a180353..d0038fcc84e2b248dd58b554556328cb37166ed7 100644 --- a/core/modules/node/src/Plugin/Block/SyndicateBlock.php +++ b/core/modules/node/src/Plugin/Block/SyndicateBlock.php @@ -8,6 +8,7 @@ namespace Drupal\node\Plugin\Block; use Drupal\block\BlockBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; /** @@ -50,7 +51,7 @@ public function build() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); // @see ::isCacheable() diff --git a/core/modules/node/src/Plugin/Condition/NodeType.php b/core/modules/node/src/Plugin/Condition/NodeType.php index 612d82dd9d9020ab9fdaa9e86191232342d5580c..9727bed8446fdd3ab6007fb727cbc2f47edd98ad 100644 --- a/core/modules/node/src/Plugin/Condition/NodeType.php +++ b/core/modules/node/src/Plugin/Condition/NodeType.php @@ -9,6 +9,7 @@ use Drupal\Core\Condition\ConditionPluginBase; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -68,7 +69,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $options = array(); $node_types = $this->entityStorage->loadMultiple(); foreach ($node_types as $type) { @@ -86,7 +87,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['bundles'] = array_filter($form_state['values']['bundles']); parent::submitConfigurationForm($form, $form_state); } diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php index f8e76a8edfc3e4a168f559d8a697a8d46dbcef36..45e34b82f2534375dc91cffafb01e19d61908f30 100644 --- a/core/modules/node/src/Plugin/Search/NodeSearch.php +++ b/core/modules/node/src/Plugin/Search/NodeSearch.php @@ -14,6 +14,7 @@ use Drupal\Core\Database\Query\SelectExtender; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; @@ -398,7 +399,7 @@ public function indexStatus() { /** * {@inheritdoc} */ - public function searchFormAlter(array &$form, array &$form_state) { + public function searchFormAlter(array &$form, FormStateInterface $form_state) { // Add advanced search keyword-related boxes. $form['advanced'] = array( '#type' => 'details', @@ -560,7 +561,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { // Output form for defining rank factor weights. $form['content_ranking'] = array( '#type' => 'details', @@ -589,7 +590,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { foreach ($this->getRankings() as $var => $values) { if (!empty($form_state['values']["rankings_$var"])) { $this->configuration['rankings'][$var] = $form_state['values']["rankings_$var"]; diff --git a/core/modules/node/src/Plugin/views/field/Language.php b/core/modules/node/src/Plugin/views/field/Language.php index af705cbcb7dc250b85d1baab0b70b7cace34ccf9..9f7ff513b70449b39112ac4a1bfd32e9a3eb8b78 100644 --- a/core/modules/node/src/Plugin/views/field/Language.php +++ b/core/modules/node/src/Plugin/views/field/Language.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\node\Plugin\views\field\Node; use Drupal\views\ResultRow; @@ -26,7 +27,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['native_language'] = array( '#title' => t('Native language'), diff --git a/core/modules/node/src/Plugin/views/field/Link.php b/core/modules/node/src/Plugin/views/field/Link.php index d2a89a4ef82f784eae9cad95283dea199898ae7c..b2767477875acc8712989723e78f9f6a3ef07adc 100644 --- a/core/modules/node/src/Plugin/views/field/Link.php +++ b/core/modules/node/src/Plugin/views/field/Link.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; @@ -32,7 +33,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['text'] = array( '#type' => 'textfield', '#title' => t('Text to display'), diff --git a/core/modules/node/src/Plugin/views/field/Node.php b/core/modules/node/src/Plugin/views/field/Node.php index b85cd024cdc1dd81ae02c52ff58e20f2d8f74767..ae74239df9243f00763e95e44156b31aa8de3134 100644 --- a/core/modules/node/src/Plugin/views/field/Node.php +++ b/core/modules/node/src/Plugin/views/field/Node.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -44,7 +45,7 @@ protected function defineOptions() { /** * Provide link to node option */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['link_to_node'] = array( '#title' => t('Link this field to the original piece of content'), '#description' => t("Enable to override this field's links."), diff --git a/core/modules/node/src/Plugin/views/field/Path.php b/core/modules/node/src/Plugin/views/field/Path.php index a08b7cddacfc95b68d0f6782b142c3f166cca242..53b5010c1c809b4d120265524cecbac0a604ca10 100644 --- a/core/modules/node/src/Plugin/views/field/Path.php +++ b/core/modules/node/src/Plugin/views/field/Path.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ResultRow; @@ -37,7 +38,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['absolute'] = array( '#type' => 'checkbox', diff --git a/core/modules/node/src/Plugin/views/field/Revision.php b/core/modules/node/src/Plugin/views/field/Revision.php index db18760ffb7d5d0bb9e646c10f16a3380e734692..040c63f9fd51043ef028333873d8672c98ee1cea 100644 --- a/core/modules/node/src/Plugin/views/field/Revision.php +++ b/core/modules/node/src/Plugin/views/field/Revision.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -41,7 +42,7 @@ protected function defineOptions() { /** * Provide link to revision option. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['link_to_node_revision'] = array( '#title' => t('Link this field to its content revision'), '#description' => t('This will override any other link you have set.'), diff --git a/core/modules/node/src/Plugin/views/field/Type.php b/core/modules/node/src/Plugin/views/field/Type.php index 9e1be577b6875528b6985e34b5e381bca433601e..4824227e9885d53d8fad08363f0ef4fd59e55355 100644 --- a/core/modules/node/src/Plugin/views/field/Type.php +++ b/core/modules/node/src/Plugin/views/field/Type.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\node\Plugin\views\field\Node; use Drupal\views\ResultRow; @@ -29,7 +30,7 @@ protected function defineOptions() { /** * Provide machine_name option for to node type display. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['machine_name'] = array( diff --git a/core/modules/node/src/Plugin/views/filter/Access.php b/core/modules/node/src/Plugin/views/filter/Access.php index 524426fdc46f395850afdd1ed7faa8386f3cbf2b..8845ca8d2b3381d908f07b9aa7a343c8e14844f9 100644 --- a/core/modules/node/src/Plugin/views/filter/Access.php +++ b/core/modules/node/src/Plugin/views/filter/Access.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\filter\FilterPluginBase; /** @@ -19,7 +20,7 @@ class Access extends FilterPluginBase { public function adminSummary() { } - protected function operatorForm(&$form, &$form_state) { } + protected function operatorForm(&$form, FormStateInterface $form_state) { } public function canExpose() { return FALSE; } diff --git a/core/modules/node/src/Plugin/views/filter/Status.php b/core/modules/node/src/Plugin/views/filter/Status.php index 08e63d965c0770baa5c00f39a677efe3d72ec065..35c818e68e8a8fa3b8b443c96794f80fb4fdd48e 100644 --- a/core/modules/node/src/Plugin/views/filter/Status.php +++ b/core/modules/node/src/Plugin/views/filter/Status.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\filter\FilterPluginBase; /** @@ -20,7 +21,7 @@ class Status extends FilterPluginBase { public function adminSummary() { } - protected function operatorForm(&$form, &$form_state) { } + protected function operatorForm(&$form, FormStateInterface $form_state) { } public function canExpose() { return FALSE; } diff --git a/core/modules/node/src/Plugin/views/row/NodeRow.php b/core/modules/node/src/Plugin/views/row/NodeRow.php index de71343e2261c02ee992940224a62fd1abf9cc66..c79691fd39a975efece6be483c2ba23d7c11b26d 100644 --- a/core/modules/node/src/Plugin/views/row/NodeRow.php +++ b/core/modules/node/src/Plugin/views/row/NodeRow.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\row\EntityRow; /** @@ -38,7 +39,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['links'] = array( diff --git a/core/modules/node/src/Plugin/views/row/Rss.php b/core/modules/node/src/Plugin/views/row/Rss.php index 4a7b01d8a92c977b2a6350e7d4eb1a166a4aae6b..9d3db7b16c1c84afd75e2cf3d26671a5828c5d01 100644 --- a/core/modules/node/src/Plugin/views/row/Rss.php +++ b/core/modules/node/src/Plugin/views/row/Rss.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\row\RowPluginBase; /** @@ -44,7 +45,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['view_mode'] = array( diff --git a/core/modules/node/src/Plugin/views/wizard/Node.php b/core/modules/node/src/Plugin/views/wizard/Node.php index fc5aadbb9525b8f829ac567e0b0122a75cfc9bc7..377a6c673dc35327c77fe1b33a4d97677ed57962 100644 --- a/core/modules/node/src/Plugin/views/wizard/Node.php +++ b/core/modules/node/src/Plugin/views/wizard/Node.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\views\wizard; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\wizard\WizardPluginBase; /** @@ -86,12 +87,12 @@ protected function rowStyleOptions() { * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * @param string $type * The display ID (e.g. 'page' or 'block'). */ - protected function buildFormStyle(array &$form, array &$form_state, $type) { + protected function buildFormStyle(array &$form, FormStateInterface $form_state, $type) { parent::buildFormStyle($form, $form_state, $type); $style_form =& $form['displays'][$type]['options']['style']; // Some style plugins don't support row plugins so stop here if that's the @@ -156,7 +157,7 @@ protected function defaultDisplayOptions() { /** * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayFiltersUser(). */ - protected function defaultDisplayFiltersUser(array $form, array &$form_state) { + protected function defaultDisplayFiltersUser(array $form, FormStateInterface $form_state) { $filters = parent::defaultDisplayFiltersUser($form, $form_state); if (!empty($form_state['values']['show']['tagged_with']['tids'])) { @@ -183,7 +184,7 @@ protected function defaultDisplayFiltersUser(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function pageDisplayOptions(array $form, array &$form_state) { + protected function pageDisplayOptions(array $form, FormStateInterface $form_state) { $display_options = parent::pageDisplayOptions($form, $form_state); $row_plugin = isset($form_state['values']['page']['style']['row_plugin']) ? $form_state['values']['page']['style']['row_plugin'] : NULL; $row_options = isset($form_state['values']['page']['style']['row_options']) ? $form_state['values']['page']['style']['row_options'] : array(); @@ -194,7 +195,7 @@ protected function pageDisplayOptions(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function blockDisplayOptions(array $form, array &$form_state) { + protected function blockDisplayOptions(array $form, FormStateInterface $form_state) { $display_options = parent::blockDisplayOptions($form, $form_state); $row_plugin = isset($form_state['values']['block']['style']['row_plugin']) ? $form_state['values']['block']['style']['row_plugin'] : NULL; $row_options = isset($form_state['values']['block']['style']['row_options']) ? $form_state['values']['block']['style']['row_options'] : array(); @@ -233,7 +234,7 @@ protected function display_options_row(&$display_options, $row_plugin, $row_opt * * Add some options for filter by taxonomy terms. */ - protected function buildFilters(&$form, &$form_state) { + protected function buildFilters(&$form, FormStateInterface $form_state) { parent::buildFilters($form, $form_state); $selected_bundle = static::getSelected($form_state, array('show', 'type'), 'all', $form['displays']['show']['type']); diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php index ede945e2bec029c056abbb31696be3226a225827..43ef3cb9912f652589f875fad78f17488f3e5f26 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php @@ -8,6 +8,7 @@ namespace Drupal\options\Plugin\Field\FieldType; use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\OptGroup; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\AllowedValuesInterface; @@ -72,7 +73,7 @@ public function isEmpty() { /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { $allowed_values = $this->getSetting('allowed_values'); $allowed_values_function = $this->getSetting('allowed_values_function'); @@ -117,11 +118,11 @@ abstract protected function allowedValuesDescription(); * An associative array containing the properties and children of the * generic form element. * @param $form_state - * The $form_state array for the form this element belongs to. + * The current state of the form for the form this element belongs to. * * @see form_process_pattern() */ - public static function validateAllowedValues($element, &$form_state) { + public static function validateAllowedValues($element, FormStateInterface $form_state) { $values = static::extractAllowedValues($element['#value'], $element['#field_has_data']); if (!is_array($values)) { diff --git a/core/modules/options/src/Plugin/Field/FieldWidget/ButtonsWidget.php b/core/modules/options/src/Plugin/Field/FieldWidget/ButtonsWidget.php index fa56329baea0c7ba20024a5665b7f9d09d01e4b0..aed9a29489587c9b2fc3c6b3ca0d15426a18604a 100644 --- a/core/modules/options/src/Plugin/Field/FieldWidget/ButtonsWidget.php +++ b/core/modules/options/src/Plugin/Field/FieldWidget/ButtonsWidget.php @@ -8,6 +8,7 @@ namespace Drupal\options\Plugin\Field\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'options_buttons' widget. @@ -29,7 +30,7 @@ class ButtonsWidget extends OptionsWidgetBase { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element = parent::formElement($items, $delta, $element, $form, $form_state); $options = $this->getOptions($items[$delta]); diff --git a/core/modules/options/src/Plugin/Field/FieldWidget/OptionsWidgetBase.php b/core/modules/options/src/Plugin/Field/FieldWidget/OptionsWidgetBase.php index 01e7688f6249c34bef7b5b40c2ece7a6fa60451d..9f1e014bcc1ece1d6b1535610e2f7afeda60816d 100644 --- a/core/modules/options/src/Plugin/Field/FieldWidget/OptionsWidgetBase.php +++ b/core/modules/options/src/Plugin/Field/FieldWidget/OptionsWidgetBase.php @@ -11,6 +11,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; /** * Base class for the 'options_*' widgets. @@ -54,7 +55,7 @@ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInter /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { // Prepare some properties for the child methods to build the actual form // element. $this->required = $element['#required']; @@ -75,10 +76,10 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen * * @param array $element * The form element. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. */ - public static function validateElement(array $element, array &$form_state) { + public static function validateElement(array $element, FormStateInterface $form_state) { if ($element['#required'] && $element['#value'] == '_none') { \Drupal::formBuilder()->setError($element, $form_state, t('!name field is required.', array('!name' => $element['#title']))); } diff --git a/core/modules/options/src/Plugin/Field/FieldWidget/SelectWidget.php b/core/modules/options/src/Plugin/Field/FieldWidget/SelectWidget.php index 6d374405d5a1362995f6911088c673ae09b4e3c9..093e06c3c9b52cfa82d611a5571bcd52c885f281 100644 --- a/core/modules/options/src/Plugin/Field/FieldWidget/SelectWidget.php +++ b/core/modules/options/src/Plugin/Field/FieldWidget/SelectWidget.php @@ -8,6 +8,7 @@ namespace Drupal\options\Plugin\Field\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\options\Plugin\Field\FieldWidget\OptionsWidgetBase; /** @@ -29,7 +30,7 @@ class SelectWidget extends OptionsWidgetBase { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element = parent::formElement($items, $delta, $element, $form, $form_state); $element += array( diff --git a/core/modules/path/src/Form/DeleteForm.php b/core/modules/path/src/Form/DeleteForm.php index c669a1fac2d4bed7c7526e4cb496110c712dec4f..b253490719cb773821a2c8ed45c700df7b1f8dc9 100644 --- a/core/modules/path/src/Form/DeleteForm.php +++ b/core/modules/path/src/Form/DeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\path\Form; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Path\AliasStorageInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -72,9 +73,9 @@ public function getCancelUrl() { } /** - * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $pid = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) { $this->pathAlias = $this->aliasStorage->load(array('pid' => $pid)); $form = parent::buildForm($form, $form_state); @@ -83,9 +84,9 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->aliasStorage->delete(array('pid' => $this->pathAlias['pid'])); $form_state['redirect'] = 'admin/config/search/path'; diff --git a/core/modules/path/src/Form/EditForm.php b/core/modules/path/src/Form/EditForm.php index 0c1a7ab0e6328d71340bd72d537f5a10ebf49a75..b5fd90efe465047627e4c900572612e7a3a00721 100644 --- a/core/modules/path/src/Form/EditForm.php +++ b/core/modules/path/src/Form/EditForm.php @@ -8,6 +8,7 @@ namespace Drupal\path\Form; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -32,7 +33,7 @@ protected function buildPath($pid) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $pid = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) { $form = parent::buildForm($form, $form_state, $pid); $form['#title'] = String::checkPlain($this->path['alias']); @@ -51,7 +52,7 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) { /** * Submits the delete form. */ - public function deleteSubmit(array &$form, array &$form_state) { + public function deleteSubmit(array &$form, FormStateInterface $form_state) { $form_state['redirect_route'] = new Url('path.delete', array( 'pid' => $form_state['values']['pid'], )); diff --git a/core/modules/path/src/Form/PathFilterForm.php b/core/modules/path/src/Form/PathFilterForm.php index ce66c70a2a358917dfaef9771b0b88ee49f6e5ca..e8130f03b2df8684a5cb755c6d911f50a4f38f8b 100644 --- a/core/modules/path/src/Form/PathFilterForm.php +++ b/core/modules/path/src/Form/PathFilterForm.php @@ -8,6 +8,7 @@ namespace Drupal\path\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $keys = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $keys = NULL) { $form['#attributes'] = array('class' => array('search-form')); $form['basic'] = array( '#type' => 'details', @@ -59,7 +60,7 @@ public function buildForm(array $form, array &$form_state, $keys = NULL) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['redirect_route'] = new Url('path.admin_overview_filter', array( 'keys' => trim($form_state['values']['filter']), )); @@ -68,7 +69,7 @@ public function submitForm(array &$form, array &$form_state) { /** * Resets the filter selections. */ - public function resetForm(array &$form, array &$form_state) { + public function resetForm(array &$form, FormStateInterface $form_state) { $form_state['redirect_route'] = new Url('path.admin_overview'); } diff --git a/core/modules/path/src/Form/PathFormBase.php b/core/modules/path/src/Form/PathFormBase.php index a9e80c4938c65457d086c13fae981585028309c8..f4d7ffd21e813a0a695084fc31e32e53b56476fd 100644 --- a/core/modules/path/src/Form/PathFormBase.php +++ b/core/modules/path/src/Form/PathFormBase.php @@ -8,6 +8,7 @@ namespace Drupal\path\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Path\AliasManagerInterface; use Drupal\Core\Path\AliasStorageInterface; @@ -74,7 +75,7 @@ abstract protected function buildPath($pid); /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $pid = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) { $this->path = $this->buildPath($pid); $form['source'] = array( '#type' => 'textfield', @@ -135,7 +136,7 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $source = &$form_state['values']['source']; $source = $this->aliasManager->getPathByAlias($source); $alias = $form_state['values']['alias']; @@ -154,7 +155,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Remove unnecessary values. form_state_values_clean($form_state); diff --git a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php index d09002205677812e51c71da884d98d82d7abed2d..dc4d256e0fb655febfcb94af438cdf782c71fd64 100644 --- a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php +++ b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Symfony\Component\Validator\ConstraintViolationInterface; @@ -28,7 +29,7 @@ class PathWidget extends WidgetBase { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $entity = $items->getEntity(); $path = array(); if (!$entity->isNew()) { @@ -79,10 +80,10 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen * * @param array $element * The form element. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. */ - public static function validateFormElement(array &$element, array &$form_state) { + public static function validateFormElement(array &$element, FormStateInterface $form_state) { // Trim the submitted value. $alias = trim($element['alias']['#value']); if (!empty($alias)) { @@ -100,7 +101,7 @@ public static function validateFormElement(array &$element, array &$form_state) /** * {@inheritdoc} */ - public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, array &$form_state) { + public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) { return $element['alias']; } diff --git a/core/modules/quickedit/src/Form/QuickEditFieldForm.php b/core/modules/quickedit/src/Form/QuickEditFieldForm.php index 38b82a5454e0d1ec7d5b3387ed6e11996a36b539..6ce51d82653a1c9457b5068edf7141af064340b6 100644 --- a/core/modules/quickedit/src/Form/QuickEditFieldForm.php +++ b/core/modules/quickedit/src/Form/QuickEditFieldForm.php @@ -13,6 +13,7 @@ use Drupal\Core\Entity\EntityChangedInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\entity\Entity\EntityFormDisplay; use Drupal\user\TempStoreFactory; @@ -83,7 +84,7 @@ public function getFormId() { * * Builds a form for a single entity field. */ - public function buildForm(array $form, array &$form_state, EntityInterface $entity = NULL, $field_name = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity = NULL, $field_name = NULL) { if (!isset($form_state['entity'])) { $this->init($form_state, $entity, $field_name); } @@ -116,7 +117,7 @@ public function buildForm(array $form, array &$form_state, EntityInterface $enti /** * Initialize the form state and the entity before the first form build. */ - protected function init(array &$form_state, EntityInterface $entity, $field_name) { + protected function init(FormStateInterface $form_state, EntityInterface $entity, $field_name) { // @todo Rather than special-casing $node->revision, invoke prepareEdit() // once http://drupal.org/node/1863258 lands. if ($entity->getEntityTypeId() == 'node') { @@ -143,7 +144,7 @@ protected function init(array &$form_state, EntityInterface $entity, $field_name /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $entity = $this->buildEntity($form, $form_state); $form_state['form_display']->validateFormValues($entity, $form, $form_state); @@ -164,7 +165,7 @@ public function validateForm(array &$form, array &$form_state) { * * Saves the entity with updated values for the edited field. */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['entity'] = $this->buildEntity($form, $form_state); // Store entity in tempstore with its UUID as tempstore key. @@ -177,7 +178,7 @@ public function submitForm(array &$form, array &$form_state) { * Calling code may then validate the returned entity, and if valid, transfer * it back to the form state and save it. */ - protected function buildEntity(array $form, array &$form_state) { + protected function buildEntity(array $form, FormStateInterface $form_state) { /** @var $entity \Drupal\Core\Entity\EntityInterface */ $entity = clone $form_state['entity']; $field_name = $form_state['field_name']; @@ -203,10 +204,10 @@ protected function buildEntity(array $form, array &$form_state) { * * @param array &$form * A reference to 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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - protected function simplify(array &$form, array &$form_state) { + protected function simplify(array &$form, FormStateInterface $form_state) { $field_name = $form_state['field_name']; $widget_element =& $form[$field_name]['widget']; diff --git a/core/modules/quickedit/src/QuickEditController.php b/core/modules/quickedit/src/QuickEditController.php index 2c1c0938f54c8ba02c2d8d505328f0f96847190b..ad1751d323c842534b52905b452f2f2213a66b16 100644 --- a/core/modules/quickedit/src/QuickEditController.php +++ b/core/modules/quickedit/src/QuickEditController.php @@ -8,6 +8,7 @@ namespace Drupal\quickedit; use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\Form\FormState; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -177,13 +178,13 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view $this->tempStoreFactory->get('quickedit')->set($entity->uuid(), $entity); } - $form_state = array( + $form_state = new FormState(array( 'langcode' => $langcode, 'no_redirect' => TRUE, 'build_info' => array( 'args' => array($entity, $field_name), ), - ); + )); $form = $this->formBuilder()->buildForm('Drupal\quickedit\Form\QuickEditFieldForm', $form_state); if (!empty($form_state['executed'])) { diff --git a/core/modules/responsive_image/src/Form/ResponsiveImageMappingDeleteForm.php b/core/modules/responsive_image/src/Form/ResponsiveImageMappingDeleteForm.php index bd30ea300f095dccb4f2041c14dd7e7191b1e1d4..e614e0ee6a30a261ac70ce8b057017ad4c011bac 100644 --- a/core/modules/responsive_image/src/Form/ResponsiveImageMappingDeleteForm.php +++ b/core/modules/responsive_image/src/Form/ResponsiveImageMappingDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\responsive_image\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; class ResponsiveImageMappingDeleteForm extends EntityConfirmFormBase { @@ -36,7 +37,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php index ad4723f41bb720baa5db99badcbd6ed86f905e8b..24a80d4f33e46d6ec8465f68f671799b19e8fad1 100644 --- a/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php +++ b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\image\Plugin\Field\FieldFormatter\ImageFormatterBase; /** @@ -38,7 +39,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $responsive_image_options = array(); $responsive_image_mappings = entity_load_multiple('responsive_image_mapping'); if ($responsive_image_mappings && !empty($responsive_image_mappings)) { diff --git a/core/modules/responsive_image/src/ResponsiveImageMappingForm.php b/core/modules/responsive_image/src/ResponsiveImageMappingForm.php index 57779fdb6775b95651b54426020ac2b8c12eba0a..7a38d1231c19263ef00f1bb9c96eaac7c8a00d8e 100644 --- a/core/modules/responsive_image/src/ResponsiveImageMappingForm.php +++ b/core/modules/responsive_image/src/ResponsiveImageMappingForm.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\EntityForm; +use Drupal\Core\Form\FormStateInterface; /** * Form controller for the responsive image edit/add forms. @@ -20,15 +21,15 @@ class ResponsiveImageMappingForm extends EntityForm { * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param \Drupal\responsive_image\ResponsiveImageMappingInterface $responsive_image_mapping * The entity being edited. * * @return array * The array containing the complete form. */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { if ($this->operation == 'duplicate') { $form['#title'] = $this->t('Duplicate responsive image mapping @label', array('@label' => $this->entity->label())); $this->entity = $this->entity->createDuplicate(); @@ -96,7 +97,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { /** @var \Drupal\responsive_image\ResponsiveImageMappingInterface $responsive_image_mapping */ $responsive_image_mapping = $this->entity; @@ -119,7 +120,7 @@ public function validate(array $form, array &$form_state) { /** * Overrides Drupal\Core\Entity\EntityForm::save(). */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { /** @var \Drupal\responsive_image\ResponsiveImageMappingInterface $responsive_image_mapping */ $responsive_image_mapping = $this->entity; $responsive_image_mapping->save(); diff --git a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php index b3896a15551bbead3b482970114061ec1ca8bedb..68668bab88e4c08da03549bc6f5dc6408c9872c1 100644 --- a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php +++ b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php @@ -7,6 +7,7 @@ namespace Drupal\rest\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\row\RowPluginBase; @@ -74,7 +75,7 @@ protected function defineOptions() { /** * Overrides \Drupal\views\Plugin\views\row\RowPluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['field_options'] = array( @@ -111,7 +112,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Form element validation handler for \Drupal\rest\Plugin\views\row\DataFieldRow::buildOptionsForm(). */ - public function validateAliasName($element, &$form_state) { + public function validateAliasName($element, FormStateInterface $form_state) { if (preg_match('@[^A-Za-z0-9_-]+@', $element['#value'])) { form_error($element, $form_state, t('The machine-readable name must contain only letters, numbers, dashes and underscores.')); } @@ -120,7 +121,7 @@ public function validateAliasName($element, &$form_state) { /** * Overrides \Drupal\views\Plugin\views\row\RowPluginBase::validateOptionsForm(). */ - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { // Collect an array of aliases to validate. $aliases = static::extractFromOptionsArray('alias', $form_state['values']['row_options']['field_options']); diff --git a/core/modules/rest/src/Plugin/views/style/Serializer.php b/core/modules/rest/src/Plugin/views/style/Serializer.php index 1403dc3ada9295af55b3436f0f8ea95adc92664a..66529634c2cc3d9e9bf8318fdde8184003da2f5c 100644 --- a/core/modules/rest/src/Plugin/views/style/Serializer.php +++ b/core/modules/rest/src/Plugin/views/style/Serializer.php @@ -7,6 +7,7 @@ namespace Drupal\rest\Plugin\views\style; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\style\StylePluginBase; @@ -88,7 +89,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['formats'] = array( @@ -103,7 +104,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * {@inheritdoc} */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { parent::submitOptionsForm($form, $form_state); $form_state['values']['style_options']['formats'] = array_filter($form_state['values']['style_options']['formats']); diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 59646f959c9ae24f96d9271b36d9c2f98c4aa31e..be8da8aa3374cf028e2757a5fcdea0597fe02f34 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -8,6 +8,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; /** @@ -831,7 +832,7 @@ function search_module_preinstall() { * * @see \Drupal\search\Form\SearchBlockForm */ -function search_form_search_block_form_alter(&$form, &$form_state) { +function search_form_search_block_form_alter(&$form, FormStateInterface $form_state) { $form['form_build_id']['#access'] = FALSE; $form['form_token']['#access'] = FALSE; $form['form_id']['#access'] = FALSE; diff --git a/core/modules/search/src/Form/ReindexConfirm.php b/core/modules/search/src/Form/ReindexConfirm.php index e83e8c022414033b0ddb3bb5e0b7d077765968b2..06c457b7fa4cf15460d71b6437d32f66f6fd2663 100644 --- a/core/modules/search/src/Form/ReindexConfirm.php +++ b/core/modules/search/src/Form/ReindexConfirm.php @@ -8,6 +8,7 @@ namespace Drupal\search\Form; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -58,9 +59,9 @@ public function getCancelUrl() { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { if ($form['confirm']) { search_reindex(); drupal_set_message($this->t('The index will be rebuilt.')); diff --git a/core/modules/search/src/Form/SearchBlockForm.php b/core/modules/search/src/Form/SearchBlockForm.php index dafe3122f5baf045b372b86d690e65b7049ad2b9..e154863022e10b0edb53d73b3974c1aa63556096 100644 --- a/core/modules/search/src/Form/SearchBlockForm.php +++ b/core/modules/search/src/Form/SearchBlockForm.php @@ -8,6 +8,7 @@ namespace Drupal\search\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\search\SearchPageRepositoryInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -52,7 +53,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Set up the form to submit using GET to the correct search page. $entity_id = $this->searchPageRepository->getDefaultSearchPage(); if (!$entity_id) { @@ -90,7 +91,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // This form submits to the search page, so processing happens there. } } diff --git a/core/modules/search/src/Form/SearchPageAddForm.php b/core/modules/search/src/Form/SearchPageAddForm.php index c8f3f68b888ee27e884494942c68b38a450be6b4..0550f744fe7f0b034835e8f3c2f9e187632bc26a 100644 --- a/core/modules/search/src/Form/SearchPageAddForm.php +++ b/core/modules/search/src/Form/SearchPageAddForm.php @@ -7,6 +7,8 @@ namespace Drupal\search\Form; +use Drupal\Core\Form\FormStateInterface; + /** * Provides a form for adding a search page. */ @@ -15,7 +17,7 @@ class SearchPageAddForm extends SearchPageFormBase { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $search_plugin_id = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $search_plugin_id = NULL) { $this->entity->setPlugin($search_plugin_id); $definition = $this->entity->getPlugin()->getPluginDefinition(); $this->entity->set('label', $definition['title']); @@ -25,7 +27,7 @@ public function buildForm(array $form, array &$form_state, $search_plugin_id = N /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = $this->t('Add search page'); return $actions; @@ -34,7 +36,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { // If there is no default search page, make the added search the default. if (!$this->searchPageRepository->getDefaultSearchPage()) { $this->searchPageRepository->setDefaultSearchPage($this->entity); diff --git a/core/modules/search/src/Form/SearchPageDeleteForm.php b/core/modules/search/src/Form/SearchPageDeleteForm.php index 572764919ba0acceb59ea75ea5dacd75e5870f0e..a78d1c20db1cf08281e55e9bd785234026044e8f 100644 --- a/core/modules/search/src/Form/SearchPageDeleteForm.php +++ b/core/modules/search/src/Form/SearchPageDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\search\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -39,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); $form_state['redirect_route'] = $this->getCancelUrl(); drupal_set_message($this->t('The %label search page has been deleted.', array('%label' => $this->entity->label()))); diff --git a/core/modules/search/src/Form/SearchPageEditForm.php b/core/modules/search/src/Form/SearchPageEditForm.php index dc3de86146817cd2732de3eb78b8ccf7112c9b10..7ff92608e4e874b7176dc4d3afd2d82425233a53 100644 --- a/core/modules/search/src/Form/SearchPageEditForm.php +++ b/core/modules/search/src/Form/SearchPageEditForm.php @@ -7,6 +7,8 @@ namespace Drupal\search\Form; +use Drupal\Core\Form\FormStateInterface; + /** * Provides a form for editing a search page. */ @@ -15,7 +17,7 @@ class SearchPageEditForm extends SearchPageFormBase { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = $this->t('Save search page'); return $actions; @@ -24,7 +26,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { parent::save($form, $form_state); drupal_set_message($this->t('The %label search page has been updated.', array('%label' => $this->entity->label()))); diff --git a/core/modules/search/src/Form/SearchPageForm.php b/core/modules/search/src/Form/SearchPageForm.php index 1dac382c5467d8d41531bc1b6b9859c307be8e12..8e585db70aaa40671ce0f9110ce939a47959791e 100644 --- a/core/modules/search/src/Form/SearchPageForm.php +++ b/core/modules/search/src/Form/SearchPageForm.php @@ -8,6 +8,7 @@ namespace Drupal\search\Form; use Drupal\Core\Entity\EntityForm; +use Drupal\Core\Form\FormStateInterface; /** * Provides a search form for site wide search. @@ -37,7 +38,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $plugin = $this->entity->getPlugin(); $form_state['search_page_id'] = $this->entity->id(); @@ -74,7 +75,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { // The submit button is added in the form directly. return array(); } @@ -82,7 +83,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Redirect to the search page with keywords in the GET parameters. // Plugins with additional search parameters will need to provide their // own form submit handler to replace this, so they can put their values diff --git a/core/modules/search/src/Form/SearchPageFormBase.php b/core/modules/search/src/Form/SearchPageFormBase.php index 45e5cd4033b8ba8d32ec2e536b05d9bf31ffcaae..97cd2fc784e21d74be0d17120dc1b3d77915edf4 100644 --- a/core/modules/search/src/Form/SearchPageFormBase.php +++ b/core/modules/search/src/Form/SearchPageFormBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\search\SearchPageRepositoryInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -79,7 +80,7 @@ public function getBaseFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $this->plugin = $this->entity->getPlugin(); return parent::buildForm($form, $form_state); } @@ -87,7 +88,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form['label'] = array( '#type' => 'textfield', '#title' => $this->t('Label'), @@ -143,7 +144,7 @@ public function exists($id) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); // Ensure each path is unique. @@ -163,7 +164,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); if ($this->plugin instanceof PluginFormInterface) { @@ -175,7 +176,7 @@ public function submit(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $this->entity->save(); $form_state['redirect_route']['route_name'] = 'search.settings'; diff --git a/core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php b/core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php index 8dcc9a45da73a3a5cc2335b8bea6d39eeaece824..d5de0c4be9b402f3ca3b0ea0074573f3fa1dd1c3 100644 --- a/core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php +++ b/core/modules/search/src/Plugin/ConfigurableSearchPluginBase.php @@ -8,6 +8,7 @@ namespace Drupal\search\Plugin; use Drupal\Component\Utility\NestedArray; +use Drupal\Core\Form\FormStateInterface; /** * Provides a base implementation for a configurable Search plugin. @@ -54,7 +55,7 @@ public function setConfiguration(array $configuration) { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { } /** diff --git a/core/modules/search/src/Plugin/SearchInterface.php b/core/modules/search/src/Plugin/SearchInterface.php index 144c0ab5785dbb7aece137dcb5fd05c4879d626a..34c9d4f640810a30e429a29309f5f7203361646d 100644 --- a/core/modules/search/src/Plugin/SearchInterface.php +++ b/core/modules/search/src/Plugin/SearchInterface.php @@ -8,6 +8,7 @@ namespace Drupal\search\Plugin; use Drupal\Component\Plugin\PluginInspectionInterface; +use Drupal\Core\Form\FormStateInterface; /** * Defines a common interface for all SearchPlugin objects. @@ -91,14 +92,14 @@ public function buildResults(); * * @param array $form * Nested array of form elements that comprise the form. - * @param array $form_state - * A keyed array containing the current state of the form. The arguments - * that \Drupal::formBuilder()->getForm() was originally called with are + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. The arguments that + * \Drupal::formBuilder()->getForm() was originally called with are * available in the array $form_state['build_info']['args']. * * @see SearchInterface::buildSearchUrlQuery() */ - public function searchFormAlter(array &$form, array &$form_state); + public function searchFormAlter(array &$form, FormStateInterface $form_state); /** * Builds the URL GET query parameters array for search. @@ -108,7 +109,7 @@ public function searchFormAlter(array &$form, array &$form_state); * method to add form elements to the search form will need to override this * method to gather the form input and add it to the GET query parameters. * - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state, with submitted form information. * * @return array diff --git a/core/modules/search/src/Plugin/SearchPluginBase.php b/core/modules/search/src/Plugin/SearchPluginBase.php index e13a3077b3950d6d81ad2a37ae4eee388b6807e2..9a553ccee3022362edef17ef308df24d83d1d1c8 100644 --- a/core/modules/search/src/Plugin/SearchPluginBase.php +++ b/core/modules/search/src/Plugin/SearchPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\search\Plugin; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -104,7 +105,7 @@ public function buildResults() { /** * {@inheritdoc} */ - public function searchFormAlter(array &$form, array &$form_state) { + public function searchFormAlter(array &$form, FormStateInterface $form_state) { // Empty default implementation. } diff --git a/core/modules/search/src/Plugin/views/filter/Search.php b/core/modules/search/src/Plugin/views/filter/Search.php index ef69c7deb10dd81c0650eb94489b3a420ab13096..e885ce946188929c039f8c3b829aa646dd538250 100644 --- a/core/modules/search/src/Plugin/views/filter/Search.php +++ b/core/modules/search/src/Plugin/views/filter/Search.php @@ -7,6 +7,7 @@ namespace Drupal\search\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\filter\FilterPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; @@ -70,7 +71,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - protected function operatorForm(&$form, &$form_state) { + protected function operatorForm(&$form, FormStateInterface $form_state) { $form['operator'] = array( '#type' => 'radios', '#title' => t('On empty input'), @@ -85,7 +86,7 @@ protected function operatorForm(&$form, &$form_state) { /** * {@inheritdoc} */ - protected function valueForm(&$form, &$form_state) { + protected function valueForm(&$form, FormStateInterface $form_state) { $form['value'] = array( '#type' => 'textfield', '#size' => 15, @@ -98,7 +99,7 @@ protected function valueForm(&$form, &$form_state) { /** * {@inheritdoc} */ - public function validateExposed(&$form, &$form_state) { + public function validateExposed(&$form, FormStateInterface $form_state) { if (!isset($this->options['expose']['identifier'])) { return; } diff --git a/core/modules/search/src/Plugin/views/row/SearchRow.php b/core/modules/search/src/Plugin/views/row/SearchRow.php index 8c0709f71511c1c5d14ebfac0fccf3aae1b4531d..c93efdad94f3879d501081fcd0f86a29cbdf73b4 100644 --- a/core/modules/search/src/Plugin/views/row/SearchRow.php +++ b/core/modules/search/src/Plugin/views/row/SearchRow.php @@ -7,6 +7,7 @@ namespace Drupal\search\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\row\RowPluginBase; /** @@ -34,7 +35,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['score'] = array( '#type' => 'checkbox', '#title' => t('Display score'), diff --git a/core/modules/search/src/SearchPageListBuilder.php b/core/modules/search/src/SearchPageListBuilder.php index d6a837a580f9652586cce288c3056c876c93cd54..ac40476b39403fcd081b38855881cbbebf75c689 100644 --- a/core/modules/search/src/SearchPageListBuilder.php +++ b/core/modules/search/src/SearchPageListBuilder.php @@ -13,6 +13,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -152,7 +153,7 @@ public function buildRow(EntityInterface $entity) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $old_state = $this->configFactory->getOverrideState(); $search_settings = $this->configFactory->setOverrideState(FALSE)->get('search.settings'); @@ -318,13 +319,13 @@ public function getDefaultOperations(EntityInterface $entity) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $search_settings = $this->configFactory->get('search.settings'); @@ -348,7 +349,7 @@ public function submitForm(array &$form, array &$form_state) { * Form submission handler for the reindex button on the search admin settings * form. */ - public function searchAdminReindexSubmit(array &$form, array &$form_state) { + public function searchAdminReindexSubmit(array &$form, FormStateInterface $form_state) { // Send the user to the confirmation page. $form_state['redirect_route']['route_name'] = 'search.reindex_confirm'; } @@ -356,7 +357,7 @@ public function searchAdminReindexSubmit(array &$form, array &$form_state) { /** * Form validation handler for adding a new search page. */ - public function validateAddSearchPage(array &$form, array &$form_state) { + public function validateAddSearchPage(array &$form, FormStateInterface $form_state) { if (empty($form_state['values']['search_type'])) { $this->formBuilder()->setErrorByName('search_type', $form_state, $this->t('You must select the new search page type.')); } @@ -365,7 +366,7 @@ public function validateAddSearchPage(array &$form, array &$form_state) { /** * Form submission handler for adding a new search page. */ - public function submitAddSearchPage(array &$form, array &$form_state) { + public function submitAddSearchPage(array &$form, FormStateInterface $form_state) { $form_state['redirect_route'] = array( 'route_name' => 'search.add_type', 'route_parameters' => array( diff --git a/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php b/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php index d0d690d6b5a92e54929af77473ad2e7044ac9189..3bb04e04696291769bc24862f579be3db1ff9322 100644 --- a/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php +++ b/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php @@ -8,6 +8,7 @@ namespace Drupal\search_embedded_form\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form controller for search_embedded_form form. @@ -24,7 +25,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $count = \Drupal::state()->get('search_embedded_form.submit_count'); $form['name'] = array( @@ -48,7 +49,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $state = \Drupal::state(); $submit_count = (int) $state->get('search_embedded_form.submit_count'); $state->set('search_embedded_form.submit_count', $submit_count + 1); diff --git a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php index 32cfb776c436461635a386a7d0226af15693a5d0..2c3401030c8f7d3ba8593419f5d8551e3fdc7be7 100644 --- a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php +++ b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php @@ -8,6 +8,7 @@ namespace Drupal\search_extra_type\Plugin\Search; use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\Form\FormStateInterface; use Drupal\search\Plugin\ConfigurableSearchPluginBase; /** @@ -89,7 +90,7 @@ public function buildResults() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { // Output form for defining rank factor weights. $form['extra_type_settings'] = array( '#type' => 'fieldset', @@ -112,7 +113,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['boost'] = $form_state['values']['extra_type_settings']['boost']; } diff --git a/core/modules/shortcut/src/Form/SetCustomize.php b/core/modules/shortcut/src/Form/SetCustomize.php index a306f505a33fdb7abfdb07bd88ff493b9fb65410..d6afd909caae5d8b8e93c73c18aaadd3b73a1eb3 100644 --- a/core/modules/shortcut/src/Form/SetCustomize.php +++ b/core/modules/shortcut/src/Form/SetCustomize.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -27,7 +28,7 @@ class SetCustomize extends EntityForm { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $form['shortcuts'] = array( '#tree' => TRUE, @@ -82,7 +83,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { // Only includes a Save action for the entity, no direct Delete button. return array( 'submit' => array( @@ -99,7 +100,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { foreach ($this->entity->getShortcuts() as $shortcut) { $shortcut->setWeight($form_state['values']['shortcuts']['links'][$shortcut->id()]['weight']); $shortcut->save(); diff --git a/core/modules/shortcut/src/Form/ShortcutDeleteForm.php b/core/modules/shortcut/src/Form/ShortcutDeleteForm.php index bef1c00b729a65e2e058f9563a8400b524e6f993..0256017dd50e239d9e7d81f4740575e21671a48d 100644 --- a/core/modules/shortcut/src/Form/ShortcutDeleteForm.php +++ b/core/modules/shortcut/src/Form/ShortcutDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\shortcut\Form; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -48,7 +49,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); $form_state['redirect_route'] = $this->getCancelUrl(); drupal_set_message($this->t('The shortcut %title has been deleted.', array('%title' => $this->entity->title->value))); diff --git a/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php b/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php index 14f20f2271655d63c31da7d646f0f6303f65590c..f7e28ac1b4ed7f65b5335184f16d5ac45d1cf65b 100644 --- a/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php +++ b/core/modules/shortcut/src/Form/ShortcutSetDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\shortcut\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\shortcut\ShortcutSetStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -74,7 +75,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Find out how many users are directly assigned to this shortcut set, and // make a message. $number = $this->storage->countAssignedUsers($this->entity); @@ -101,7 +102,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); $form_state['redirect_route'] = new Url('shortcut.set_admin'); drupal_set_message(t('The shortcut set %title has been deleted.', array('%title' => $this->entity->label()))); diff --git a/core/modules/shortcut/src/Form/SwitchShortcutSet.php b/core/modules/shortcut/src/Form/SwitchShortcutSet.php index ec3180c8c7ee2b5561df74d30d94248745e977ed..a66a890573bb60b8c8db291f321d1ca10d6d593c 100644 --- a/core/modules/shortcut/src/Form/SwitchShortcutSet.php +++ b/core/modules/shortcut/src/Form/SwitchShortcutSet.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Access\AccessInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\shortcut\Entity\ShortcutSet; use Drupal\shortcut\ShortcutSetStorageInterface; @@ -75,7 +76,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, UserInterface $user = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, UserInterface $user = NULL) { $account = $this->currentUser(); $this->user = $user; @@ -169,7 +170,7 @@ public function exists($id) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { if ($form_state['values']['set'] == 'new') { // Check to prevent creating a shortcut set with an empty title. if (trim($form_state['values']['label']) == '') { @@ -185,7 +186,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $account = $this->currentUser(); $account_is_user = $this->user->id() == $account->id(); diff --git a/core/modules/shortcut/src/ShortcutForm.php b/core/modules/shortcut/src/ShortcutForm.php index 33c169a5f2e0ea4ff4fc50e4b1818a49d12716fd..e36fd793086492f104b1b443829154b041f43b61 100644 --- a/core/modules/shortcut/src/ShortcutForm.php +++ b/core/modules/shortcut/src/ShortcutForm.php @@ -8,6 +8,7 @@ namespace Drupal\shortcut; use Drupal\Core\Entity\ContentEntityForm; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; /** @@ -25,7 +26,7 @@ class ShortcutForm extends ContentEntityForm { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $form['path'] = array( @@ -50,7 +51,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function buildEntity(array $form, array &$form_state) { + public function buildEntity(array $form, FormStateInterface $form_state) { $entity = parent::buildEntity($form, $form_state); // Set the computed 'path' value so it can used in the preSave() method to @@ -63,7 +64,7 @@ public function buildEntity(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { if (!shortcut_valid_link($form_state['values']['path'])) { $this->setFormError('path', $form_state, $this->t('The shortcut must correspond to a valid path on the site.')); } @@ -74,7 +75,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $entity = $this->entity; $entity->save(); diff --git a/core/modules/shortcut/src/ShortcutSetForm.php b/core/modules/shortcut/src/ShortcutSetForm.php index 2b50ed2eee0f91257509c374584d5d708e8142eb..be485699b123cb9b5c5a31a747d2776c2bf94675 100644 --- a/core/modules/shortcut/src/ShortcutSetForm.php +++ b/core/modules/shortcut/src/ShortcutSetForm.php @@ -8,6 +8,7 @@ namespace Drupal\shortcut; use Drupal\Core\Entity\EntityForm; +use Drupal\Core\Form\FormStateInterface; /** * Form controller for the shortcut set entity edit forms. @@ -17,7 +18,7 @@ class ShortcutSetForm extends EntityForm { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $entity = $this->entity; @@ -50,7 +51,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); $entity = $this->entity; // Check to prevent a duplicate title. @@ -62,7 +63,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $entity = $this->entity; $is_new = !$entity->getOriginalId(); $entity->save(); diff --git a/core/modules/simpletest/src/Form/SimpletestResultsForm.php b/core/modules/simpletest/src/Form/SimpletestResultsForm.php index e2b49608ff1f90767aab6a82c8364f1b036d3936..f9e48d3603c38f673ca24270d7d319311ad0b2ca 100644 --- a/core/modules/simpletest/src/Form/SimpletestResultsForm.php +++ b/core/modules/simpletest/src/Form/SimpletestResultsForm.php @@ -10,6 +10,8 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Database\Connection; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormState; +use Drupal\Core\Form\FormStateInterface; use Drupal\simpletest\TestDiscovery; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -103,7 +105,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $test_id = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $test_id = NULL) { $this->buildStatusImageMap(); // Make sure there are test results to display and a re-run is not being // performed. @@ -249,7 +251,7 @@ public function buildForm(array $form, array &$form_state, $test_id = NULL) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $pass = $form_state['values']['filter_pass'] ? explode(',', $form_state['values']['filter_pass']) : array(); $fail = $form_state['values']['filter_fail'] ? explode(',', $form_state['values']['filter_fail']) : array(); @@ -269,7 +271,7 @@ public function submitForm(array &$form, array &$form_state) { } $form_execute = array(); - $form_state_execute = array('values' => array()); + $form_state_execute = new FormState(array('values' => array())); foreach ($classes as $class) { $form_state_execute['values']['tests'][$class] = $class; } diff --git a/core/modules/simpletest/src/Form/SimpletestSettingsForm.php b/core/modules/simpletest/src/Form/SimpletestSettingsForm.php index 563b05da0cb814d6c17915dd3ef6c8ebb5dc51a4..2b1e71d4135ca0629db2f5167e008b545c7409a7 100644 --- a/core/modules/simpletest/src/Form/SimpletestSettingsForm.php +++ b/core/modules/simpletest/src/Form/SimpletestSettingsForm.php @@ -8,6 +8,7 @@ namespace Drupal\simpletest\Form; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Configure simpletest settings for this site. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('simpletest.settings'); $form['general'] = array( '#type' => 'details', @@ -86,7 +87,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $config = $this->config('simpletest.settings'); // If a username was provided but a password wasn't, preserve the existing // password. @@ -106,7 +107,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('simpletest.settings') ->set('clear_results', $form_state['values']['simpletest_clear_results']) ->set('verbose', $form_state['values']['simpletest_verbose']) diff --git a/core/modules/simpletest/src/Form/SimpletestTestForm.php b/core/modules/simpletest/src/Form/SimpletestTestForm.php index ab9b55e5ecd47914f1ed9ebd10d19279b58d7eee..bb56b69124f77c7354ff65db9dd56ff9fca45f21 100644 --- a/core/modules/simpletest/src/Form/SimpletestTestForm.php +++ b/core/modules/simpletest/src/Form/SimpletestTestForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\SortArray; use Drupal\Component\Utility\String; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * List tests arranged in groups that can be selected and run. @@ -26,7 +27,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', @@ -183,7 +184,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Test discovery does not run upon form submission. simpletest_classloader_register(); diff --git a/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php b/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php index 3bdacacae32bf120522de3571881847574218231..62745b75683d0898704f3ff18e18267c09714a93 100644 --- a/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php +++ b/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php @@ -8,6 +8,7 @@ namespace Drupal\statistics\Plugin\Block; use Drupal\block\BlockBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; /** @@ -75,9 +76,9 @@ protected function blockAccess(AccountInterface $account) { } /** - * Overrides \Drupal\block\BlockBase::blockForm(). + * {@inheritdoc} */ - public function blockForm($form, &$form_state) { + public function blockForm($form, FormStateInterface $form_state) { // Popular content block settings. $numbers = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40); $numbers = array('0' => t('Disabled')) + array_combine($numbers, $numbers); @@ -106,9 +107,9 @@ public function blockForm($form, &$form_state) { } /** - * Overrides \Drupal\block\BlockBase::blockSubmit(). + * {@inheritdoc} */ - public function blockSubmit($form, &$form_state) { + public function blockSubmit($form, FormStateInterface $form_state) { $this->configuration['top_day_num'] = $form_state['values']['statistics_block_top_day_num']; $this->configuration['top_all_num'] = $form_state['values']['statistics_block_top_all_num']; $this->configuration['top_last_num'] = $form_state['values']['statistics_block_top_last_num']; diff --git a/core/modules/statistics/src/StatisticsSettingsForm.php b/core/modules/statistics/src/StatisticsSettingsForm.php index c0025908def0c30cc6885aa1256c537cf3a5c318..cac15a19135d62e8f88fe23d50e14e9fc1e1f14e 100644 --- a/core/modules/statistics/src/StatisticsSettingsForm.php +++ b/core/modules/statistics/src/StatisticsSettingsForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -55,9 +56,9 @@ public function getFormId() { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('statistics.settings'); // Content counter settings. @@ -77,9 +78,9 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('statistics.settings') ->set('count_content_views', $form_state['values']['statistics_count_content_views']) ->save(); diff --git a/core/modules/syslog/syslog.module b/core/modules/syslog/syslog.module index 4165fab68030d2fa3962e75d0887467553e01d5f..baee84f0053148ecb55fad912abb30f0dfd4b4d4 100644 --- a/core/modules/syslog/syslog.module +++ b/core/modules/syslog/syslog.module @@ -5,6 +5,7 @@ * Redirects logging messages to syslog. */ +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; /** @@ -30,7 +31,7 @@ function syslog_help($route_name, RouteMatchInterface $route_match) { /** * Implements hook_form_FORM_ID_alter(). */ -function syslog_form_system_logging_settings_alter(&$form, &$form_state) { +function syslog_form_system_logging_settings_alter(&$form, FormStateInterface $form_state) { $config = \Drupal::config('syslog.settings'); $help = \Drupal::moduleHandler()->moduleExists('help') ? ' ' . l(t('More information'), 'admin/help/syslog') . '.' : NULL; $form['syslog_identity'] = array( @@ -63,7 +64,7 @@ function syslog_form_system_logging_settings_alter(&$form, &$form_state) { * * @see syslog_form_system_logging_settings_alter() */ -function syslog_logging_settings_submit($form, &$form_state) { +function syslog_logging_settings_submit($form, FormStateInterface $form_state) { \Drupal::config('syslog.settings') ->set('identity', $form_state['values']['syslog_identity']) ->set('facility', $form_state['values']['syslog_facility']) diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php index 45b46917bfa2b9bf9c7fb44b757b1e7dc3c6b400..03a711c360b976ea581db2f01de8008be7909d0c 100644 --- a/core/modules/system/core.api.php +++ b/core/modules/system/core.api.php @@ -1267,7 +1267,7 @@ * return 'example_form'; * } * - * public function buildForm(array $form, array &$form_state) { + * public function buildForm(array $form, FormStateInterface $form_state) { * // Create a $form API array. * $form['phone_number'] = array( * '#type' => 'tel', @@ -1276,11 +1276,11 @@ * return $form; * } * - * public function validateForm(array &$form, array &$form_state) { + * public function validateForm(array &$form, FormStateInterface $form_state) { * // Validate submitted form data. * } * - * public function submitForm(array &$form, array &$form_state) { + * public function submitForm(array &$form, FormStateInterface $form_state) { * // Handle submitted form data. * } * } @@ -1305,7 +1305,7 @@ * $extra = '612-123-4567'; * $form = \Drupal::formBuilder()->getForm('Drupal\mymodule\Form\ExampleForm', $extra); * ... - * public function buildForm(array $form, array &$form_state, $extra = NULL) + * public function buildForm(array $form, FormStateInterface $form_state, $extra = NULL) * $form['phone_number'] = array( * '#type' => 'tel', * '#title' => $this->t('Your phone number'), diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index 34ca4403e990f4a4cac6571221c9be2c88d7228c..41d82171aa003035b88458f73a26b719386ca0d1 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -1539,15 +1539,15 @@ function hook_entity_display_build_alter(&$build, $context) { * The entity that is about to be shown on the form. * @param $operation * The current operation. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @see \Drupal\Core\Entity\EntityForm::prepareEntity() * @see hook_ENTITY_TYPE_prepare_form() * * @ingroup entity_crud */ -function hook_entity_prepare_form(\Drupal\Core\Entity\EntityInterface $entity, $operation, array &$form_state) { +function hook_entity_prepare_form(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Form\FormStateInterface $form_state) { if ($operation == 'edit') { $entity->label->value = 'Altered label'; $form_state['mymodule']['label_altered'] = TRUE; @@ -1565,15 +1565,15 @@ function hook_entity_prepare_form(\Drupal\Core\Entity\EntityInterface $entity, $ * The entity that is about to be shown on the form. * @param $operation * The current operation. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @see \Drupal\Core\Entity\EntityForm::prepareEntity() * @see hook_entity_prepare_form() * * @ingroup entity_crud */ -function hook_ENTITY_TYPE_prepare_form(\Drupal\Core\Entity\EntityInterface $entity, $operation, array &$form_state) { +function hook_ENTITY_TYPE_prepare_form(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Form\FormStateInterface $form_state) { if ($operation == 'edit') { $entity->label->value = 'Altered label'; $form_state['mymodule']['label_altered'] = TRUE; diff --git a/core/modules/system/src/Controller/FormAjaxController.php b/core/modules/system/src/Controller/FormAjaxController.php index bc43c4906355aee8ad1c82f7fbd30a9e9fa9c8dd..be4c98d155e0a009195bf0b85a6cb9db80562fc7 100644 --- a/core/modules/system/src/Controller/FormAjaxController.php +++ b/core/modules/system/src/Controller/FormAjaxController.php @@ -7,6 +7,7 @@ namespace Drupal\system\Controller; +use Drupal\Core\Form\FormState; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\HttpException; @@ -70,7 +71,7 @@ public function content(Request $request) { * @throws Symfony\Component\HttpKernel\Exception\HttpExceptionInterface */ protected function getForm(Request $request) { - $form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $form_state = new FormState(); $form_build_id = $request->request->get('form_build_id'); // Get the form from the cache. diff --git a/core/modules/system/src/Form/CronForm.php b/core/modules/system/src/Form/CronForm.php index b7e44230abfdaf2f15225c552962b38c072b411d..1ae69a1fa6dc29a2be2cb795a242c4ecf545c42a 100644 --- a/core/modules/system/src/Form/CronForm.php +++ b/core/modules/system/src/Form/CronForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\CronInterface; use Drupal\Core\Datetime\Date as DateFormatter; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Form\ConfigFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -82,7 +83,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('system.cron'); $form['description'] = array( @@ -123,7 +124,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('system.cron') ->set('threshold.autorun', $form_state['values']['cron_safe_threshold']) ->save(); @@ -134,7 +135,7 @@ public function submitForm(array &$form, array &$form_state) { /** * Runs cron and reloads the page. */ - public function submitCron(array &$form, array &$form_state) { + public function submitCron(array &$form, FormStateInterface $form_state) { // Run cron manually from Cron form. if ($this->cron->run()) { drupal_set_message(t('Cron run successfully.')); diff --git a/core/modules/system/src/Form/DateFormatAddForm.php b/core/modules/system/src/Form/DateFormatAddForm.php index b9289a22d932ffeca8366e3823ac6ecea2c967bd..22333e7b3c8d25ec27d09aad7253fa55e450e10b 100644 --- a/core/modules/system/src/Form/DateFormatAddForm.php +++ b/core/modules/system/src/Form/DateFormatAddForm.php @@ -7,6 +7,8 @@ namespace Drupal\system\Form; +use Drupal\Core\Form\FormStateInterface; + /** * Provides a form for adding a date format. */ @@ -15,7 +17,7 @@ class DateFormatAddForm extends DateFormatFormBase { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = t('Add format'); return $actions; @@ -24,7 +26,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); drupal_set_message(t('Custom date format added.')); } diff --git a/core/modules/system/src/Form/DateFormatDeleteForm.php b/core/modules/system/src/Form/DateFormatDeleteForm.php index 805bcce8e64fc98153b2f4c563445c1f59776124..7ba8f7d0ff3db1c72c70a74ba5f658130215212a 100644 --- a/core/modules/system/src/Form/DateFormatDeleteForm.php +++ b/core/modules/system/src/Form/DateFormatDeleteForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Datetime\Date as DateFormatter; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -70,7 +71,7 @@ public function getCancelUrl() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); drupal_set_message(t('Removed date format %format.', array('%format' => $this->entity->label()))); diff --git a/core/modules/system/src/Form/DateFormatEditForm.php b/core/modules/system/src/Form/DateFormatEditForm.php index c6a8eb0b7043b7fd2795de58900408e3e83f3c0e..84fda1cbc83654ffff015884b0ada02219399ac2 100644 --- a/core/modules/system/src/Form/DateFormatEditForm.php +++ b/core/modules/system/src/Form/DateFormatEditForm.php @@ -7,6 +7,8 @@ namespace Drupal\system\Form; +use Drupal\Core\Form\FormStateInterface; + /** * Provides a form for editing a date format. */ @@ -15,7 +17,7 @@ class DateFormatEditForm extends DateFormatFormBase { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $now = t('Displayed as %date', array('%date' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id()))); @@ -28,7 +30,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = t('Save format'); unset($actions['delete']); @@ -38,7 +40,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); drupal_set_message(t('Custom date format updated.')); } diff --git a/core/modules/system/src/Form/DateFormatFormBase.php b/core/modules/system/src/Form/DateFormatFormBase.php index 3370fc1ffe765a79c1e095eb883b5880db7ee7d0..edb26416701fdb8c35c813bada1a6189f3460102 100644 --- a/core/modules/system/src/Form/DateFormatFormBase.php +++ b/core/modules/system/src/Form/DateFormatFormBase.php @@ -11,6 +11,7 @@ use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\Config\Entity\ConfigEntityStorageInterface; use Drupal\Core\Datetime\Date as DateFormatter; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Datetime\DrupalDateTime; @@ -67,13 +68,11 @@ public static function create(ContainerInterface $container) { * The entity ID. * @param array $element * The form element. - * @param array $form_state - * The form state. * * @return bool * TRUE if this format already exists, FALSE otherwise. */ - public function exists($entity_id, array $element, array $form_state) { + public function exists($entity_id, array $element) { return (bool) $this->dateFormatStorage ->getQuery() ->condition('id', $element['#field_prefix'] . $entity_id) @@ -85,13 +84,13 @@ public function exists($entity_id, array $element, array $form_state) { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return \Drupal\Core\Ajax\AjaxResponse * An AJAX Response to update the date-time value of the date format. */ - public static function dateTimeLookup(array $form, array $form_state) { + public static function dateTimeLookup(array $form, FormStateInterface $form_state) { $format = ''; if (!empty($form_state['values']['date_format_pattern'])) { $format = t('Displayed as %date_format', array('%date_format' => \Drupal::service('date')->format(REQUEST_TIME, 'custom', $form_state['values']['date_format_pattern']))); @@ -107,7 +106,7 @@ public static function dateTimeLookup(array $form, array $form_state) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form['label'] = array( '#type' => 'textfield', '#title' => 'Name', @@ -156,7 +155,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); // The machine name field should already check to see if the requested @@ -174,7 +173,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $form_state['redirect_route']['route_name'] = 'system.date_format_list'; $form_state['values']['pattern'] = trim($form_state['values']['date_format_pattern']); diff --git a/core/modules/system/src/Form/FileSystemForm.php b/core/modules/system/src/Form/FileSystemForm.php index d7b1ad58be635a644a0fa54e6eb88e1bffbb6a2c..d2429e5acf738cb334030a6604987bfd6e67d8f0 100644 --- a/core/modules/system/src/Form/FileSystemForm.php +++ b/core/modules/system/src/Form/FileSystemForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Datetime\Date as DateFormatter; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StreamWrapper\PublicStream; use Drupal\Core\Form\ConfigFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -59,7 +60,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('system.file'); $form['file_public_path'] = array( '#type' => 'item', @@ -119,7 +120,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $config = $this->config('system.file') ->set('path.private', $form_state['values']['file_private_path']) ->set('path.temporary', $form_state['values']['file_temporary_path']) diff --git a/core/modules/system/src/Form/ImageToolkitForm.php b/core/modules/system/src/Form/ImageToolkitForm.php index be00cd88a50b64935eee60b9f9c27892f710ea7c..15378db645b8f55ec9da725e0585a0e1bd86fd63 100644 --- a/core/modules/system/src/Form/ImageToolkitForm.php +++ b/core/modules/system/src/Form/ImageToolkitForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\ImageToolkit\ImageToolkitManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -60,7 +61,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $current_toolkit = $this->config('system.image')->get('toolkit'); $form['image_toolkit'] = array( @@ -95,7 +96,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('system.image') ->set('toolkit', $form_state['values']['image_toolkit']) ->save(); diff --git a/core/modules/system/src/Form/LoggingForm.php b/core/modules/system/src/Form/LoggingForm.php index f52fc6aba052892ae456fb245142dea76fef37f4..ddb7e3ce35d077d300fe659ced53e0ce2f29864d 100644 --- a/core/modules/system/src/Form/LoggingForm.php +++ b/core/modules/system/src/Form/LoggingForm.php @@ -8,6 +8,7 @@ namespace Drupal\system\Form; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Configure logging settings for this site. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('system.logging'); $form['error_level'] = array( '#type' => 'radios', @@ -45,7 +46,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('system.logging') ->set('error_level', $form_state['values']['error_level']) ->save(); diff --git a/core/modules/system/src/Form/ModulesListConfirmForm.php b/core/modules/system/src/Form/ModulesListConfirmForm.php index fd671eedfa22da7727ae4d1e85b3b7d5c2eae7fc..412c4ba0c5c9f2d7eea118a286e58cb2b90fdc9f 100644 --- a/core/modules/system/src/Form/ModulesListConfirmForm.php +++ b/core/modules/system/src/Form/ModulesListConfirmForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -101,7 +102,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $account = $this->currentUser()->id(); $this->modules = $this->keyValueExpirable->get($account); @@ -131,7 +132,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Remove the key value store entry. $account = $this->currentUser()->id(); $this->keyValueExpirable->delete($account); diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php index 2c5dd06b6365f9d4c23ad1bdd3ca8c4db5b52e4b..b12c4d2dda53d43c765afd0aa21dec6148c79ac1 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -15,6 +15,7 @@ use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\Core\Menu\MenuLinkManagerInterface; use Drupal\Core\Render\Element; @@ -151,7 +152,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { require_once DRUPAL_ROOT . '/core/includes/install.inc'; $distribution = String::checkPlain(drupal_install_profile_distribution_name()); @@ -408,13 +409,13 @@ protected function buildRow(array $modules, Extension $module, $distribution) { /** * Helper function for building a list of modules to install. * - * @param array $form_state - * The form state array. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * * @return array * An array of modules to install and their dependencies. */ - protected function buildModuleList(array $form_state) { + protected function buildModuleList($form_state) { $packages = $form_state['values']['modules']; // Build a list of modules to install. @@ -472,7 +473,7 @@ protected function buildModuleList(array $form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Retrieve a list of modules to install and their dependencies. $modules = $this->buildModuleList($form_state); diff --git a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php index 1825d5322bdbe2946ff46b615d8b2e775c3fc65f..02c1dbe9ed6ce403fac0bbede587c854efa5eba3 100644 --- a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php +++ b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Config\ConfigManagerInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -125,7 +126,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Retrieve the list of modules from the key value store. $account = $this->currentUser()->id(); $this->modules = $this->keyValueExpirable->get($account); @@ -191,7 +192,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Clear the key value store entry. $account = $this->currentUser()->id(); $this->keyValueExpirable->delete($account); diff --git a/core/modules/system/src/Form/ModulesUninstallForm.php b/core/modules/system/src/Form/ModulesUninstallForm.php index 7438e48765d33add278cb4ef94db847e64d1d331..b1ec48c70794ebceefdef1154e3a7fbfd7dc1238 100644 --- a/core/modules/system/src/Form/ModulesUninstallForm.php +++ b/core/modules/system/src/Form/ModulesUninstallForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -64,7 +65,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Make sure the install API is available. include_once DRUPAL_ROOT . '/core/includes/install.inc'; @@ -148,7 +149,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // Form submitted, but no modules selected. if (!array_filter($form_state['values']['uninstall'])) { drupal_set_message($this->t('No modules selected.'), 'error'); @@ -159,7 +160,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Save all the values in an expirable key value store. $modules = $form_state['values']['uninstall']; $uninstall = array_keys(array_filter($modules)); diff --git a/core/modules/system/src/Form/PerformanceForm.php b/core/modules/system/src/Form/PerformanceForm.php index 2431e78a86eedecbe5375a920a0633ddf54471e8..d208cc3cf9b1cdc7027dd3ddb93a71c8d3e494cc 100644 --- a/core/modules/system/src/Form/PerformanceForm.php +++ b/core/modules/system/src/Form/PerformanceForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Datetime\Date as DateFormatter; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -69,7 +70,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['#attached']['library'][] = 'system/drupal.system'; $config = $this->config('system.performance'); @@ -155,7 +156,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_clear_css_cache(); drupal_clear_js_cache(); // This form allows page compression settings to be changed, which can @@ -177,7 +178,7 @@ public function submitForm(array &$form, array &$form_state) { /** * Clears the caches. */ - public function submitCacheClear(array &$form, array &$form_state) { + public function submitCacheClear(array &$form, FormStateInterface $form_state) { drupal_flush_all_caches(); drupal_set_message(t('Caches cleared.')); } diff --git a/core/modules/system/src/Form/RegionalForm.php b/core/modules/system/src/Form/RegionalForm.php index d3618597fd79e69fa5a68dcd636d304ac8e0a316..7ac2159b4d310b37844f5444ebf8b812585967ee 100644 --- a/core/modules/system/src/Form/RegionalForm.php +++ b/core/modules/system/src/Form/RegionalForm.php @@ -8,6 +8,7 @@ namespace Drupal\system\Form; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Locale\CountryManagerInterface; use Drupal\Core\Form\ConfigFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -57,7 +58,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $countries = $this->countryManager->getList(); $system_date = $this->config('system.date'); @@ -141,7 +142,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('system.date') ->set('country.default', $form_state['values']['site_default_country']) ->set('first_day', $form_state['values']['date_first_day']) diff --git a/core/modules/system/src/Form/RssFeedsForm.php b/core/modules/system/src/Form/RssFeedsForm.php index e487fceafe7b471bd4d8eec90ae25724d46e97e5..5ba8e6d588ff2688ccd0767f7bf511819d5d9ae3 100644 --- a/core/modules/system/src/Form/RssFeedsForm.php +++ b/core/modules/system/src/Form/RssFeedsForm.php @@ -8,6 +8,7 @@ namespace Drupal\system\Form; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Configure RSS settings for this site. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $rss_config = $this->config('system.rss'); $form['feed_description'] = array( '#type' => 'textarea', @@ -58,7 +59,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('system.rss') ->set('channel.description', $form_state['values']['feed_description']) ->set('items.limit', $form_state['values']['feed_default_items']) diff --git a/core/modules/system/src/Form/SiteInformationForm.php b/core/modules/system/src/Form/SiteInformationForm.php index c2b9c675ca770b000e9e3def543c1ad812e61e75..46b9013f2b399b9336cdb08772540b36a836d2c8 100644 --- a/core/modules/system/src/Form/SiteInformationForm.php +++ b/core/modules/system/src/Form/SiteInformationForm.php @@ -8,6 +8,7 @@ namespace Drupal\system\Form; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Path\AliasManagerInterface; use Drupal\Core\Form\ConfigFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -58,7 +59,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $site_config = $this->config('system.site'); $site_mail = $site_config->get('mail'); if (empty($site_mail)) { @@ -131,7 +132,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // Check for empty front page path. if (empty($form_state['values']['site_frontpage'])) { // Set to default "user". @@ -167,7 +168,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('system.site') ->set('name', $form_state['values']['site_name']) ->set('mail', $form_state['values']['site_mail']) diff --git a/core/modules/system/src/Form/SiteMaintenanceModeForm.php b/core/modules/system/src/Form/SiteMaintenanceModeForm.php index 7de4e6187f200a364992eaa2005a33cfe944730c..1ee0aa69a7f97888b9c2c3532271a1a1b6fc9bc2 100644 --- a/core/modules/system/src/Form/SiteMaintenanceModeForm.php +++ b/core/modules/system/src/Form/SiteMaintenanceModeForm.php @@ -8,6 +8,7 @@ namespace Drupal\system\Form; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Form\ConfigFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -56,7 +57,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('system.maintenance'); $form['maintenance_mode'] = array( '#type' => 'checkbox', @@ -76,7 +77,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('system.maintenance') ->set('message', $form_state['values']['maintenance_mode_message']) ->save(); diff --git a/core/modules/system/src/Form/ThemeAdminForm.php b/core/modules/system/src/Form/ThemeAdminForm.php index d83604716084970487f0b36514e4ddf8b2d811a6..627c2b33c5b35fd98f873f7c130109598718b86d 100644 --- a/core/modules/system/src/Form/ThemeAdminForm.php +++ b/core/modules/system/src/Form/ThemeAdminForm.php @@ -7,6 +7,7 @@ namespace Drupal\system\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form to select the administration theme. @@ -23,7 +24,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, array $theme_options = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, array $theme_options = NULL) { // Administration theme settings. $form['admin_theme'] = array( '#type' => 'details', @@ -48,7 +49,7 @@ public function buildForm(array $form, array &$form_state, array $theme_options /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The configuration options have been saved.')); $this->config('system.theme')->set('admin', $form_state['values']['admin_theme'])->save(); } diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php index 7752960b616a8144fa5d4cc5412f9fbd42459423..9d398d93bddc851ffdad8b5d7851c4bcb96287e0 100644 --- a/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -7,6 +7,7 @@ namespace Drupal\system\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\StreamWrapper\PublicStream; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -65,7 +66,7 @@ public function getFormId() { * @param string $theme * The theme name. */ - public function buildForm(array $form, array &$form_state, $theme = '') { + public function buildForm(array $form, FormStateInterface $form_state, $theme = '') { $form = parent::buildForm($form, $form_state); $themes = list_themes(); @@ -316,7 +317,7 @@ public function buildForm(array $form, array &$form_state, $theme = '') { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); if ($this->moduleHandler->moduleExists('file')) { @@ -373,7 +374,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $config = $this->config($form_state['values']['config_key']); diff --git a/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php b/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php index 13e1b7fe53492541708cc18eb8efc2dc377ae396..0cecf2b84c01a0d75e98ee54b01896e0ccd7d4b6 100644 --- a/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\block\BlockBase; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Session\AccountInterface; @@ -105,7 +106,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function blockForm($form, &$form_state) { + public function blockForm($form, FormStateInterface $form_state) { // Get the theme. $theme = $form_state['block_theme']; @@ -173,7 +174,7 @@ public function blockForm($form, &$form_state) { /** * {@inheritdoc} */ - public function blockSubmit($form, &$form_state) { + public function blockSubmit($form, FormStateInterface $form_state) { $this->configuration['use_site_logo'] = $form_state['values']['block_branding']['use_site_logo']; $this->configuration['use_site_name'] = $form_state['values']['block_branding']['use_site_name']; $this->configuration['use_site_slogan'] = $form_state['values']['block_branding']['use_site_slogan']; diff --git a/core/modules/system/src/Plugin/Block/SystemMainBlock.php b/core/modules/system/src/Plugin/Block/SystemMainBlock.php index 666b5157f0c103d37c88326d3ba20c8cf1300774..e251cad9cd049874c57725ad29582448689cdead 100644 --- a/core/modules/system/src/Plugin/Block/SystemMainBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemMainBlock.php @@ -8,6 +8,7 @@ namespace Drupal\system\Plugin\Block; use Drupal\block\BlockBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides a 'Main page content' block. @@ -31,7 +32,7 @@ public function build() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); // The main content block is never cacheable, because it may be dynamic. diff --git a/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php b/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php index 2b4ffaaab883faa7036feaa94f43b75753ba5617..980d5b3059b2006fca37b027da5d98c0c13ba4f2 100644 --- a/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php @@ -9,6 +9,7 @@ use Drupal\block\BlockBase; use Drupal\Core\Cache\Cache; +use Drupal\Core\Form\FormStateInterface; /** * Provides a 'Powered by Drupal' block. @@ -27,11 +28,10 @@ public function build() { return array('#markup' => '' . t('Powered by Drupal', array('@poweredby' => 'https://drupal.org')) . ''); } - /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); // The 'Powered by Drupal' block is permanently cacheable, because its diff --git a/core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php b/core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php index 874bcd6f345c0ca536854d6f514b81e60d85106c..1ccd1f9c0de88ad39eef65c5ab9af93f0fb6a051 100644 --- a/core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php +++ b/core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php @@ -9,6 +9,7 @@ use Drupal\Core\Condition\ConditionPluginBase; use Drupal\Core\Extension\ThemeHandlerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Theme\ThemeNegotiatorInterface; @@ -92,7 +93,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['theme'] = array( '#type' => 'select', '#title' => $this->t('Theme'), @@ -107,7 +108,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['theme'] = $form_state['values']['theme']; parent::submitConfigurationForm($form, $form_state); } diff --git a/core/modules/system/src/Plugin/Condition/RequestPath.php b/core/modules/system/src/Plugin/Condition/RequestPath.php index 1dab54ff47cf06f2aa439669464fd541536eb904..c6314d573b72487c1b460205f9368396b7fa17d0 100644 --- a/core/modules/system/src/Plugin/Condition/RequestPath.php +++ b/core/modules/system/src/Plugin/Condition/RequestPath.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Condition\ConditionPluginBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Path\AliasManagerInterface; use Drupal\Core\Path\PathMatcherInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; @@ -93,7 +94,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['pages'] = array( '#type' => 'textarea', '#title' => $this->t('Pages'), @@ -110,7 +111,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['pages'] = $form_state['values']['pages']; parent::submitConfigurationForm($form, $form_state); } diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php index c1a29a6150be49c84d7a194e8a50989312350afb..3cbdbd9e8ac247d2ec26ffc963732b6437b2c280 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php +++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php @@ -8,6 +8,7 @@ namespace Drupal\system\Plugin\ImageToolkit; use Drupal\Component\Utility\Unicode; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\ImageToolkit\ImageToolkitBase; /** @@ -76,7 +77,7 @@ public function settingsForm() { /** * {@inheritdoc} */ - public function settingsFormSubmit($form, &$form_state) { + public function settingsFormSubmit($form, FormStateInterface $form_state) { \Drupal::config('system.image.gd') ->set('jpeg_quality', $form_state['values']['gd']['image_jpeg_quality']) ->save(); diff --git a/core/modules/system/src/Plugin/views/field/BulkForm.php b/core/modules/system/src/Plugin/views/field/BulkForm.php index fc9898df65bc86aa8c44540d0a44910c3bb769e3..9cf68363e0d78e02b825ff84370230bcde070d6b 100644 --- a/core/modules/system/src/Plugin/views/field/BulkForm.php +++ b/core/modules/system/src/Plugin/views/field/BulkForm.php @@ -8,6 +8,7 @@ namespace Drupal\system\Plugin\views\field; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\style\Table; @@ -92,7 +93,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['action_title'] = array( '#type' => 'textfield', '#title' => t('Action title'), @@ -122,7 +123,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * {@inheritdoc} */ - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { parent::validateOptionsForm($form, $form_state); $form_state['values']['options']['selected_actions'] = array_filter($form_state['values']['options']['selected_actions']); @@ -157,10 +158,10 @@ public function preRender(&$values) { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function viewsForm(&$form, &$form_state) { + public function viewsForm(&$form, FormStateInterface $form_state) { // Add the tableselect javascript. $form['#attached']['library'][] = 'core/drupal.tableselect'; @@ -245,10 +246,10 @@ protected function getBulkOptions($filtered = TRUE) { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function viewsFormSubmit(&$form, &$form_state) { + public function viewsFormSubmit(&$form, FormStateInterface $form_state) { if ($form_state['step'] == 'views_form_views_form') { // Filter only selected checkboxes. $selected = array_filter($form_state['values'][$this->options['id']]); @@ -289,7 +290,7 @@ protected function emptySelectedMessage() { /** * {@inheritdoc} */ - public function viewsFormValidate(&$form, &$form_state) { + public function viewsFormValidate(&$form, FormStateInterface $form_state) { $selected = array_filter($form_state['values'][$this->options['id']]); if (empty($selected)) { form_set_error('', $form_state, $this->emptySelectedMessage()); diff --git a/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php b/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php index b0ce2f87a8780548278f119dad35e1de0ddecce0..0ca830a928b5a8b41bb0e771196a69fd07f502b7 100644 --- a/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php +++ b/core/modules/system/src/Tests/Form/ElementsTableSelectTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Form; +use Drupal\Core\Form\FormState; use Drupal\simpletest\WebTestBase; /** @@ -207,7 +208,7 @@ function testMultipleFalseOptionchecker() { */ private function formSubmitHelper($form, $edit) { $form_id = $this->randomName(); - $form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $form_state = new FormState(); $form['op'] = array('#type' => 'submit', '#value' => t('Submit')); // The form token CSRF protection should not interfere with this test, so we diff --git a/core/modules/system/src/Tests/Form/FormCacheTest.php b/core/modules/system/src/Tests/Form/FormCacheTest.php index b33c749f0f022a990b093e81b4cae1049d9e50c4..f8056bae6f2c81c0197663ca5ed5421a6a8ad4d7 100644 --- a/core/modules/system/src/Tests/Form/FormCacheTest.php +++ b/core/modules/system/src/Tests/Form/FormCacheTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Form; +use Drupal\Core\Form\FormState; use Drupal\Core\Session\UserSession; use Drupal\simpletest\DrupalUnitTestBase; @@ -32,7 +33,7 @@ public function setUp() { $this->form = array( '#property' => $this->randomName(), ); - $this->form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $this->form_state = new FormState(); $this->form_state['example'] = $this->randomName(); } @@ -43,7 +44,7 @@ function testCacheToken() { \Drupal::currentUser()->setAccount(new UserSession(array('uid' => 1))); form_set_cache($this->form_build_id, $this->form, $this->form_state); - $cached_form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $cached_form_state = new FormState(); $cached_form = form_get_cache($this->form_build_id, $cached_form_state); $this->assertEqual($this->form['#property'], $cached_form['#property']); $this->assertTrue(!empty($cached_form['#cache_token']), 'Form has a cache token'); @@ -53,14 +54,14 @@ function testCacheToken() { // Change the private key. (We cannot change the session ID because this // will break the parent site test runner batch.) \Drupal::state()->set('system.private_key', 'invalid'); - $cached_form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $cached_form_state = new FormState(); $cached_form = form_get_cache($this->form_build_id, $cached_form_state); $this->assertFalse($cached_form, 'No form returned from cache'); $this->assertTrue(empty($cached_form_state['example'])); // Test that loading the cache with a different form_id fails. $wrong_form_build_id = $this->randomName(9); - $cached_form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $cached_form_state = new FormState(); $this->assertFalse(form_get_cache($wrong_form_build_id, $cached_form_state), 'No form returned from cache'); $this->assertTrue(empty($cached_form_state['example']), 'Cached form state was not loaded'); } @@ -74,7 +75,7 @@ function testNoCacheToken() { $this->form_state['example'] = $this->randomName(); form_set_cache($this->form_build_id, $this->form, $this->form_state); - $cached_form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $cached_form_state = new FormState(); $cached_form = form_get_cache($this->form_build_id, $cached_form_state); $this->assertEqual($this->form['#property'], $cached_form['#property']); $this->assertTrue(empty($cached_form['#cache_token']), 'Form has no cache token'); diff --git a/core/modules/system/src/Tests/Form/FormDefaultHandlersTest.php b/core/modules/system/src/Tests/Form/FormDefaultHandlersTest.php index 9c980a6cc928b2f9cef780091e6d7ee7b89cc675..7fa6a7c2df963e460d0de625920ab09aeee64342 100644 --- a/core/modules/system/src/Tests/Form/FormDefaultHandlersTest.php +++ b/core/modules/system/src/Tests/Form/FormDefaultHandlersTest.php @@ -8,6 +8,8 @@ namespace Drupal\system\Tests\Form; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormState; +use Drupal\Core\Form\FormStateInterface; use Drupal\simpletest\KernelTestBase; /** @@ -34,7 +36,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['#validate'][] = array($this, 'customValidateForm'); $form['#submit'][] = array($this, 'customSubmitForm'); $form['submit'] = array('#type' => 'submit', '#value' => 'Save'); @@ -44,28 +46,28 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function customValidateForm(array &$form, array &$form_state) { + public function customValidateForm(array &$form, FormStateInterface $form_state) { $form_state['test_handlers']['validate'][] = __FUNCTION__; } /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $form_state['test_handlers']['validate'][] = __FUNCTION__; } /** * {@inheritdoc} */ - public function customSubmitForm(array &$form, array &$form_state) { + public function customSubmitForm(array &$form, FormStateInterface $form_state) { $form_state['test_handlers']['submit'][] = __FUNCTION__; } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['test_handlers']['submit'][] = __FUNCTION__; } @@ -73,7 +75,7 @@ public function submitForm(array &$form, array &$form_state) { * Tests that default handlers are added even if custom are specified. */ function testDefaultAndCustomHandlers() { - $form_state['values'] = array(); + $form_state = new FormState(array('values' => array())); $form_builder = $this->container->get('form_builder'); $form_builder->submitForm($this, $form_state); diff --git a/core/modules/system/src/Tests/Form/FormTest.php b/core/modules/system/src/Tests/Form/FormTest.php index 2b4850e6867fcc2379ca04e646c22c15f78f911a..12d78ea3db54bd9ed202086d3afb18708ca574df 100644 --- a/core/modules/system/src/Tests/Form/FormTest.php +++ b/core/modules/system/src/Tests/Form/FormTest.php @@ -9,6 +9,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormState; use Drupal\Core\Render\Element; use Drupal\form_test\Form\FormTestDisabledElementsForm; use Drupal\simpletest\WebTestBase; @@ -102,7 +103,7 @@ function testRequiredFields() { foreach (array(TRUE, FALSE) as $required) { $form_id = $this->randomName(); $form = array(); - $form_state = \Drupal::formBuilder()->getFormStateDefaults(); + $form_state = new FormState(); $form['op'] = array('#type' => 'submit', '#value' => t('Submit')); $element = $data['element']['#title']; $form[$element] = $data['element']; @@ -482,7 +483,7 @@ function testColorValidation() { */ function testDisabledElements() { // Get the raw form in its original state. - $form_state = array(); + $form_state = new FormState(); $form = (new FormTestDisabledElementsForm())->buildForm(array(), $form_state); // Build a submission that tries to hijack the form by submitting input for diff --git a/core/modules/system/src/Tests/Form/ProgrammaticTest.php b/core/modules/system/src/Tests/Form/ProgrammaticTest.php index a5c40718741df6debcbfff1532adfbadecf60eb4..2eba5ead24d473595f5963e59aade50c1e2ddeaf 100644 --- a/core/modules/system/src/Tests/Form/ProgrammaticTest.php +++ b/core/modules/system/src/Tests/Form/ProgrammaticTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Form; +use Drupal\Core\Form\FormState; use Drupal\simpletest\WebTestBase; /** @@ -71,7 +72,7 @@ function testSubmissionWorkflow() { */ private function submitForm($values, $valid_input) { // Programmatically submit the given values. - $form_state = array('values' => $values); + $form_state = new FormState(array('values' => $values)); \Drupal::formBuilder()->submitForm('\Drupal\form_test\Form\FormTestProgrammaticForm', $form_state); // Check that the form returns an error when expected, and vice versa. @@ -98,6 +99,7 @@ private function submitForm($values, $valid_input) { * Test the programmed_bypass_access_check flag. */ public function testProgrammaticAccessBypass() { + $form_state = new FormState(); $form_state['values'] = array( 'textfield' => 'dummy value', 'field_restricted' => 'dummy value' diff --git a/core/modules/system/src/Tests/Form/StubForm.php b/core/modules/system/src/Tests/Form/StubForm.php index 225371b565819740d1891c876d67cf2a0cd84f5d..c3898df5636b957c92098d84344d71308ab998a0 100644 --- a/core/modules/system/src/Tests/Form/StubForm.php +++ b/core/modules/system/src/Tests/Form/StubForm.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides a stub form for testing purposes. @@ -51,14 +52,14 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { return $this->form; } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/src/Tests/Form/TriggeringElementProgrammedUnitTest.php b/core/modules/system/src/Tests/Form/TriggeringElementProgrammedUnitTest.php index 3e6f41357362f5d217995b308f765877e7060b07..2d040de9aefc8753ed881b66d3ba27b9ddcf7be9 100644 --- a/core/modules/system/src/Tests/Form/TriggeringElementProgrammedUnitTest.php +++ b/core/modules/system/src/Tests/Form/TriggeringElementProgrammedUnitTest.php @@ -9,6 +9,8 @@ use Drupal\Component\Utility\String; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormState; +use Drupal\Core\Form\FormStateInterface; use Drupal\simpletest\DrupalUnitTestBase; /** @@ -30,7 +32,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['one'] = array( '#type' => 'textfield', '#title' => 'One', @@ -57,7 +59,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { // Verify that the only submit button was recognized as triggering_element. $this->assertEqual($form['actions']['submit']['#array_parents'], $form_state['triggering_element']['#array_parents']); } @@ -65,7 +67,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } /** @@ -73,6 +75,7 @@ public function submitForm(array &$form, array &$form_state) { */ function testLimitValidationErrors() { // Programmatically submit the form. + $form_state = new FormState(); $form_state['values'] = array(); $form_state['values']['section'] = 'one'; $form_builder = $this->container->get('form_builder'); diff --git a/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php b/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php index b923daf474a53a3b2babceac5d7a209431189a8e..cabd863159199e0cb3e100cb73f1546a2d8ec437 100644 --- a/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php +++ b/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\System; +use Drupal\Core\Form\FormState; use Drupal\simpletest\WebTestBase; /** @@ -47,11 +48,12 @@ abstract class SystemConfigFormTestBase extends WebTestBase { */ public function testConfigForm() { // Programmatically submit the given values. + $values = array(); foreach ($this->values as $form_key => $data) { $values[$form_key] = $data['#value']; } - $form_state = array('values' => $values); - drupal_form_submit($this->form, $form_state); + $form_state = new FormState(array('values' => $values)); + \Drupal::formBuilder()->submitForm($this->form, $form_state); // Check that the form returns an error when expected, and vice versa. $errors = form_get_errors($form_state); diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index d78942e945f684b104b89c7b16b238d28987da04..ee83508d45c695c3e150249193bcda41dfee0933 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -692,9 +692,9 @@ function hook_page_alter(&$page) { * @param $form * Nested array of form elements that comprise the form. * @param $form_state - * A keyed array containing the current state of the form. The arguments - * that \Drupal::formBuilder()->getForm() was originally called with are - * available in the array $form_state['build_info']['args']. + * The current state of the form. The arguments that + * \Drupal::formBuilder()->getForm() was originally called with are available + * in the array $form_state['build_info']['args']. * @param $form_id * String representing the name of the form itself. Typically this is the * name of the function that generated the form. @@ -703,7 +703,7 @@ function hook_page_alter(&$page) { * @see hook_form_FORM_ID_alter() * @see forms_api_reference.html */ -function hook_form_alter(&$form, &$form_state, $form_id) { +function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) { $upload_enabled_types = \Drupal::config('mymodule.settings')->get('upload_enabled_types'); $form['workflow']['upload_' . $form['type']['#value']] = array( @@ -731,9 +731,9 @@ function hook_form_alter(&$form, &$form_state, $form_id) { * @param $form * Nested array of form elements that comprise the form. * @param $form_state - * A keyed array containing the current state of the form. The arguments - * that \Drupal::formBuilder()->getForm() was originally called with are - * available in the array $form_state['build_info']['args']. + * The current state of the form. The arguments that + * \Drupal::formBuilder()->getForm() was originally called with are available + * in the array $form_state['build_info']['args']. * @param $form_id * String representing the name of the form itself. Typically this is the * name of the function that generated the form. @@ -743,7 +743,7 @@ function hook_form_alter(&$form, &$form_state, $form_id) { * @see \Drupal\Core\Form\FormBuilderInterface::prepareForm() * @see forms_api_reference.html */ -function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) { +function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { // Modification for the form with the given form ID goes here. For example, if // FORM_ID is "user_register_form" this code would run only on the user // registration form. @@ -779,7 +779,7 @@ function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) { * @param $form * Nested array of form elements that comprise the form. * @param $form_state - * A keyed array containing the current state of the form. + * The current state of the form. * @param $form_id * String representing the name of the form itself. Typically this is the * name of the function that generated the form. @@ -788,7 +788,7 @@ function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) { * @see hook_form_FORM_ID_alter() * @see \Drupal\Core\Form\FormBuilderInterface::prepareForm() */ -function hook_form_BASE_FORM_ID_alter(&$form, &$form_state, $form_id) { +function hook_form_BASE_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { // Modification for the form with the given BASE_FORM_ID goes here. For // example, if BASE_FORM_ID is "node_form", this code would run on every // node form, regardless of node type. diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 8bbb5e77eb59e77e18a0d30235a7eac53ed23b0d..f421e6bce48a63e20f55c7ee32b4cd6fff6eac3f 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -8,6 +8,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ExtensionDiscovery; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\StringTranslation\TranslationWrapper; use Drupal\Core\Language\LanguageInterface; @@ -991,7 +992,7 @@ function system_page_build(&$page) { /** * Implements hook_form_FORM_ID_alter(). */ -function system_form_user_form_alter(&$form, &$form_state) { +function system_form_user_form_alter(&$form, FormStateInterface $form_state) { if (\Drupal::config('system.date')->get('timezone.user.configurable')) { system_user_timezone($form, $form_state); } @@ -1000,7 +1001,7 @@ function system_form_user_form_alter(&$form, &$form_state) { /** * Implements hook_form_FORM_ID_alter(). */ -function system_form_user_register_form_alter(&$form, &$form_state) { +function system_form_user_register_form_alter(&$form, FormStateInterface $form_state) { $config = \Drupal::config('system.date'); if ($config->get('timezone.user.configurable') && $config->get('timezone.user.default') == DRUPAL_USER_TIMEZONE_SELECT) { system_user_timezone($form, $form_state); @@ -1031,7 +1032,7 @@ function system_user_login($account) { /** * Add the time zone field to the user edit and register forms. */ -function system_user_timezone(&$form, &$form_state) { +function system_user_timezone(&$form, FormStateInterface $form_state) { $user = \Drupal::currentUser(); $account = $form_state['controller']->getEntity(); diff --git a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module index 3a605c5a4bd039e2f73b974b9e6f0e363fda4fdd..8f8719a7152b2cc892fd6cd8c0355fc0b2cd6132 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module +++ b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module @@ -7,6 +7,7 @@ use Drupal\Core\Ajax; use Drupal\Core\Ajax\AjaxResponse; +use Drupal\Core\Form\FormStateInterface; /** * Ajax form callback: Selects 'after'. @@ -206,6 +207,6 @@ function ajax_forms_test_validation_number_form_callback($form, $form_state) { /** * AJAX form callback: Selects for the ajax_forms_test_lazy_load_form() form. */ -function ajax_forms_test_lazy_load_form_ajax($form, &$form_state) { +function ajax_forms_test_lazy_load_form_ajax($form, FormStateInterface $form_state) { return array('#markup' => 'new content'); } diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php index 474b6ea540fe332f82e8366a89bec0d17d8fcaf8..46525e72082e21aab577daedb03e616f92ff7056 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php +++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php @@ -8,6 +8,7 @@ namespace Drupal\ajax_forms_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form constructor for the Ajax Command display form. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc}. */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = array(); // Shows the 'after' command with a callback generating commands. @@ -216,7 +217,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc}. */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestLazyLoadForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestLazyLoadForm.php index d5761fe564196b1f65d9859bbdfbfbbcf8789a80..762c30606cd08c8b690d7ccdd4caf78e400c015c 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestLazyLoadForm.php +++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestLazyLoadForm.php @@ -8,6 +8,7 @@ namespace Drupal\ajax_forms_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form builder: Builds a form that triggers a simple AJAX callback. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // We attach a JavaScript setting, so that one of the generated AJAX // commands will be a settings command. We can then check the settings // command to ensure that the 'currentPath' setting is not part @@ -54,7 +55,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state['values']['add_files']) { $path = drupal_get_path('module', 'system'); $attached = array( diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestSimpleForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestSimpleForm.php index a2a4cf8562fd3ba2603185c75598417d1109457e..225664de7728390ac847d942f094283df91cd222 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestSimpleForm.php +++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestSimpleForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\FormBase; use Drupal\ajax_forms_test\Callbacks; +use Drupal\Core\Form\FormStateInterface; /** * Form builder: Builds a form that triggers a simple AJAX callback. @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $object = new Callbacks(); $form = array(); @@ -77,7 +78,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php index 35322794353cd327af1ca6efc002423384e81119..bf7064e78210ebac815f8e803865ebbf556a0867 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php +++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestValidationForm.php @@ -8,6 +8,7 @@ namespace Drupal\ajax_forms_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form builder: Builds a form that triggers a simple AJAX callback. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['drivertext'] = array( '#title' => $this->t('AJAX-enabled textfield.'), '#description' => $this->t("When this one AJAX-triggers and the spare required field is empty, you should not get an error."), @@ -68,7 +69,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t("Validation form submitted")); } diff --git a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php index 9d598d8adc358010014888b3fcbb8f01910c491a..5f118172014624c2390d83e51840ea6222060ff2 100644 --- a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php +++ b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php @@ -13,6 +13,7 @@ use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\OpenModalDialogCommand; use Drupal\Core\Ajax\OpenDialogCommand; +use Drupal\Core\Form\FormStateInterface; /** * Dummy form for testing DialogController with _form routes. @@ -29,7 +30,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // In order to use WebTestBase::drupalPostAjaxForm() to POST from a link, we need // to have a dummy field we can set in WebTestBase::drupalPostForm() else it won't // submit anything. @@ -59,14 +60,14 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['redirect'] = 'ajax-test/dialog-contents'; } @@ -74,14 +75,14 @@ public function submitForm(array &$form, array &$form_state) { /** * AJAX callback handler for AjaxTestDialogForm. */ - public function modal(&$form, &$form_state) { + public function modal(&$form, FormStateInterface $form_state) { return $this->dialog(TRUE); } /** * AJAX callback handler for AjaxTestDialogForm. */ - public function nonModal(&$form, &$form_state) { + public function nonModal(&$form, FormStateInterface $form_state) { return $this->dialog(FALSE); } diff --git a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php index 462f6710e9e7dc19921a98643c6c847409b03cae..423731628349137c01b8a19e07af270697fe9a35 100644 --- a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php +++ b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php @@ -8,6 +8,7 @@ namespace Drupal\ajax_test\Form; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormStateInterface; /** * Dummy form for testing DialogController with _form routes. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['#action'] = url('ajax-test/dialog'); @@ -43,11 +44,11 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) {} + public function submitForm(array &$form, FormStateInterface $form_state) {} /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) {} + public function validateForm(array &$form, FormStateInterface $form_state) {} } diff --git a/core/modules/system/tests/modules/batch_test/batch_test.module b/core/modules/system/tests/modules/batch_test/batch_test.module index 5438acfc54c677d09bfcbf9109846e552f767562..9290ef8b9de998af20b59ed8fe0820d90bd46e46 100644 --- a/core/modules/system/tests/modules/batch_test/batch_test.module +++ b/core/modules/system/tests/modules/batch_test/batch_test.module @@ -5,10 +5,13 @@ * Helper module for the Batch API tests. */ +use Drupal\Core\Form\FormState; + /** * Batch operation: Submits form_test_mock_form() using drupal_form_submit(). */ function _batch_test_nested_drupal_form_submit_callback($value) { + $state = new FormState(); $state['values']['test_value'] = $value; \Drupal::formBuilder()->submitForm('Drupal\batch_test\Form\BatchTestMockForm', $state); } diff --git a/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php b/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php index 9afb0e90b1b2e58c2383cdf794180854f44378a5..fcd9b010f53ac5abfc33193cb871131a5f17a841 100644 --- a/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php +++ b/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php @@ -6,6 +6,7 @@ namespace Drupal\batch_test\Controller; +use Drupal\Core\Form\FormState; /** * Controller routines for batch tests. @@ -84,9 +85,9 @@ public function testNoForm() { * Render array containing markup. */ function testProgrammatic($value = 1) { - $form_state = array( + $form_state = new FormState(array( 'values' => array('value' => $value) - ); + )); \Drupal::formBuilder()->submitForm('Drupal\batch_test\Form\BatchTestChainedForm', $form_state); return array( 'success' => array( diff --git a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestChainedForm.php b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestChainedForm.php index c6603deee9ee7a69aa5f7cbecd6139fb545dfb9c..ae6430ed0a74a02c5a292ac254075e2284d2f5e2 100644 --- a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestChainedForm.php +++ b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestChainedForm.php @@ -8,6 +8,7 @@ namespace Drupal\batch_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // This value is used to test that $form_state persists through batched // submit handlers. $form['value'] = array( @@ -49,13 +50,13 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } /** * Form submission handler #1 for batch_test_chained_form */ - public static function batchTestChainedFormSubmit1($form, &$form_state) { + public static function batchTestChainedFormSubmit1($form, FormStateInterface $form_state) { batch_test_stack(NULL, TRUE); batch_test_stack('submit handler 1'); @@ -70,7 +71,7 @@ public static function batchTestChainedFormSubmit1($form, &$form_state) { /** * Form submission handler #2 for batch_test_chained_form */ - public static function batchTestChainedFormSubmit2($form, &$form_state) { + public static function batchTestChainedFormSubmit2($form, FormStateInterface $form_state) { batch_test_stack('submit handler 2'); batch_test_stack('value = ' . $form_state['values']['value']); @@ -83,7 +84,7 @@ public static function batchTestChainedFormSubmit2($form, &$form_state) { /** * Form submission handler #3 for batch_test_chained_form */ - public static function batchTestChainedFormSubmit3($form, &$form_state) { + public static function batchTestChainedFormSubmit3($form, FormStateInterface $form_state) { batch_test_stack('submit handler 3'); batch_test_stack('value = ' . $form_state['values']['value']); @@ -95,7 +96,7 @@ public static function batchTestChainedFormSubmit3($form, &$form_state) { /** * Form submission handler #4 for batch_test_chained_form */ - public static function batchTestChainedFormSubmit4($form, &$form_state) { + public static function batchTestChainedFormSubmit4($form, FormStateInterface $form_state) { batch_test_stack('submit handler 4'); batch_test_stack('value = ' . $form_state['values']['value']); diff --git a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php index 6372c208a39623c50e1de9d1221212fb0a45fe17..f72fc29e500469268a39766bc6e767e69f30d3a8 100644 --- a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php +++ b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php @@ -8,6 +8,7 @@ namespace Drupal\batch_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Generate form of id batch_test_mock_form. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['test_value'] = array( '#title' => t('Test value'), '#type' => 'textfield', @@ -40,7 +41,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { batch_test_stack('mock form submitted with value = ' . $form_state['values']['test_value']); } diff --git a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMultiStepForm.php b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMultiStepForm.php index 4ce90a4ecc28c8e506a55df954c17a7285676004..3743cac67d2d0f5bba9d4be2161c83a718d8b280 100644 --- a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMultiStepForm.php +++ b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMultiStepForm.php @@ -8,6 +8,7 @@ namespace Drupal\batch_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { if (empty($form_state['storage']['step'])) { $form_state['storage']['step'] = 1; } @@ -44,7 +45,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { batch_test_stack(NULL, TRUE); switch ($form_state['storage']['step']) { diff --git a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php index 3c3933941770d1f0c27d21f5a737c6c64c6a4700..6bfa1c9752ec07bd5b3ea640f2e9b636511ff51e 100644 --- a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php +++ b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php @@ -8,6 +8,7 @@ namespace Drupal\batch_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['batch'] = array( '#type' => 'select', '#title' => 'Choose batch', @@ -48,7 +49,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { batch_test_stack(NULL, TRUE); $function = '_batch_test_' . $form_state['values']['batch']; diff --git a/core/modules/system/tests/modules/condition_test/src/FormController.php b/core/modules/system/tests/modules/condition_test/src/FormController.php index d713bb769034c75c31b6d9c9c61dc66b25b1853e..1f137555296266a14ac27d67f078503a783cc2b0 100644 --- a/core/modules/system/tests/modules/condition_test/src/FormController.php +++ b/core/modules/system/tests/modules/condition_test/src/FormController.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\FormInterface; use Drupal\Core\Condition\ConditionManager; +use Drupal\Core\Form\FormStateInterface; /** * Routing controller class for condition_test testing of condition forms. @@ -38,9 +39,9 @@ public function __construct() { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = $this->condition->buildConfigurationForm($form, $form_state); $form['actions']['submit'] = array( '#type' => 'submit', @@ -51,15 +52,16 @@ public function buildForm(array $form, array &$form_state) { /** * Implements \Drupal\Core\Form\FormInterface::validateForm(). + * */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $this->condition->validateConfigurationForm($form, $form_state); } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->condition->submitConfigurationForm($form, $form_state); $config = $this->condition->getConfig(); $bundles = implode(' and ', $config['bundles']); diff --git a/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php b/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php index 12e7311d3a42fac9ef7d0049246031512ed5863c..712ac979b83059125b58d7ae52d81abb6f25f9a8 100644 --- a/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php +++ b/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form controller for database_test module. @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $header = array( 'username' => array('data' => t('Username'), 'field' => 'u.name'), 'status' => array('data' => t('Status'), 'field' => 'u.status'), @@ -72,7 +73,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 864e302164db22e94f0c080947b452900973459f..6b293d1410e47f0bed8d39c7eea00b2ce1dc5f84 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\entity\Entity\EntityFormDisplay; @@ -242,7 +243,7 @@ function entity_test_permission() { /** * Implements hook_form_BASE_FORM_ID_alter(). */ -function entity_test_form_node_form_alter(&$form, &$form_state, $form_id) { +function entity_test_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) { $langcode = $form_state['controller']->getFormLangcode($form_state); \Drupal::state()->set('entity_test.form_langcode', $langcode); } diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestDeleteForm.php b/core/modules/system/tests/modules/entity_test/src/EntityTestDeleteForm.php index f9b0c4d94c6f5bab4feced343823b2334afb9fdf..76fea6960fd2e93b49ce5cc453378e70cb83026f 100644 --- a/core/modules/system/tests/modules/entity_test/src/EntityTestDeleteForm.php +++ b/core/modules/system/tests/modules/entity_test/src/EntityTestDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\entity_test; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -33,7 +34,7 @@ public function getQuestion() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); $entity = $this->entity; $entity->delete(); diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php b/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php index 2ca9d0da3203a013d7d23bcdb06c822b17ee23fa..ed56b501e779c58071771dc066062641129a2890 100644 --- a/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php +++ b/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php @@ -7,6 +7,7 @@ namespace Drupal\entity_test; use Drupal\Core\Entity\ContentEntityForm; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; /** @@ -15,9 +16,9 @@ class EntityTestForm extends ContentEntityForm { /** - * Overrides Drupal\Core\Entity\EntityForm::form(). + * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $entity = $this->entity; @@ -61,9 +62,9 @@ public function form(array $form, array &$form_state) { } /** - * Overrides \Drupal\Core\Entity\EntityForm::submit(). + * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { // Build the entity object from the submitted values. $entity = parent::submit($form, $form_state); @@ -76,9 +77,9 @@ public function submit(array $form, array &$form_state) { } /** - * Overrides Drupal\Core\Entity\EntityForm::save(). + * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $entity = $this->entity; $is_new = $entity->isNew(); $entity->save(); diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module index 08fdb2edd92481a3173aae8cda4c3c82848691ff..ad38397d93e5c5c77a5a5caae6243dc8801db75d 100644 --- a/core/modules/system/tests/modules/form_test/form_test.module +++ b/core/modules/system/tests/modules/form_test/form_test.module @@ -5,6 +5,8 @@ * Helper module for the form API tests. */ +use Drupal\Core\Form\FormStateInterface; + /** * Implements hook_permission(). */ @@ -23,14 +25,14 @@ function form_test_permission() { /** * Implements hook_form_FORM_ID_alter() on behalf of block.module. */ -function block_form_form_test_alter_form_alter(&$form, &$form_state) { +function block_form_form_test_alter_form_alter(&$form, FormStateInterface $form_state) { drupal_set_message('block_form_form_test_alter_form_alter() executed.'); } /** * Implements hook_form_alter(). */ -function form_test_form_alter(&$form, &$form_state, $form_id) { +function form_test_form_alter(&$form, FormStateInterface $form_state, $form_id) { if ($form_id == 'form_test_alter_form') { drupal_set_message('form_test_form_alter() executed.'); } @@ -39,14 +41,14 @@ function form_test_form_alter(&$form, &$form_state, $form_id) { /** * Implements hook_form_FORM_ID_alter(). */ -function form_test_form_form_test_alter_form_alter(&$form, &$form_state) { +function form_test_form_form_test_alter_form_alter(&$form, FormStateInterface $form_state) { drupal_set_message('form_test_form_form_test_alter_form_alter() executed.'); } /** * Implements hook_form_FORM_ID_alter() on behalf of system.module. */ -function system_form_form_test_alter_form_alter(&$form, &$form_state) { +function system_form_form_test_alter_form_alter(&$form, FormStateInterface $form_state) { drupal_set_message('system_form_form_test_alter_form_alter() executed.'); } @@ -93,7 +95,7 @@ function _form_test_tableselect_get_data() { * * @see form_test_state_persist() */ -function form_test_form_form_test_state_persist_alter(&$form, &$form_state) { +function form_test_form_form_test_state_persist_alter(&$form, FormStateInterface $form_state) { // Simulate a form alter implementation inserting form elements that enable // caching of the form, e.g. elements having #ajax. if (\Drupal::request()->get('cache')) { @@ -104,7 +106,7 @@ function form_test_form_form_test_state_persist_alter(&$form, &$form_state) { /** * Implements hook_form_FORM_ID_alter() for the registration form. */ -function form_test_form_user_register_form_alter(&$form, &$form_state) { +function form_test_form_user_register_form_alter(&$form, FormStateInterface $form_state) { $form['test_rebuild'] = array( '#type' => 'submit', '#value' => t('Rebuild'), @@ -115,7 +117,7 @@ function form_test_form_user_register_form_alter(&$form, &$form_state) { /** * Submit callback that just lets the form rebuild. */ -function form_test_user_register_form_rebuild($form, &$form_state) { +function form_test_user_register_form_rebuild($form, FormStateInterface $form_state) { drupal_set_message('Form rebuilt.'); $form_state['rebuild'] = TRUE; } diff --git a/core/modules/system/tests/modules/form_test/src/Callbacks.php b/core/modules/system/tests/modules/form_test/src/Callbacks.php index 08d970dc69a56ebf20f0fa61c53b5b189eace691..73fd437f09a244ca0071482697ae3e673154d858 100644 --- a/core/modules/system/tests/modules/form_test/src/Callbacks.php +++ b/core/modules/system/tests/modules/form_test/src/Callbacks.php @@ -7,6 +7,8 @@ namespace Drupal\form_test; +use Drupal\Core\Form\FormStateInterface; + /** * Simple class for testing methods as Form API callbacks. */ @@ -15,7 +17,7 @@ class Callbacks { /** * Form element validation handler for 'name' in form_test_validate_form(). */ - public function validateName(&$element, &$form_state) { + public function validateName(&$element, FormStateInterface $form_state) { $triggered = FALSE; if ($form_state['values']['name'] == 'element_validate') { // Alter the form element. diff --git a/core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php b/core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php index b1d69bc836b8a229b49009f32a03398875dcfd90..d650455e401cf92b6dfc783d502be7d3825f1ffa 100644 --- a/core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php +++ b/core/modules/system/tests/modules/form_test/src/ConfirmFormTestForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -60,7 +61,7 @@ public function getCancelText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['element'] = array('#markup' => '

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

'); return parent::buildForm($form, $form_state); @@ -69,7 +70,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The ConfirmFormTestForm::submitForm() method was used for this form.')); $form_state['redirect_route']['route_name'] = ''; } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestAlterForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestAlterForm.php index 3052d76cd6c973bedc3bcc7a3f88b2753fb63990..170e92b22654f5781a1d078d7f235cf9cf3960b5 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestAlterForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestAlterForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form builder for testing hook_form_alter() and hook_form_FORM_ID_alter(). @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Elements can be added as needed for future testing needs, but for now, // we're only testing alter hooks that do not require any elements added by // this function. @@ -34,7 +35,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestButtonClassForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestButtonClassForm.php index 11101209d1a352868b0feebbbc08b15ffb8f0d25..542a10419b48c800bea57b5b798375711ddec5d6 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestButtonClassForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestButtonClassForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a simple form to test form button classes. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['button'] = array( '#type' => 'button', '#value' => 'test', @@ -41,7 +42,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php index 1ca9a16a8f5fb8a6b3ea7951cde2e2ca4cddf518..6a23006ae16bfe87b64ed701c64b105d609786ab 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\JsonResponse; class FormTestCheckboxForm extends FormBase { @@ -22,7 +23,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // A required checkbox. $form['required_checkbox'] = array( '#type' => 'checkbox', @@ -90,7 +91,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['response'] = new JsonResponse($form_state['values']); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php index 64a2206d993cade1bc7f71a12a08de4c1ab87a06..335c1d7ef8b6a769be77535f1230f8d77753f183 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a form to test return values for checkboxes. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $default_value = NULL, $return_value = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $default_value = NULL, $return_value = NULL) { $form['checkbox'] = array( '#title' => t('Checkbox'), '#type' => 'checkbox', @@ -37,7 +38,7 @@ public function buildForm(array $form, array &$form_state, $default_value = NULL /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesRadiosForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesRadiosForm.php index 4b84cf11198ceb20a0b695d86905d69ad9c32e5f..721399e1585258d225da236239daef84bcaa1562 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesRadiosForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesRadiosForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\JsonResponse; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $customize = FALSE) { + public function buildForm(array $form, FormStateInterface $form_state, $customize = FALSE) { // Expand #type checkboxes, setting custom element properties for some but not // all options. $form['checkboxes'] = array( @@ -82,7 +83,7 @@ public function buildForm(array $form, array &$form_state, $customize = FALSE) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['response'] = new JsonResponse($form_state['values']); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php index 08356ad3cd5e1b4864377ff9b9baf94ceaafaace..709a76d371de95e0c300c480a4087f161a775325 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\JsonResponse; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $json = TRUE) { + public function buildForm(array $form, FormStateInterface $form_state, $json = TRUE) { $form_state['json'] = $json; $form['checkbox_off'] = array( '#title' => t('Checkbox off'), @@ -54,7 +55,7 @@ public function buildForm(array $form, array &$form_state, $json = TRUE) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { if (!empty($form_state['json'])) { $form_state['response'] = new JsonResponse($form_state['values']); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php index c8464c1e8e22cf129c29da9d657a1f7f27eedf2b..b0c4957194ef2344f5fb22ab958d651ebfe259f4 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form builder to test button click detection. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $first = NULL, $second = NULL, $third = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $first = NULL, $second = NULL, $third = NULL) { // A single text field. In IE, when a form has only one non-button input field // and the ENTER key is pressed while that field has focus, the form is // submitted without any information identifying the button responsible for @@ -83,7 +84,7 @@ public function buildForm(array $form, array &$form_state, $first = NULL, $secon /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { if (isset($form_state['triggering_element'])) { drupal_set_message(t('The clicked button is %name.', array('%name' => $form_state['triggering_element']['#name']))); } @@ -95,7 +96,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message('Submit handler for form_test_clicked_button executed.'); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestColorForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestColorForm.php index 085602674635ef931ba2c789faae05ffe49cc25c..3603631fbfdce63001ca6e8cbfdd5c48ba0d2d87 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestColorForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestColorForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\JsonResponse; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['color'] = array( '#type' => 'color', '#title' => 'Color', @@ -40,7 +41,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['response'] = new JsonResponse($form_state['values']); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php index 9f4e16822747e9ebecc478c687078082273a9555..3555ab674163227fdcbbde54868b8686762e4d8b 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\JsonResponse; /** @@ -26,7 +27,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Elements that take a simple default value. foreach (array('textfield', 'textarea', 'search', 'tel', 'hidden') as $type) { $form[$type] = array( @@ -223,7 +224,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['response'] = new JsonResponse($form_state['values']); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestEmailForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestEmailForm.php index f46ec64271204568d5ec1d05f74a1a04542423ed..11bad32ba958172ba56d02917a4a275f7470f2ca 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestEmailForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestEmailForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\JsonResponse; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['email'] = array( '#type' => 'email', '#title' => 'Email address', @@ -47,7 +48,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['response'] = new JsonResponse($form_state['values']); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php index 143437031b0d5b873f74dbceb77b842c24506b69..76e05ad9d9c45eb109af2f3ac065078ace34d4ca 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a form to test select elements when #options is not an array. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['empty_select'] = array( '#type' => 'select', '#title' => t('Empty Select'), @@ -37,7 +38,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateDatabaseForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateDatabaseForm.php index f570e2ba9fa44404ff1348fd5cb2e8578dcc925a..a0dda13312d28e729a8617de873d608894ea68cb 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateDatabaseForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateDatabaseForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a form which gets the database connection stored in the form state. @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['text'] = array( '#type' => 'textfield', '#title' => t('Text field'), @@ -50,7 +51,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['cache'] = TRUE; $form_state['rebuild'] = TRUE; diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php index 879d7b35c1f03935c93db267176ba5f1e87add86..79d44d726492ceba7abc48f8b9d89fee056da260 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form builder for form_state_values_clean() test. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Build an example form containing a managed file and a submit form element. $form['image'] = array( '#type' => 'managed_file', @@ -42,7 +43,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { form_state_values_clean($form_state); print t('You WIN!'); exit; diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php index 5c258d4d1661839dcbdbf33a76d170688e7d813d..c8b39e3985c3d6617f4d32cea8492fe720914a3e 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php @@ -9,6 +9,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form builder for form_state_values_clean() test. @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Build an example form containing multiple submit and button elements; not // only on the top-level. $form = array('#tree' => TRUE); @@ -41,7 +42,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { form_state_values_clean($form_state); // This won't have a proper JSON header, but Drupal doesn't check for that // anyway so this is fine until it's replaced with a JsonResponse. diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupContainerForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupContainerForm.php index 72c672e5ab1b28a86f2fc397990831d6fabd4ef8..26a04c49922f88be5de8c295e2fbba377b1a87ce 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupContainerForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupContainerForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a simple form to test the #group property on #type 'container'. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['container'] = array( '#type' => 'container', ); @@ -44,7 +45,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupDetailsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupDetailsForm.php index fe94c13e5b1c11be8dd620aeb29ac933c8bde849..d8f5925db67329f3f96a745ca6a177e96a6303f1 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupDetailsForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupDetailsForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a simple form to test the #group property on #type 'details'. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['details'] = array( '#type' => 'details', '#title' => 'Root element', @@ -46,7 +47,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php index 5d4a7a81c60b7f8f91dc8f2465b0bca5a2754acb..e55b1af2437ce9cf3aa9274c7e75786aaa2e002b 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupFieldsetForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a simple form to test the #group property on #type 'fieldset'. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['fieldset'] = array( '#type' => 'fieldset', '#title' => 'Fieldset', @@ -44,7 +45,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupVerticalTabsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupVerticalTabsForm.php index b92e22df82f4a7d02b77b07a202f671b476cde05..c4a11afb5222325fa4ab9513fdc9a7739718fb82 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupVerticalTabsForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestGroupVerticalTabsForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a simple form to test the #group property on #type 'vertical_tabs'. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['vertical_tabs'] = array( '#type' => 'vertical_tabs', ); @@ -52,7 +53,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php index d4f2493b4b9fac79e5f557e23dcb2852c919a1cb..e3a31e9777dcfe86e8354657763d89b7531e9c4b 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\JsonResponse; class FormTestInputForgeryForm extends FormBase { @@ -22,7 +23,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // For testing that a user can't submit a value not matching one of the // allowed options. $form['checkboxes'] = array( @@ -44,7 +45,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { return new JsonResponse($form_state['values']); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php index 2e24091acaf15714032b1f01ba5d8574df54ec3e..75234b0e37d47c11ff839ba0c892b5fde13deaf1 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * A form for testing form labels and required marks. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['form_checkboxes_test'] = array( '#type' => 'checkboxes', '#title' => t('Checkboxes test'), @@ -114,7 +115,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php index 711b369fd0d1a453250f0369bc376f527839d28d..71d8311c85f66085a88403ca69a593a56607e176 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Symfony\Component\HttpFoundation\JsonResponse; @@ -26,7 +27,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['languages_all'] = array( '#title' => t('Languages: All'), '#type' => 'language_select', @@ -65,7 +66,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['response'] = new JsonResponse($form_state['values']); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php index 6fdbb2502eb66da8272795d5882d642bdb6cbcbe..b8f4c524c23b2b5dd583ab558f3502c2140abf73 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a simple form with a button triggering partial validation. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['title'] = array( '#type' => 'textfield', '#title' => 'Title', @@ -87,7 +88,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function elementValidateLimitValidationErrors($element, &$form_state) { + public function elementValidateLimitValidationErrors($element, FormStateInterface $form_state) { if ($element['#value'] == 'invalid') { form_error($element, $form_state, t('@label element is invalid', array('@label' => $element['#title']))); } @@ -96,13 +97,13 @@ public function elementValidateLimitValidationErrors($element, &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ - public function partialSubmitForm(array &$form, array &$form_state) { + public function partialSubmitForm(array &$form, FormStateInterface $form_state) { // The title has not been validated, thus its value - in case of the test case // an empty string - may not be set. if (!isset($form_state['values']['title']) && isset($form_state['values']['test'])) { diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestNumberForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestNumberForm.php index 7c313fc336d4499bef88095c3844f91875e7855f..e48f4058d0e19ac844cb011821faa500ce858c0f 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestNumberForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestNumberForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a form to test #type 'number' and 'range' validation. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $element = 'number') { + public function buildForm(array $form, FormStateInterface $form_state, $element = 'number') { $base = array( '#type' => $element, ); @@ -139,7 +140,7 @@ public function buildForm(array $form, array &$form_state, $element = 'number') /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php index 7df5f7a8ae04bd756d9fbe74ab685697bc28e6df..8a022b487ffa70493db8600e94914588e247885f 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestPatternForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a simple form using the FAPI #pattern proterty. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['textfield'] = array( '#type' => 'textfield', '#title' => 'One digit followed by lowercase letters', @@ -59,7 +60,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestPlaceholderForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestPlaceholderForm.php index f11d9d44a51c8c6fbc6f51e6beaec698e1bfb9d7..fc6c4dc0da6c7a6a530920fa93c208dc2326ba6e 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestPlaceholderForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestPlaceholderForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a form to test the placeholder attribute. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { foreach (array('textfield', 'textarea', 'url', 'password', 'search', 'tel', 'email', 'number') as $type) { $form[$type] = array( '#type' => $type, @@ -39,7 +40,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php index a44b8c4617c7b6dd621e3d7ef38ef4d1f4aa583d..68b4368feba25f7ff955b23146fbdda9966068ea 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form builder to test programmatic form submissions. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['textfield'] = array( '#title' => 'Textfield', '#type' => 'textfield', @@ -87,7 +88,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { if (empty($form_state['values']['textfield'])) { form_set_error('textfield', $form_state, t('Textfield is required.')); } @@ -96,7 +97,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['storage']['programmatic_form_submit'] = $form_state['values']; } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeForm.php index fff51261f7855cfc4b60060aa563f236bf47db4c..34f1e52b10c56054282460703eb76e598451d97c 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\JsonResponse; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['with_default_value'] = array( '#type' => 'range', '#title' => 'Range with default value', @@ -68,7 +69,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['response'] = new JsonResponse($form_state['values']); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeInvalidForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeInvalidForm.php index 7b685a76296828666f9044b393dd8e09605efffd..92b236581d741e467acac17c0ef369c44904653a 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeInvalidForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRangeInvalidForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form constructor for testing invalid #type 'range' elements. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['minmax'] = array( '#type' => 'range', '#min' => 10, @@ -42,7 +43,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php index e1ecceddb029df0edddac4157b204c996cacc34f..2e6ed8bd245eb1fd53e9f5e00032416962ae820c 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form builder for testing preservation of values during a rebuild. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Start the form with two checkboxes, to test different defaults, and a // textfield, to test more than one element type. $form = array( @@ -85,7 +86,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function addMoreSubmitForm(array &$form, array &$form_state) { + public function addMoreSubmitForm(array &$form, FormStateInterface $form_state) { // Rebuild, to test preservation of input values. $form_state['storage']['add_more'] = TRUE; $form_state['rebuild'] = TRUE; @@ -94,7 +95,7 @@ public function addMoreSubmitForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Finish the workflow. Do not rebuild. drupal_set_message(t('Form values: %values', array('%values' => var_export($form_state['values'], TRUE)))); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php index 98219d97337f0fb6c6b22eede0ecb1cc3a618140..0adc985f5d0291740d9a694c94e30765463eb60e 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form builder to detect form redirect. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['redirection'] = array( '#type' => 'checkbox', '#title' => t('Use redirection'), @@ -49,7 +50,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { if (!empty($form_state['values']['redirection'])) { $form_state['redirect'] = !empty($form_state['values']['destination']) ? $form_state['values']['destination'] : NULL; } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRequiredAttributeForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRequiredAttributeForm.php index 380d1c9502866d6b25f615059096837f5eace940..5f7d5d0319afd2f8c963b03aa59e7720d1bc5cc3 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRequiredAttributeForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRequiredAttributeForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Builds a form to test the required attribute. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { foreach (array('textfield', 'textarea', 'password') as $type) { $form[$type] = array( '#type' => $type, @@ -39,7 +40,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestSelectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestSelectForm.php index 5227ae4bbdeb0372d2b9759ac37cef69460c15b0..eba498b3905285cfbfc70464dedf702d28b3f74d 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestSelectForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestSelectForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\JsonResponse; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $base = array( '#type' => 'select', '#options' => array('one' => 'one', 'two' => 'two', 'three' => 'three'), @@ -126,7 +127,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['response'] = new JsonResponse($form_state['values']); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php index 5d948b05758338451faa101d87d74037a138dc73..f34f926cd1862d1dbf81000bc71eab7cb5567b04 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form constructor for testing form state persistence. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['title'] = array( '#type' => 'textfield', '#title' => 'title', @@ -43,7 +44,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($form_state['value']); $form_state['rebuild'] = TRUE; } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php index dadee2659e6ddb9cb9bc017e2508540986deddb7..742dac32c61a21690817612cacc57c1855f2e01d 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * A multistep form for testing the form storage. @@ -30,7 +31,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { if ($form_state['rebuild']) { $form_state['input'] = array(); } @@ -92,7 +93,7 @@ public function buildForm(array $form, array &$form_state) { * * Tests updating of cached form storage during validation. */ - public function elementValidateValueCached($element, &$form_state) { + public function elementValidateValueCached($element, FormStateInterface $form_state) { // If caching is enabled and we receive a certain value, change the storage. // This presumes that another submitted form value triggers a validation error // elsewhere in the form. Form API should still update the cached form storage @@ -105,7 +106,7 @@ public function elementValidateValueCached($element, &$form_state) { /** * {@inheritdoc} */ - public function continueSubmitForm(array &$form, array &$form_state) { + public function continueSubmitForm(array &$form, FormStateInterface $form_state) { $form_state['storage']['thing']['title'] = $form_state['values']['title']; $form_state['storage']['thing']['value'] = $form_state['values']['value']; $form_state['rebuild'] = TRUE; @@ -114,7 +115,7 @@ public function continueSubmitForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message("Title: " . String::checkPlain($form_state['values']['title'])); drupal_set_message("Form constructions: " . $_SESSION['constructions']); if (isset($form_state['storage']['thing']['changed'])) { diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php index 29c7e922fc9357cb2dcd4283cf0223a8bb6555f6..8c34d223aeeed7d25b986b0f6f5fac4b2f0b472f 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectColspanForm.php @@ -7,6 +7,8 @@ namespace Drupal\form_test\Form; +use Drupal\Core\Form\FormStateInterface; + class FormTestTableSelectColspanForm extends FormTestTableSelectFormBase { /** @@ -19,7 +21,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { list($header, $options) = _form_test_tableselect_get_data(); // Change the data so that the third column has colspan=2. @@ -42,7 +44,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectEmptyForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectEmptyForm.php index 2bc690ec627b1094af6c4bf488f097c066d69bf4..5d7dade98e83903321b1bbf8a964460f67726b0d 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectEmptyForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectEmptyForm.php @@ -7,6 +7,8 @@ namespace Drupal\form_test\Form; +use Drupal\Core\Form\FormStateInterface; + class FormTestTableSelectEmptyForm extends FormTestTableSelectFormBase { /** @@ -19,14 +21,14 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { return $this->tableselectFormBuilder($form, $form_state, array('#options' => array())); } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php index 863fe9bef8b4bbb7b2078866f7958308f8210a75..c5186e2e7128e46664ee068517c092099ddf4d20 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php @@ -19,8 +19,8 @@ abstract class FormTestTableSelectFormBase extends FormBase { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param $element_properties * An array of element properties for the tableselect element. * diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectJsSelectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectJsSelectForm.php index c33ec770ab866d0efb899d16d17f5b209869adcc..c0991635a9a7cd78b799e5f730a369a5e26feecc 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectJsSelectForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectJsSelectForm.php @@ -7,6 +7,8 @@ namespace Drupal\form_test\Form; +use Drupal\Core\Form\FormStateInterface; + class FormTestTableSelectJsSelectForm extends FormTestTableSelectFormBase { /** @@ -19,7 +21,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $test_action = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $test_action = NULL) { switch ($test_action) { case 'multiple-true-default': $options = array('#multiple' => TRUE); @@ -44,7 +46,7 @@ public function buildForm(array $form, array &$form_state, $test_action = NULL) /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleFalseForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleFalseForm.php index c7545deb98339b12a43b02b241e19067776dd5bb..5f0b457b3d980c0e4c6892ad6cb9f6b681859cb4 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleFalseForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleFalseForm.php @@ -7,6 +7,8 @@ namespace Drupal\form_test\Form; +use Drupal\Core\Form\FormStateInterface; + class FormTestTableSelectMultipleFalseForm extends FormTestTableSelectFormBase { /** @@ -19,14 +21,14 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { return $this->tableselectFormBuilder($form, $form_state, array('#multiple' => FALSE)); } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message(t('Submitted: @value', array('@value' => $form_state['values']['tableselect']))); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleTrueForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleTrueForm.php index 28ea3bbd93924e12625450aeb68e3260edbf3542..4d9a0e6d9ecc702c68b654dd96594cb820e80bdf 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleTrueForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleTrueForm.php @@ -7,6 +7,8 @@ namespace Drupal\form_test\Form; +use Drupal\Core\Form\FormStateInterface; + class FormTestTableSelectMultipleTrueForm extends FormTestTableSelectFormBase { /** @@ -19,14 +21,14 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { return $this->tableselectFormBuilder($form, $form_state, array('#multiple' => TRUE)); } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $selected = $form_state['values']['tableselect']; foreach ($selected as $key => $value) { drupal_set_message(t('Submitted: @key = @value', array('@key' => $key, '@value' => $value))); diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php index 8e2c5a032db680aefa2f06436a2731030d2cf4b3..297b60462123ebb482825b037edd60af881d9679 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestUrlForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\JsonResponse; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['url'] = array( '#type' => 'url', '#title' => 'Optional URL', @@ -47,7 +48,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['response'] = new JsonResponse($form_state['values']); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php index 2e59a754ba1ca69210087d144eb50dd983fdf597..6467520f815320e6f4df7321241a203fee9fbd33 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\form_test\Callbacks; /** @@ -34,7 +35,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $object = new Callbacks(); $form['name'] = array( @@ -58,7 +59,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { if ($form_state['values']['name'] == 'validate') { // Alter the form element. $form['name']['#value'] = '#value changed by #validate'; @@ -75,7 +76,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php index 65cb0302e12fdef551bd7da22ab11603ffa9cf69..35908ad5e2610af0fe00d3668bd40b5263c938c9 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form constructor to test the #required property. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $options = array('foo' => 'foo', 'bar' => 'bar'); $validate = array(array($this, 'elementValidateRequired')); @@ -75,7 +76,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function elementValidateRequired($element, &$form_state) { + public function elementValidateRequired($element, FormStateInterface $form_state) { // Set a custom validation error on the #required element. if (!empty($element['#required_but_empty']) && isset($element['#form_test_required_error'])) { form_error($element, $form_state, $element['#form_test_required_error']); @@ -85,7 +86,7 @@ public function elementValidateRequired($element, &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message('The form_test_validate_required_form form was submitted successfully.'); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php index 25e507611f1ce7cbb82078e54b4bf55de52502bc..9beb455e1042d6e683b57710b5165a1ac6d5370d 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form constructor to test the #required property without #title. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['textfield'] = array( '#type' => 'textfield', '#required' => TRUE, @@ -37,7 +38,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message('The form_test_validate_required_form_no_title form was submitted successfully.'); } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php index 4b35fbb98a84d58a907fd803482a20fb5db08366..4a6966043e860dd2b82a644ff6b788fe9ab5d8a7 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; class FormTestVerticalTabsForm extends FormBase { @@ -21,7 +22,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['vertical_tabs'] = array( '#type' => 'vertical_tabs', ); @@ -52,7 +53,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/Form/RedirectBlockForm.php b/core/modules/system/tests/modules/form_test/src/Form/RedirectBlockForm.php index 7d134d04325d5b0238ec9d8763f78e282ab8ff05..5f2fb52570c389972dd1d19bcadf17e7d81464d0 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/RedirectBlockForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/RedirectBlockForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -27,7 +28,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Submit')); @@ -37,7 +38,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['redirect_route'] = new Url('form_test.route1', array(), array('query' => array('test1' => 'test2'))); } } diff --git a/core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php b/core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php index 3f6703d9705b6173d0fede52f4010a6e65af4634..dd5843599a2113643190ff41b4c79048188cb3b3 100644 --- a/core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php +++ b/core/modules/system/tests/modules/form_test/src/FormTestArgumentsObject.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides a test form object that needs arguments. @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $arg = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $arg = NULL) { $form['element'] = array('#markup' => 'The FormTestArgumentsObject::buildForm() method was used for this form.'); $form['bananas'] = array( @@ -45,14 +46,14 @@ public function buildForm(array $form, array &$form_state, $arg = NULL) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The FormTestArgumentsObject::validateForm() method was used for this form.')); } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The FormTestArgumentsObject::submitForm() method was used for this form.')); $this->config('form_test.object') ->set('bananas', $form_state['values']['bananas']) diff --git a/core/modules/system/tests/modules/form_test/src/FormTestAutocompleteForm.php b/core/modules/system/tests/modules/form_test/src/FormTestAutocompleteForm.php index 6cedc3aaeee163a4d3d6c5f7a7cfe52edb8815e7..43daa5c2a086b2c8a540d78edff5026ec5263b5f 100644 --- a/core/modules/system/tests/modules/form_test/src/FormTestAutocompleteForm.php +++ b/core/modules/system/tests/modules/form_test/src/FormTestAutocompleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\form_test; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Defines a test form using autocomplete textfields. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['autocomplete_1'] = array( '#type' => 'textfield', '#title' => 'Autocomplete 1', @@ -43,7 +44,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php b/core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php index 6ddc7e0c7b037ae8a84c49843b4c81e72a47ba4d..4ccc8ad4a68775afb9b7168cbdc4fed110cc4ba7 100644 --- a/core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php +++ b/core/modules/system/tests/modules/form_test/src/FormTestControllerObject.php @@ -8,6 +8,7 @@ namespace Drupal\form_test; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -33,7 +34,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $custom_attributes = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $custom_attributes = NULL) { $form['element'] = array('#markup' => 'The FormTestControllerObject::buildForm() method was used for this form.'); $form['custom_attribute']['#markup'] = $custom_attributes; @@ -55,14 +56,14 @@ public function buildForm(array $form, array &$form_state, $custom_attributes = /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The FormTestControllerObject::validateForm() method was used for this form.')); } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The FormTestControllerObject::submitForm() method was used for this form.')); $this->config('form_test.object') ->set('bananas', $form_state['values']['bananas']) diff --git a/core/modules/system/tests/modules/form_test/src/FormTestObject.php b/core/modules/system/tests/modules/form_test/src/FormTestObject.php index f6cb948cfbb9d43656b2b0e1d313865b10415b81..a6c6da356f667f53e500fe93df2a2d8c0e2428e8 100644 --- a/core/modules/system/tests/modules/form_test/src/FormTestObject.php +++ b/core/modules/system/tests/modules/form_test/src/FormTestObject.php @@ -8,6 +8,7 @@ namespace Drupal\form_test; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides a test form object. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['element'] = array('#markup' => 'The FormTestObject::buildForm() method was used for this form.'); $form['bananas'] = array( @@ -46,14 +47,14 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The FormTestObject::validateForm() method was used for this form.')); } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The FormTestObject::submitForm() method was used for this form.')); $this->config('form_test.object') ->set('bananas', $form_state['values']['bananas']) diff --git a/core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php b/core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php index 2861600932382a913667fc59da76dfcda3fccb17..40682cb86b5e30b0920b201358533fef247f3ec0 100644 --- a/core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php +++ b/core/modules/system/tests/modules/form_test/src/FormTestServiceObject.php @@ -8,6 +8,7 @@ namespace Drupal\form_test; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides a test form object. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['element'] = array('#markup' => 'The FormTestServiceObject::buildForm() method was used for this form.'); $form['bananas'] = array( @@ -44,14 +45,14 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The FormTestServiceObject::validateForm() method was used for this form.')); } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The FormTestServiceObject::submitForm() method was used for this form.')); $this->config('form_test.object') ->set('bananas', $form_state['values']['bananas']) diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php index 42c88308aacca1ad63e094aa9019442bb05809db..36ab20ce4cac9dcc1c8a3e52106415ce1f18a284 100644 --- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php +++ b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php @@ -8,6 +8,7 @@ namespace Drupal\image_test\Plugin\ImageToolkit; use Drupal\Component\Utility\Unicode; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\ImageToolkit\ImageToolkitBase; /** @@ -60,7 +61,7 @@ public function settingsForm() { /** * {@inheritdoc} */ - public function settingsFormSubmit($form, &$form_state) { + public function settingsFormSubmit($form, FormStateInterface $form_state) { \Drupal::config('system.image.test_toolkit') ->set('test_parameter', $form_state['values']['test']['test_parameter']) ->save(); diff --git a/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php b/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php index 706c79c0a8bf124de06ca323dee32e87acaddc65..3cf17f80a9fded40614d1da83ba91124eccdbbbe 100644 --- a/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php +++ b/core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form controller for the test config edit forms. @@ -25,7 +26,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['input'] = array( '#type' => 'textfield', '#title' => 'Input', @@ -44,7 +45,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message(String::format('Ok: @input', array('@input' => $form_state['values']['input']))); } diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index 4dd9d6058f2c5e52d7283bac55feca0ae0d60c6d..09973a863663c73d43f132370c8b96eafe590f66 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -239,9 +239,9 @@ * @param $form * Nested array of form elements that comprise the form. * @param $form_state - * A keyed array containing the current state of the form. + * The current state of the form. */ -function hook_form_system_theme_settings_alter(&$form, &$form_state) { +function hook_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) { // Add a checkbox to toggle the breadcrumb trail. $form['toggle_breadcrumb'] = array( '#type' => 'checkbox', diff --git a/core/modules/taxonomy/src/Form/OverviewTerms.php b/core/modules/taxonomy/src/Form/OverviewTerms.php index 4ff067a24fcebed8f45798618b9564f50ae8c9a0..23db546e1091002ea02b8301c0acd862c86eac52 100644 --- a/core/modules/taxonomy/src/Form/OverviewTerms.php +++ b/core/modules/taxonomy/src/Form/OverviewTerms.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\taxonomy\VocabularyInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -58,15 +59,15 @@ public function getFormId() { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param \Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary * The vocabulary to display the overview form for. * * @return array * The form structure. */ - public function buildForm(array $form, array &$form_state, VocabularyInterface $taxonomy_vocabulary = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, VocabularyInterface $taxonomy_vocabulary = NULL) { // @todo Remove global variables when http://drupal.org/node/2044435 is in. global $pager_page_array, $pager_total, $pager_total_items; @@ -360,10 +361,10 @@ public function buildForm(array $form, array &$form_state, VocabularyInterface $ * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Sort term order based on weight. uasort($form_state['values']['terms'], array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); @@ -448,7 +449,7 @@ public function submitForm(array &$form, array &$form_state) { /** * Redirects to confirmation form for the reset action. */ - public function submitReset(array &$form, array &$form_state) { + public function submitReset(array &$form, FormStateInterface $form_state) { /** @var $vocabulary \Drupal\taxonomy\VocabularyInterface */ $vocabulary = $form_state['taxonomy']['vocabulary']; $form_state['redirect_route'] = $vocabulary->urlInfo('reset'); diff --git a/core/modules/taxonomy/src/Form/TermDeleteForm.php b/core/modules/taxonomy/src/Form/TermDeleteForm.php index 44d92b69adda532ad3ee26de984ff74d352bced2..7851734e1ea8f3db012ec73f400d8708f17e2097 100644 --- a/core/modules/taxonomy/src/Form/TermDeleteForm.php +++ b/core/modules/taxonomy/src/Form/TermDeleteForm.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Entity\EntityManagerInterface; @@ -55,7 +56,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); $storage = $this->entityManager->getStorage('taxonomy_vocabulary'); $vocabulary = $storage->load($this->entity->bundle()); diff --git a/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php b/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php index 34d3da9f1e05d787243ecd510faea8b6252358f4..52348fb5b76bda4f4142913c1fd2e8269b76b130 100644 --- a/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php +++ b/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\taxonomy\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -53,7 +54,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/src/Form/VocabularyResetForm.php b/core/modules/taxonomy/src/Form/VocabularyResetForm.php index ef9e296cd5c1037f8f5d0d2df354dcaeb09392f3..e32aec86b03857936ca2c946bb570156a0dc580d 100644 --- a/core/modules/taxonomy/src/Form/VocabularyResetForm.php +++ b/core/modules/taxonomy/src/Form/VocabularyResetForm.php @@ -8,6 +8,7 @@ namespace Drupal\taxonomy\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\taxonomy\TermStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -80,7 +81,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $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); diff --git a/core/modules/taxonomy/src/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php b/core/modules/taxonomy/src/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php index bae89fd641944edd699e21f11da16b655f89d4f1..1dd79433e5c050e17bbe72d8eaac930489880b1b 100644 --- a/core/modules/taxonomy/src/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php +++ b/core/modules/taxonomy/src/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php @@ -10,6 +10,7 @@ use Drupal\Core\Field\EntityReferenceFieldItemList; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; /** * Represents a configurable taxonomy_term_reference entity field item list. @@ -19,7 +20,7 @@ class TaxonomyTermReferenceFieldItemList extends EntityReferenceFieldItemList { /** * {@inheritdoc} */ - public function defaultValuesFormSubmit(array $element, array &$form, array &$form_state) { + public function defaultValuesFormSubmit(array $element, array &$form, FormStateInterface $form_state) { $default_value = parent::defaultValuesFormSubmit($element, $form, $form_state); // Convert numeric IDs to UUIDs to ensure config deployability. diff --git a/core/modules/taxonomy/src/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php b/core/modules/taxonomy/src/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php index fb6a93e1b0ceb0fbed0ec8a542441a31091b7d4e..865a80225971f08b8d0094f50e26093ebde0e7f5 100644 --- a/core/modules/taxonomy/src/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php +++ b/core/modules/taxonomy/src/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\OptGroup; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\AllowedValuesInterface; @@ -119,7 +120,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { $vocabularies = entity_load_multiple('taxonomy_vocabulary'); $options = array(); foreach ($vocabularies as $vocabulary) { @@ -151,7 +152,7 @@ public function settingsForm(array &$form, array &$form_state, $has_data) { /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { return array(); } diff --git a/core/modules/taxonomy/src/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php b/core/modules/taxonomy/src/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php index ae156a48d54311f53841ffd01a76c0041f100580..b3500faeb63b9b4682e7bd5ba55fa88da4ff13c9 100644 --- a/core/modules/taxonomy/src/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php +++ b/core/modules/taxonomy/src/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'taxonomy_autocomplete' widget. @@ -38,7 +39,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['placeholder'] = array( '#type' => 'textfield', '#title' => t('Placeholder'), @@ -69,7 +70,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $tags = array(); if (!$items->isEmpty()) { foreach ($items as $item) { @@ -96,7 +97,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen /** * {@inheritdoc} */ - public function massageFormValues(array $values, array $form, array &$form_state) { + public function massageFormValues(array $values, array $form, FormStateInterface $form_state) { // Autocomplete widgets do not send their tids in the form, so we must detect // them here and process them independently. $items = array(); diff --git a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php index d41e89321ee4e152d74b159d100e11e91144258e..85c7b1165fea4dfff6538ef04b6af982b5c2b8e7 100644 --- a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php +++ b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Plugin\views\argument; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\argument\ArgumentPluginBase; use Drupal\Component\Utility\String; @@ -32,7 +33,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['depth'] = array( '#type' => 'weight', '#title' => t('Depth'), diff --git a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php index ddfd1b92c59c95ba7bc2393405060556ad631477..077b1fd0deb64d0b8ca86522c002398a27cba814 100644 --- a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php +++ b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Plugin\views\argument; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\argument\ArgumentPluginBase; /** @@ -21,7 +22,7 @@ */ class IndexTidDepthModifier extends ArgumentPluginBase { - public function buildOptionsForm(&$form, &$form_state) { } + public function buildOptionsForm(&$form, FormStateInterface $form_state) { } public function query($group_by = FALSE) { } diff --git a/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php b/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php index 6dfd7bde3c6c7144d1b6861b1d4d11fd2b590e07..d5c9c9d5397ff9da8250418c6cb85b1ad4792e80 100644 --- a/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php +++ b/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Plugin\views\argument_default; +use Drupal\Core\Form\FormStateInterface; use Drupal\taxonomy\TermInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -55,7 +56,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['term_page'] = array( '#type' => 'checkbox', '#title' => t('Load default filter from term page'), @@ -113,7 +114,7 @@ public function buildOptionsForm(&$form, &$form_state) { ); } - public function submitOptionsForm(&$form, &$form_state, &$options = array()) { + public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = array()) { // Filter unselected items so we don't unnecessarily store giant arrays. $options['vids'] = array_filter($options['vids']); } diff --git a/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php b/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php index d44b58c5897b0c03764ece212a34d4a83a0efaca..3ed92580dfd0a9b0e13f8a8214749c38f808d061 100644 --- a/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php +++ b/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Plugin\views\argument_validator; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\Core\Entity\EntityManagerInterface; @@ -53,7 +54,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['transform'] = array( diff --git a/core/modules/taxonomy/src/Plugin/views/field/LinkEdit.php b/core/modules/taxonomy/src/Plugin/views/field/LinkEdit.php index 295bb9c10093e0ccc5bd9021a4874a6a270d7e7a..a0b1e67e19c4cdc6b7b512740baf71aa79e9a039 100644 --- a/core/modules/taxonomy/src/Plugin/views/field/LinkEdit.php +++ b/core/modules/taxonomy/src/Plugin/views/field/LinkEdit.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ResultRow; @@ -39,7 +40,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['text'] = array( '#type' => 'textfield', '#title' => t('Text to display'), diff --git a/core/modules/taxonomy/src/Plugin/views/field/Taxonomy.php b/core/modules/taxonomy/src/Plugin/views/field/Taxonomy.php index 7700b27d1dd2d078254994b0f8c48ef87bf3ecdb..59ced2d861d0a94198cb602bfb9df5d13115c1de 100644 --- a/core/modules/taxonomy/src/Plugin/views/field/Taxonomy.php +++ b/core/modules/taxonomy/src/Plugin/views/field/Taxonomy.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\area\Result; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -48,7 +49,7 @@ protected function defineOptions() { /** * Provide link to taxonomy option */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['link_to_taxonomy'] = array( '#title' => t('Link this field to its taxonomy term page'), '#description' => t("Enable to override this field's links."), diff --git a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php index 90e8225eef3e3555e1f8d9d8a9836aa9c2e90d05..5aac9e117e05f35a4946ca0c22385c7fad3e2feb 100644 --- a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\field\PrerenderList; @@ -49,7 +50,7 @@ protected function defineOptions() { /** * Provide "link to term" option. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['link_to_taxonomy'] = array( '#title' => t('Link this field to its term page'), '#type' => 'checkbox', diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php index 2c708ea1739ae891664fe2fda05422223f7cd210..c8f2381ec30c5943ed2e5ee568f20e4a728b59f9 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\filter\ManyToOne; @@ -51,7 +52,7 @@ protected function defineOptions() { return $options; } - public function buildExtraOptionsForm(&$form, &$form_state) { + public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) { $vocabularies = entity_load_multiple('taxonomy_vocabulary'); $options = array(); foreach ($vocabularies as $voc) { @@ -95,7 +96,7 @@ public function buildExtraOptionsForm(&$form, &$form_state) { ); } - protected function valueForm(&$form, &$form_state) { + protected function valueForm(&$form, FormStateInterface $form_state) { $vocabulary = entity_load('taxonomy_vocabulary', $this->options['vid']); if (empty($vocabulary) && $this->options['limit']) { $form['markup'] = array( @@ -212,7 +213,7 @@ protected function valueForm(&$form, &$form_state) { } } - protected function valueValidate($form, &$form_state) { + protected function valueValidate($form, FormStateInterface $form_state) { // We only validate if they've chosen the text field style. if ($this->options['type'] != 'textfield') { return; @@ -253,7 +254,7 @@ public function acceptExposedInput($input) { return $rc; } - public function validateExposed(&$form, &$form_state) { + public function validateExposed(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed'])) { return; } @@ -331,11 +332,11 @@ function validate_term_strings(&$form, $values) { return $tids; } - protected function valueSubmit($form, &$form_state) { + protected function valueSubmit($form, FormStateInterface $form_state) { // prevent array_filter from messing up our arrays in parent submit. } - public function buildExposeForm(&$form, &$form_state) { + public function buildExposeForm(&$form, FormStateInterface $form_state) { parent::buildExposeForm($form, $form_state); if ($this->options['type'] != 'select') { unset($form['expose']['reduce']); diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php index da0a61d53a48da391cf30e19e5baeb442eb519ca..cb30f46ad29e04a24caab01695b82e409014690d 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php @@ -7,6 +7,8 @@ namespace Drupal\taxonomy\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; + /** * Filter handler for taxonomy terms with depth. * @@ -33,7 +35,7 @@ protected function defineOptions() { return $options; } - public function buildExtraOptionsForm(&$form, &$form_state) { + public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) { parent::buildExtraOptionsForm($form, $form_state); $form['depth'] = array( diff --git a/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php b/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php index c720ee93eebd02cab52b0e1c8fe53c578bc525eb..348309397d1224f2524df9b4fb12b7be900de328 100644 --- a/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php +++ b/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Plugin\views\relationship; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\relationship\RelationshipPluginBase; @@ -44,7 +45,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $vocabularies = entity_load_multiple('taxonomy_vocabulary'); $options = array(); foreach ($vocabularies as $voc) { diff --git a/core/modules/taxonomy/src/TermForm.php b/core/modules/taxonomy/src/TermForm.php index 851fa434f33e074c70e71c55171bbbfd76221ff9..89aeac2b4aebe47ad8937b8085bffbb27eb0fb50 100644 --- a/core/modules/taxonomy/src/TermForm.php +++ b/core/modules/taxonomy/src/TermForm.php @@ -8,6 +8,7 @@ namespace Drupal\taxonomy; use Drupal\Core\Entity\ContentEntityForm; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; /** @@ -18,7 +19,7 @@ class TermForm extends ContentEntityForm { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $term = $this->entity; $vocab_storage = $this->entityManager->getStorage('taxonomy_vocabulary'); $vocabulary = $vocab_storage->load($term->bundle()); @@ -107,7 +108,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); // Ensure numeric values. @@ -119,7 +120,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function buildEntity(array $form, array &$form_state) { + public function buildEntity(array $form, FormStateInterface $form_state) { $term = parent::buildEntity($form, $form_state); // Prevent leading and trailing spaces in term names. @@ -134,7 +135,7 @@ public function buildEntity(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $term = $this->entity; switch ($term->save()) { diff --git a/core/modules/taxonomy/src/TermTranslationHandler.php b/core/modules/taxonomy/src/TermTranslationHandler.php index 58cf8646b63cf54e199392e0afeea118b2b6603c..3b8fbeb2e5964cd98a4d935e05fb1fffecd366ab 100644 --- a/core/modules/taxonomy/src/TermTranslationHandler.php +++ b/core/modules/taxonomy/src/TermTranslationHandler.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\content_translation\ContentTranslationHandler; +use Drupal\Core\Form\FormStateInterface; /** * Defines the translation handler for terms. @@ -18,7 +19,7 @@ class TermTranslationHandler extends ContentTranslationHandler { /** * {@inheritdoc} */ - public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { + public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) { parent::entityFormAlter($form, $form_state, $entity); $form['actions']['submit']['#submit'][] = array($this, 'entityFormSave'); } @@ -30,7 +31,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac * * @see \Drupal\Core\Entity\EntityForm::build(). */ - function entityFormSave(array $form, array &$form_state) { + function entityFormSave(array $form, FormStateInterface $form_state) { if ($this->getSourceLangcode($form_state)) { $entity = content_translation_form_controller($form_state)->getEntity(); // We need a redirect here, otherwise we would get an access denied page, diff --git a/core/modules/taxonomy/src/VocabularyForm.php b/core/modules/taxonomy/src/VocabularyForm.php index 95a986a5b9c82ff911a591780d717f86a8b560ea..01ddc08e76507019ca03e8a85cfbf274d9c5d8ab 100644 --- a/core/modules/taxonomy/src/VocabularyForm.php +++ b/core/modules/taxonomy/src/VocabularyForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; /** @@ -19,7 +20,7 @@ class VocabularyForm extends EntityForm { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $vocabulary = $this->entity; if ($vocabulary->isNew()) { $form['#title'] = $this->t('Add vocabulary'); @@ -88,7 +89,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { // If we are displaying the delete confirmation skip the regular actions. if (empty($form_state['confirm_delete'])) { $actions = parent::actions($form, $form_state); @@ -114,7 +115,7 @@ protected function actions(array $form, array &$form_state) { /** * Submit handler to update the bundle for the default language configuration. */ - public function languageConfigurationSubmit(array &$form, array &$form_state) { + public function languageConfigurationSubmit(array &$form, FormStateInterface $form_state) { $vocabulary = $this->entity; // Delete the old language settings for the vocabulary, if the machine name // is changed. @@ -130,7 +131,7 @@ public function languageConfigurationSubmit(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $vocabulary = $this->entity; // Prevent leading and trailing spaces in vocabulary names. diff --git a/core/modules/taxonomy/src/VocabularyListBuilder.php b/core/modules/taxonomy/src/VocabularyListBuilder.php index c4fc1ad244fe4a10e94875ee758655d4f343268b..056c0730e1ead1bfb4f56ffb19f64553a47f107a 100644 --- a/core/modules/taxonomy/src/VocabularyListBuilder.php +++ b/core/modules/taxonomy/src/VocabularyListBuilder.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\Entity\DraggableListBuilder; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormStateInterface; /** * Defines a class to build a listing of taxonomy vocabulary entities. @@ -86,7 +87,7 @@ public function render() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $form['vocabularies']['#attributes'] = array('id' => 'taxonomy'); $form['actions']['submit']['#value'] = t('Save'); @@ -97,7 +98,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); drupal_set_message(t('The configuration options have been saved.')); diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 62e03977b8934a0473595a8c8aca007ae2393251..61ecb8b35b580364c4c2199037e7899d621e9a2c 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -8,6 +8,7 @@ use Drupal\Component\Utility\Tags; use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; @@ -708,7 +709,7 @@ function taxonomy_term_title(Term $term) { /** * Form element validate handler for taxonomy term autocomplete element. */ -function taxonomy_autocomplete_validate($element, &$form_state) { +function taxonomy_autocomplete_validate($element, FormStateInterface $form_state) { // Split the values into an array. // @see \Drupal\taxonomy\Plugin\Field\FieldWidget\TaxonomyAutocompleteWidget:massageFormValues() $typed_terms = array(); diff --git a/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php b/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php index 7dd4dee4a20b08383b194f28372ea0f09917f0ac..5c65cf6e8b93d598fde6fbb5dbcd06bbee5d2ae2 100644 --- a/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php +++ b/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'telephone_link' formatter. @@ -35,7 +36,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $elements['title'] = array( '#type' => 'textfield', '#title' => t('Title to replace basic numeric telephone number display.'), diff --git a/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php b/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php index 0bdd1c8ad7f23ccb0b8f6d02a6a3598cf2e5f173..2be36da099c1996ea1b5a132baf0d8f3c3fff947 100644 --- a/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php +++ b/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'telephone_default' widget. @@ -35,7 +36,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['placeholder'] = array( '#type' => 'textfield', '#title' => t('Placeholder'), @@ -65,7 +66,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element['value'] = $element + array( '#type' => 'tel', '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, diff --git a/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php b/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php index 40c8dd0bffd5d9165912484470d07f03108b4f82..8cd66c013f71772c9e3712e3e249e4d10195e26a 100644 --- a/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php +++ b/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php @@ -8,6 +8,7 @@ use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'text_trimmed' formatter. @@ -44,7 +45,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element['trim_length'] = array( '#title' => t('Trim length'), '#type' => 'number', diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextItem.php index 6bacea68ab2d892a6afa7b8505573c68f90e5336..3b7285d4e327cd31ff30a62ff751e19249822d6f 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextItem.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextItem.php @@ -8,6 +8,7 @@ namespace Drupal\text\Plugin\Field\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'text' field type. @@ -78,7 +79,7 @@ public function getConstraints() { /** * {@inheritdoc} */ - public function settingsForm(array &$form, array &$form_state, $has_data) { + public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) { $element = array(); $element['max_length'] = array( @@ -97,7 +98,7 @@ public function settingsForm(array &$form, array &$form_state, $has_data) { /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { $element = array(); $element['text_processing'] = array( diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php index 367ae1957593e4e757261cde9bd13a2e4313a1f9..1c74a41e1079f0c4dc8087fb378b75f95f77053f 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php @@ -8,6 +8,7 @@ namespace Drupal\text\Plugin\Field\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; /** * Plugin implementation of the 'text_long' field type. @@ -48,7 +49,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { $element = array(); $element['text_processing'] = array( diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php index 0d686e0fbaf100e970bdbb796eca43d57a311331..7ffcd64d0f7e5ca6a78f115816893585afc3121f 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php @@ -8,6 +8,7 @@ namespace Drupal\text\Plugin\Field\FieldType; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\TypedData\DataDefinition; /** @@ -91,7 +92,7 @@ public function isEmpty() { /** * {@inheritdoc} */ - public function instanceSettingsForm(array $form, array &$form_state) { + public function instanceSettingsForm(array $form, FormStateInterface $form_state) { $element = array(); $settings = $this->getSettings(); diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php index a8afeb3d38537216ab0365ac5e2bff96fdbcac0e..ef6a5db7609aab5415b79651bd4fda0184c83758 100644 --- a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php +++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextareaWidget; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\Validator\ConstraintViolationInterface; /** @@ -27,7 +28,7 @@ class TextareaWidget extends StringTextareaWidget { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $main_widget = parent::formElement($items, $delta, $element, $form, $form_state); if ($this->getFieldSetting('text_processing')) { @@ -44,7 +45,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen /** * {@inheritdoc} */ - public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, array &$form_state) { + public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) { if ($violation->arrayPropertyPath == array('format') && isset($element['format']['#access']) && !$element['format']['#access']) { // Ignore validation errors for formats if formats may not be changed, // i.e. when existing formats become invalid. See filter_process_format(). diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php index e23e794decbf9386e992bcab299c824f8833a1b3..ba8c87525d71daf9c90e06d4c059a0f37c0e0927 100644 --- a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php +++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php @@ -7,6 +7,7 @@ namespace Drupal\text\Plugin\Field\FieldWidget; +use Drupal\Core\Form\FormStateInterface; use Drupal\text\Plugin\Field\FieldWidget\TextareaWidget; use Symfony\Component\Validator\ConstraintViolationInterface; use Drupal\Core\Field\FieldItemListInterface; @@ -38,7 +39,7 @@ public static function defaultSettings() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state) { + public function settingsForm(array $form, FormStateInterface $form_state) { $element = parent::settingsForm($form, $form_state); $element['summary_rows'] = array( '#type' => 'number', @@ -64,7 +65,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element = parent::formElement($items, $delta, $element, $form, $form_state); $display_summary = $items[$delta]->summary || $this->getFieldSetting('display_summary'); @@ -89,7 +90,7 @@ function formElement(FieldItemListInterface $items, $delta, array $element, arra /** * {@inheritdoc} */ - public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, array &$form_state) { + public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) { $element = parent::errorElement($element, $violation, $form, $form_state); return ($element === FALSE) ? FALSE : $element[$violation->arrayPropertyPath[0]]; } diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php index 989bcb846f57b6d08624dc951ca3500c8eab470e..c9b5dcd0a17b7c74256d43ca2f7521e778b48421 100644 --- a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php +++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\Plugin\Field\FieldWidget\StringWidget; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\Validator\ConstraintViolationInterface; /** @@ -28,7 +29,7 @@ class TextfieldWidget extends StringWidget { /** * {@inheritdoc} */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $main_widget = parent::formElement($items, $delta, $element, $form, $form_state); if ($this->getFieldSetting('text_processing')) { @@ -44,7 +45,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen /** * {@inheritdoc} */ - public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, array &$form_state) { + public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) { if ($violation->arrayPropertyPath == array('format') && isset($element['format']['#access']) && !$element['format']['#access']) { // Ignore validation errors for formats if formats may not be changed, // i.e. when existing formats become invalid. See filter_process_format(). diff --git a/core/modules/update/src/Form/UpdateManagerInstall.php b/core/modules/update/src/Form/UpdateManagerInstall.php index e44cd0d5f6ad4d759c33ab45aba840ee0f279dc8..11b1ff645bd625901cd6aac51d2bbb80ef565eea 100644 --- a/core/modules/update/src/Form/UpdateManagerInstall.php +++ b/core/modules/update/src/Form/UpdateManagerInstall.php @@ -10,6 +10,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\FileTransfer\Local; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Updater\Updater; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -54,7 +55,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $this->moduleHandler->loadInclude('update', 'inc', 'update.manager'); if (!_update_manager_check_backends($form, 'install')) { return $form; @@ -101,7 +102,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $uploaded_file = $this->getRequest()->files->get('files[project_upload]', NULL, TRUE); if (!($form_state['values']['project_url'] XOR !empty($uploaded_file))) { $this->setFormError('project_url', $form_state, $this->t('You must either provide a URL or upload an archive file to install.')); @@ -111,7 +112,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $local_cache = NULL; if ($form_state['values']['project_url']) { $local_cache = update_manager_file_get($form_state['values']['project_url']); diff --git a/core/modules/update/src/Form/UpdateManagerUpdate.php b/core/modules/update/src/Form/UpdateManagerUpdate.php index fd2cfb23403b6015a596216715fcc0f9a4bec23c..0f813610e6c3039f8fe29f355df65eeca5a46e1e 100644 --- a/core/modules/update/src/Form/UpdateManagerUpdate.php +++ b/core/modules/update/src/Form/UpdateManagerUpdate.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\State\StateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -65,7 +66,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $this->moduleHandler->loadInclude('update', 'inc', 'update.manager'); $last_markup = array( @@ -285,7 +286,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { if (!empty($form_state['values']['projects'])) { $enabled = array_filter($form_state['values']['projects']); } @@ -300,7 +301,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->moduleHandler->loadInclude('update', 'inc', 'update.manager'); $projects = array(); foreach (array('projects', 'disabled_projects') as $type) { diff --git a/core/modules/update/src/Form/UpdateReady.php b/core/modules/update/src/Form/UpdateReady.php index 57155f0caa22be3bb492382b74bc41e1f4d5e12c..942164a294602e74a14f1ca4a461f9b36de890a7 100644 --- a/core/modules/update/src/Form/UpdateReady.php +++ b/core/modules/update/src/Form/UpdateReady.php @@ -10,6 +10,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\FileTransfer\Local; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Updater\Updater; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -66,7 +67,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $this->moduleHandler->loadInclude('update', 'inc', 'update.manager'); if (!_update_manager_check_backends($form, 'update')) { return $form; @@ -96,7 +97,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Store maintenance_mode setting so we can restore it when done. $_SESSION['maintenance_mode'] = $this->state->get('system.maintenance_mode'); if ($form_state['values']['maintenance_mode'] == TRUE) { diff --git a/core/modules/update/src/UpdateSettingsForm.php b/core/modules/update/src/UpdateSettingsForm.php index 600eaa2e2d2ea79dd2322e5c14ac14a082a310c4..70610816c64be13bd2ee3e96e80361eb3e739399 100644 --- a/core/modules/update/src/UpdateSettingsForm.php +++ b/core/modules/update/src/UpdateSettingsForm.php @@ -8,6 +8,7 @@ namespace Drupal\update; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Configure update settings for this site. @@ -22,9 +23,9 @@ public function getFormId() { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('update.settings'); $form['update_check_frequency'] = array( @@ -70,7 +71,7 @@ public function buildForm(array $form, array &$form_state) { /** * Implements \Drupal\Core\Form\FormInterface::validateForm(). */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $form_state['notify_emails'] = array(); if (!empty($form_state['values']['update_notify_emails'])) { $valid = array(); @@ -101,9 +102,9 @@ public function validateForm(array &$form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $config = $this->config('update.settings'); // See if the update_check_disabled setting is being changed, and if so, // invalidate all update status data. diff --git a/core/modules/update/update.module b/core/modules/update/update.module index e34965e1d1207bfdfd34d7f7768216d84ed959c7..3ba62cb7e48a44ae9e497117cb1df29890a29071 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -12,6 +12,7 @@ */ use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Site\Settings; use Symfony\Cmf\Component\Routing\RouteObjectInterface; @@ -261,7 +262,7 @@ function update_form_system_modules_alter(&$form, $form_state) { * * @see update_form_system_modules_alter() */ -function update_storage_clear_submit($form, &$form_state) { +function update_storage_clear_submit($form, FormStateInterface $form_state) { // Clear all update module data. update_storage_clear(); } diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index f4f718b48bc832914b3673e75f60704862fe2d80..a72c497cb3c43ae6a94f1c88128d0cb5dadcad74 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\language\ConfigurableLanguageManagerInterface; @@ -66,7 +67,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { /** @var \Drupal\user\UserInterface $account */ $account = $this->entity; $user = $this->currentUser(); @@ -308,7 +309,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function buildEntity(array $form, array &$form_state) { + public function buildEntity(array $form, FormStateInterface $form_state) { // Change the roles array to a list of enabled roles. // @todo: Alter the form state as the form values are directly extracted and // set on the field, which throws an exception as the list requires @@ -324,7 +325,7 @@ public function buildEntity(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); $account = $this->entity; @@ -391,7 +392,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); $user = $this->getEntity($form_state); diff --git a/core/modules/user/src/AccountSettingsForm.php b/core/modules/user/src/AccountSettingsForm.php index fa39ac253af4599e1530d2944d2a388a27977e93..06e1a091040cf33353fe00022c69f24708998d98 100644 --- a/core/modules/user/src/AccountSettingsForm.php +++ b/core/modules/user/src/AccountSettingsForm.php @@ -10,6 +10,7 @@ use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Extension\ModuleHandler; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -56,9 +57,9 @@ public function getFormId() { } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $config = $this->config('user.settings'); $mail_config = $this->config('user.mail'); @@ -406,9 +407,9 @@ public function buildForm(array $form, array &$form_state) { } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $this->config('user.settings') diff --git a/core/modules/user/src/Form/UserCancelForm.php b/core/modules/user/src/Form/UserCancelForm.php index f9e8ead1a01b7ab6225e4e872c274e6b888daf28..031a27a539e4e9f678725731ea8e2c72d2eea593 100644 --- a/core/modules/user/src/Form/UserCancelForm.php +++ b/core/modules/user/src/Form/UserCancelForm.php @@ -8,6 +8,7 @@ namespace Drupal\user\Form; use Drupal\Core\Entity\ContentEntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides a confirmation form for cancelling user account. @@ -72,7 +73,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $user = $this->currentUser(); $this->cancelMethods = user_cancel_methods(); @@ -117,7 +118,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/src/Form/UserLoginForm.php b/core/modules/user/src/Form/UserLoginForm.php index 6300bfc3e32fc7f23cc24ff064856f0e6cde85c9..9ba621716bed0e6295e7552522d2720987a51d24 100644 --- a/core/modules/user/src/Form/UserLoginForm.php +++ b/core/modules/user/src/Form/UserLoginForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Flood\FloodInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\user\UserAuthInterface; use Drupal\user\UserStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -76,7 +77,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Display login form: $form['name'] = array( '#type' => 'textfield', @@ -114,7 +115,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $account = $this->userStorage->load($form_state['uid']); // A destination was set, probably on an exception controller, @@ -134,7 +135,7 @@ public function submitForm(array &$form, array &$form_state) { /** * Sets an error if supplied username has been blocked. */ - public function validateName(array &$form, array &$form_state) { + public function validateName(array &$form, FormStateInterface $form_state) { if (!empty($form_state['values']['name']) && user_is_blocked($form_state['values']['name'])) { // Blocked in user administration. $this->setFormError('name', $form_state, $this->t('The username %name has not been activated or is blocked.', array('%name' => $form_state['values']['name']))); @@ -146,7 +147,7 @@ public function validateName(array &$form, array &$form_state) { * * If successful, $form_state['uid'] is set to the matching user ID. */ - public function validateAuthentication(array &$form, array &$form_state) { + public function validateAuthentication(array &$form, FormStateInterface $form_state) { $password = trim($form_state['values']['pass']); $flood_config = $this->config('user.flood'); if (!empty($form_state['values']['name']) && !empty($password)) { @@ -193,7 +194,7 @@ public function validateAuthentication(array &$form, array &$form_state) { * * This validation function should always be the last one. */ - public function validateFinal(array &$form, array &$form_state) { + public function validateFinal(array &$form, FormStateInterface $form_state) { $flood_config = $this->config('user.flood'); if (empty($form_state['uid'])) { // Always register an IP-based failed login event. diff --git a/core/modules/user/src/Form/UserMultipleCancelConfirm.php b/core/modules/user/src/Form/UserMultipleCancelConfirm.php index 1d918ab7fdddbc199de517497d63e3499214cc7d..430480a2e4462a9a44194f5d6ed10c33bf868506 100644 --- a/core/modules/user/src/Form/UserMultipleCancelConfirm.php +++ b/core/modules/user/src/Form/UserMultipleCancelConfirm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Url; use Drupal\user\TempStoreFactory; @@ -101,7 +102,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Retrieve the accounts to be canceled from the temp store. $accounts = $this->tempStoreFactory ->get('user_user_operations_cancel') @@ -168,7 +169,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $current_user_id = $this->currentUser()->id(); // Clear out the accounts from the temp store. diff --git a/core/modules/user/src/Form/UserPasswordForm.php b/core/modules/user/src/Form/UserPasswordForm.php index 672dc11144950985ae8aac872808be33adf1a56f..59052820c1afe252b62aede7263dd51845554321 100644 --- a/core/modules/user/src/Form/UserPasswordForm.php +++ b/core/modules/user/src/Form/UserPasswordForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\Plugin\Field\FieldType\EmailItem; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManager; use Drupal\user\UserStorageInterface; use Symfony\Component\HttpFoundation\Request; @@ -69,7 +70,7 @@ public function getFormId() { * @param \Symfony\Component\HttpFoundation\Request $request * The request object. */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['name'] = array( '#type' => 'textfield', '#title' => $this->t('Username or email address'), @@ -106,7 +107,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $name = trim($form_state['values']['name']); // Try to load by email. $users = $this->userStorage->loadByProperties(array('mail' => $name, 'status' => '1')); @@ -126,7 +127,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $langcode = $this->languageManager->getCurrentLanguage()->id; $account = $form_state['values']['account']; diff --git a/core/modules/user/src/Form/UserPasswordResetForm.php b/core/modules/user/src/Form/UserPasswordResetForm.php index ba7c1212ad2f7958c16a34cc3208d22979599b0d..41c6e1a1c8e0572cbcaa42371f5a8548a109189d 100644 --- a/core/modules/user/src/Form/UserPasswordResetForm.php +++ b/core/modules/user/src/Form/UserPasswordResetForm.php @@ -7,6 +7,7 @@ namespace Drupal\user\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Component\Utility\Crypt; use Drupal\Core\Form\FormBase; @@ -56,8 +57,8 @@ public function getFormID() { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param \Drupal\Core\Session\AccountInterface $user * User requesting reset. * @param string $expiration_date @@ -68,7 +69,7 @@ public function getFormID() { * @param string $hash * Login link hash. */ - public function buildForm(array $form, array &$form_state, AccountInterface $user = NULL, $expiration_date = NULL, $timestamp = NULL, $hash = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, AccountInterface $user = NULL, $expiration_date = NULL, $timestamp = NULL, $hash = NULL) { if ($expiration_date) { $form['message'] = array('#markup' => $this->t('

This is a one-time login for %user_name and will expire on %expiration_date.

Click on this button to log in to the site and change your password.

', array('%user_name' => $user->getUsername(), '%expiration_date' => $expiration_date))); } @@ -98,7 +99,7 @@ public function buildForm(array $form, array &$form_state, AccountInterface $use /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { /** @var $user \Drupal\user\UserInterface */ $user = $form_state['values']['user']; user_login_finalize($user); diff --git a/core/modules/user/src/Form/UserPermissionsForm.php b/core/modules/user/src/Form/UserPermissionsForm.php index bd4e473835b015298f1a8d5752bb8366f9680fd8..8e5ac1d4f704f36dc3622cb2cb18e9c9a5d8829b 100644 --- a/core/modules/user/src/Form/UserPermissionsForm.php +++ b/core/modules/user/src/Form/UserPermissionsForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\user\RoleStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -75,7 +76,7 @@ protected function getRoles() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $role_names = array(); $role_permissions = array(); foreach ($this->getRoles() as $role_name => $role) { @@ -184,7 +185,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - function submitForm(array &$form, array &$form_state) { + function submitForm(array &$form, FormStateInterface $form_state) { foreach ($form_state['values']['role_names'] as $role_name => $name) { user_role_change_permissions($role_name, $form_state['values'][$role_name]); } diff --git a/core/modules/user/src/Form/UserPermissionsRoleSpecificForm.php b/core/modules/user/src/Form/UserPermissionsRoleSpecificForm.php index 6345a064d4f155cf34257195f93d29581ac3ae33..3da670d8c6a8a4693497b7551fc518f6840210b6 100644 --- a/core/modules/user/src/Form/UserPermissionsRoleSpecificForm.php +++ b/core/modules/user/src/Form/UserPermissionsRoleSpecificForm.php @@ -7,6 +7,7 @@ namespace Drupal\user\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\user\RoleInterface; /** @@ -34,7 +35,7 @@ protected function getRoles() { * @param string $role_id * The user role ID used for this form. */ - public function buildForm(array $form, array &$form_state, RoleInterface $user_role = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, RoleInterface $user_role = NULL) { $this->userRole = $user_role; return parent::buildForm($form, $form_state); } diff --git a/core/modules/user/src/Form/UserRoleDelete.php b/core/modules/user/src/Form/UserRoleDelete.php index 9ac6ad0cb695d2e69c7c909df92169d3cc294426..428817072b57f9fc6f587a1cacef12f578f4d4c1 100644 --- a/core/modules/user/src/Form/UserRoleDelete.php +++ b/core/modules/user/src/Form/UserRoleDelete.php @@ -8,6 +8,7 @@ namespace Drupal\user\Form; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -39,7 +40,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/src/Plugin/Action/ChangeUserRoleBase.php b/core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php index f844743c6c8f7579d22f2b667ca87da0417e07cd..c6fb44afd7630bff7a3d6ec561fabc245cd50a50 100644 --- a/core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php +++ b/core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php @@ -10,6 +10,7 @@ use Drupal\Core\Action\ConfigurableActionBase; use Drupal\Core\Entity\DependencyTrait; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -59,7 +60,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $roles = user_role_names(TRUE); unset($roles[DRUPAL_AUTHENTICATED_RID]); $form['rid'] = array( @@ -75,7 +76,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['rid'] = $form_state['values']['rid']; } diff --git a/core/modules/user/src/Plugin/Condition/UserRole.php b/core/modules/user/src/Plugin/Condition/UserRole.php index 872b18a7b1d8f9f780702c0c32e812f0c95daadc..5400d4ecd7ebed35d52ff224b0919ee2f5a48d84 100644 --- a/core/modules/user/src/Plugin/Condition/UserRole.php +++ b/core/modules/user/src/Plugin/Condition/UserRole.php @@ -8,6 +8,7 @@ namespace Drupal\user\Plugin\Condition; use Drupal\Core\Condition\ConditionPluginBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\Context\ContextDefinition; /** @@ -27,7 +28,7 @@ class UserRole extends ConditionPluginBase { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['roles'] = array( '#type' => 'checkboxes', '#title' => $this->t('When the user has the following roles'), @@ -50,7 +51,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function submitConfigurationForm(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['roles'] = array_filter($form_state['values']['roles']); parent::submitConfigurationForm($form, $form_state); } diff --git a/core/modules/user/src/Plugin/views/access/Permission.php b/core/modules/user/src/Plugin/views/access/Permission.php index 77979134e16c9183bb806f1ca20f1a7e6c66cea2..bc5a5fa0d0d7ebf55bc1e99e391d70e4e29d9557 100644 --- a/core/modules/user/src/Plugin/views/access/Permission.php +++ b/core/modules/user/src/Plugin/views/access/Permission.php @@ -7,6 +7,7 @@ namespace Drupal\user\Plugin\views\access; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\views\Plugin\views\access\AccessPluginBase; use Symfony\Component\Routing\Route; @@ -60,7 +61,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $perms = array(); $module_info = system_get_info('module'); diff --git a/core/modules/user/src/Plugin/views/access/Role.php b/core/modules/user/src/Plugin/views/access/Role.php index 496c9d791f129264ec209a9e9241763fbe025d3b..c63a5a46d5c3df50520054c501d510dfa907fd1f 100644 --- a/core/modules/user/src/Plugin/views/access/Role.php +++ b/core/modules/user/src/Plugin/views/access/Role.php @@ -8,6 +8,7 @@ namespace Drupal\user\Plugin\views\access; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\access\AccessPluginBase; use Symfony\Component\Routing\Route; use Drupal\Core\Session\AccountInterface; @@ -69,7 +70,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['role'] = array( '#type' => 'checkboxes', @@ -80,13 +81,13 @@ public function buildOptionsForm(&$form, &$form_state) { ); } - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { if (!array_filter($form_state['values']['access_options']['role'])) { form_error($form['role'], $form_state, t('You must select at least one role if type is "by role"')); } } - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { // I hate checkboxes. $form_state['values']['access_options']['role'] = array_filter($form_state['values']['access_options']['role']); } diff --git a/core/modules/user/src/Plugin/views/argument_default/User.php b/core/modules/user/src/Plugin/views/argument_default/User.php index fad874384767693ad1af1f295165aba9bf0092cf..d218e065f52fd9b39e0d2f0d521b18bd94bbcf5a 100644 --- a/core/modules/user/src/Plugin/views/argument_default/User.php +++ b/core/modules/user/src/Plugin/views/argument_default/User.php @@ -7,6 +7,7 @@ namespace Drupal\user\Plugin\views\argument_default; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -36,7 +37,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['user'] = array( '#type' => 'checkbox', '#title' => t('Also look for a node and use the node author'), diff --git a/core/modules/user/src/Plugin/views/argument_validator/User.php b/core/modules/user/src/Plugin/views/argument_validator/User.php index 25d23b2f6f66160bcc3f3796f8d3100da3ea1614..c6acd8656c288d13c49ad2f89d9841d75f178e7b 100644 --- a/core/modules/user/src/Plugin/views/argument_validator/User.php +++ b/core/modules/user/src/Plugin/views/argument_validator/User.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\views\Plugin\views\argument\ArgumentPluginBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\argument_validator\Entity; /** @@ -51,7 +52,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $sanitized_id = ArgumentPluginBase::encodeValidatorId($this->definition['id']); @@ -78,7 +79,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * {@inheritdoc} */ - public function submitOptionsForm(&$form, &$form_state, &$options = array()) { + public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = array()) { // filter trash out of the options so we don't store giant unnecessary arrays $options['roles'] = array_filter($options['roles']); } diff --git a/core/modules/user/src/Plugin/views/argument_validator/UserName.php b/core/modules/user/src/Plugin/views/argument_validator/UserName.php index daf50b3cff03c4de89193acb981f70e17b50c7e3..057389b7de6c1d7f4994f57bd9374fd82907202f 100644 --- a/core/modules/user/src/Plugin/views/argument_validator/UserName.php +++ b/core/modules/user/src/Plugin/views/argument_validator/UserName.php @@ -7,6 +7,8 @@ namespace Drupal\user\Plugin\views\argument_validator; +use Drupal\Core\Form\FormStateInterface; + /** * Validates whether a user name is valid. * @@ -21,7 +23,7 @@ class UserName extends User { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $entity_type = $this->entityManager->getDefinition('user'); diff --git a/core/modules/user/src/Plugin/views/field/Link.php b/core/modules/user/src/Plugin/views/field/Link.php index 1300de5cddf3a16f8bdd67a3318cc701e1581b6c..40ff364ed1ccee2c4935dbbf2441fb0ba073c365 100644 --- a/core/modules/user/src/Plugin/views/field/Link.php +++ b/core/modules/user/src/Plugin/views/field/Link.php @@ -7,6 +7,7 @@ namespace Drupal\user\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -45,7 +46,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['text'] = array( '#type' => 'textfield', '#title' => t('Text to display'), diff --git a/core/modules/user/src/Plugin/views/field/Mail.php b/core/modules/user/src/Plugin/views/field/Mail.php index 290852642e969f092c6baa5a9e350fb07b47c461..ad26317ceaf386e3a49069447f859ad1363f1d3b 100644 --- a/core/modules/user/src/Plugin/views/field/Mail.php +++ b/core/modules/user/src/Plugin/views/field/Mail.php @@ -7,6 +7,7 @@ namespace Drupal\user\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -24,7 +25,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['link_to_user'] = array( '#title' => t('Link this field'), diff --git a/core/modules/user/src/Plugin/views/field/Name.php b/core/modules/user/src/Plugin/views/field/Name.php index fa924d748cd23db5e9e88020c909916939c5c4d6..5396bc601943798d7cee29d486f42c5adc23baa9 100644 --- a/core/modules/user/src/Plugin/views/field/Name.php +++ b/core/modules/user/src/Plugin/views/field/Name.php @@ -8,6 +8,7 @@ namespace Drupal\user\Plugin\views\field; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\user\Plugin\views\field\User; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ResultRow; @@ -48,7 +49,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['format_username'] = array( diff --git a/core/modules/user/src/Plugin/views/field/User.php b/core/modules/user/src/Plugin/views/field/User.php index ef04e9c852d4f6aba4e7a57395e20ad9a97d6f23..d49c7e1fea97919c1231ebb3adb4ff5117fe13e3 100644 --- a/core/modules/user/src/Plugin/views/field/User.php +++ b/core/modules/user/src/Plugin/views/field/User.php @@ -7,6 +7,7 @@ namespace Drupal\user\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ResultRow; @@ -41,7 +42,7 @@ protected function defineOptions() { /** * Provide link to node option */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['link_to_user'] = array( '#title' => t('Link this field to its user'), '#description' => t("Enable to override this field's links."), diff --git a/core/modules/user/src/Plugin/views/field/UserBulkForm.php b/core/modules/user/src/Plugin/views/field/UserBulkForm.php index 3811eaecd5548c1569fec92c9e8529280ce1ba54..943cd9bdab77e05619d0f55ebca42a2cd40627ea 100644 --- a/core/modules/user/src/Plugin/views/field/UserBulkForm.php +++ b/core/modules/user/src/Plugin/views/field/UserBulkForm.php @@ -8,6 +8,7 @@ namespace Drupal\user\Plugin\views\field; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\system\Plugin\views\field\BulkForm; use Drupal\user\UserInterface; @@ -23,7 +24,7 @@ class UserBulkForm extends BulkForm { * * Provide a more useful title to improve the accessibility. */ - public function viewsForm(&$form, &$form_state) { + public function viewsForm(&$form, FormStateInterface $form_state) { parent::viewsForm($form, $form_state); if (!empty($this->view->result)) { diff --git a/core/modules/user/src/Plugin/views/field/UserData.php b/core/modules/user/src/Plugin/views/field/UserData.php index b58c3fce389506cf2ef6dfd9aa0dcaefb84787c1..cb9f35b8998dadfcc9ecafdbe5357b1569164fe5 100644 --- a/core/modules/user/src/Plugin/views/field/UserData.php +++ b/core/modules/user/src/Plugin/views/field/UserData.php @@ -7,6 +7,7 @@ namespace Drupal\user\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; @@ -63,7 +64,7 @@ protected function defineOptions() { /** * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::defineOptions(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $modules = system_get_info('module'); diff --git a/core/modules/user/src/Plugin/views/filter/Name.php b/core/modules/user/src/Plugin/views/filter/Name.php index 0d1b5fc66292a8f1e62abb619600a71aa7e8cb7a..8bdb0016f8f18d08cf87c2578384409219ad06ce 100644 --- a/core/modules/user/src/Plugin/views/filter/Name.php +++ b/core/modules/user/src/Plugin/views/filter/Name.php @@ -8,6 +8,7 @@ namespace Drupal\user\Plugin\views\filter; use Drupal\Component\Utility\Tags; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\filter\InOperator; /** @@ -21,7 +22,7 @@ class Name extends InOperator { protected $alwaysMultiple = TRUE; - protected function valueForm(&$form, &$form_state) { + protected function valueForm(&$form, FormStateInterface $form_state) { $values = array(); if ($this->value) { $result = entity_load_multiple_by_properties('user', array('uid' => $this->value)); @@ -50,7 +51,7 @@ protected function valueForm(&$form, &$form_state) { } } - protected function valueValidate($form, &$form_state) { + protected function valueValidate($form, FormStateInterface $form_state) { $values = Tags::explode($form_state['values']['options']['value']); $uids = $this->validate_user_strings($form['value'], $form_state, $values); @@ -72,7 +73,7 @@ public function acceptExposedInput($input) { return $rc; } - public function validateExposed(&$form, &$form_state) { + public function validateExposed(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed'])) { return; } @@ -108,7 +109,7 @@ public function validateExposed(&$form, &$form_state) { * or the exposed filter, this is abstracted out a bit so it can * handle the multiple input sources. */ - function validate_user_strings(&$form, array &$form_state, $values) { + function validate_user_strings(&$form, FormStateInterface $form_state, $values) { $uids = array(); $placeholders = array(); $args = array(); @@ -140,7 +141,7 @@ function validate_user_strings(&$form, array &$form_state, $values) { return $uids; } - protected function valueSubmit($form, &$form_state) { + protected function valueSubmit($form, FormStateInterface $form_state) { // prevent array filter from removing our anonymous user. } diff --git a/core/modules/user/src/ProfileForm.php b/core/modules/user/src/ProfileForm.php index fbe7665f5e12a0c45437dcd26b2ac9842c20bb65..c7c74c5b8b38203d57be8ba96bea1261ee9460ed 100644 --- a/core/modules/user/src/ProfileForm.php +++ b/core/modules/user/src/ProfileForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManager; /** @@ -26,7 +27,7 @@ public function __construct(EntityManagerInterface $entity_manager, LanguageMana /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $element = parent::actions($form, $form_state); // The user account being edited. @@ -45,7 +46,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $account = $this->entity; $account->save(); $form_state['values']['uid'] = $account->id(); @@ -56,7 +57,7 @@ public function save(array $form, array &$form_state) { /** * Provides a submit handler for the 'Cancel account' button. */ - public function editCancelSubmit($form, &$form_state) { + public function editCancelSubmit($form, FormStateInterface $form_state) { $destination = array(); $query = $this->getRequest()->query; if ($query->has('destination')) { diff --git a/core/modules/user/src/ProfileTranslationHandler.php b/core/modules/user/src/ProfileTranslationHandler.php index c332d83500df4f82d845e709d2b1d5d7043109e7..fd9c90b1cde4577b6993aae1ecc09d040a657590 100644 --- a/core/modules/user/src/ProfileTranslationHandler.php +++ b/core/modules/user/src/ProfileTranslationHandler.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\content_translation\ContentTranslationHandler; +use Drupal\Core\Form\FormStateInterface; /** * Defines the translation handler for users. @@ -18,7 +19,7 @@ class ProfileTranslationHandler extends ContentTranslationHandler { /** * {@inheritdoc} */ - public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { + public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) { parent::entityFormAlter($form, $form_state, $entity); $form['actions']['submit']['#submit'][] = array($this, 'entityFormSave'); } @@ -30,7 +31,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac * * @see \Drupal\Core\Entity\EntityForm::build(). */ - function entityFormSave(array $form, array &$form_state) { + function entityFormSave(array $form, FormStateInterface $form_state) { if ($this->getSourceLangcode($form_state)) { $entity = content_translation_form_controller($form_state)->getEntity(); // We need a redirect here, otherwise we would get an access denied page diff --git a/core/modules/user/src/RegisterForm.php b/core/modules/user/src/RegisterForm.php index ddbbcc051e0b877d00b5557da87d87190f54b4a0..f3f251125fb97d06739986a2d8e4665691bc71bf 100644 --- a/core/modules/user/src/RegisterForm.php +++ b/core/modules/user/src/RegisterForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManager; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -25,9 +26,9 @@ public function __construct(EntityManagerInterface $entity_manager, LanguageMana } /** - * Overrides Drupal\Core\Entity\EntityForm::form(). + * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $user = $this->currentUser(); /** @var \Drupal\user\UserInterface $account */ $account = $this->entity; @@ -71,7 +72,7 @@ public function form(array $form, array &$form_state) { /** * Overrides Drupal\Core\Entity\EntityForm::actions(). */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $element = parent::actions($form, $form_state); $element['submit']['#value'] = $this->t('Create new account'); return $element; @@ -80,7 +81,7 @@ protected function actions(array $form, array &$form_state) { /** * Overrides Drupal\Core\Entity\EntityForm::submit(). */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $admin = $form_state['values']['administer_users']; if (!\Drupal::config('user.settings')->get('verify_mail') || $admin) { @@ -102,7 +103,7 @@ public function submit(array $form, array &$form_state) { /** * Overrides Drupal\Core\Entity\EntityForm::submit(). */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $account = $this->entity; $pass = $account->getPassword(); $admin = $form_state['values']['administer_users']; diff --git a/core/modules/user/src/RoleForm.php b/core/modules/user/src/RoleForm.php index 1961a758d29ac61e87f9522dc747a91e5b665601..0587041080a8d154558347c75fb2af8a2ce97f73 100644 --- a/core/modules/user/src/RoleForm.php +++ b/core/modules/user/src/RoleForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityForm; +use Drupal\Core\Form\FormStateInterface; /** * Form controller for the role entity edit forms. @@ -18,7 +19,7 @@ class RoleForm extends EntityForm { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $entity = $this->entity; $form['label'] = array( '#type' => 'textfield', @@ -51,7 +52,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function save(array $form, array &$form_state) { + public function save(array $form, FormStateInterface $form_state) { $entity = $this->entity; // Prevent leading and trailing spaces in role names. diff --git a/core/modules/user/src/RoleListBuilder.php b/core/modules/user/src/RoleListBuilder.php index afe8d7b0771a3a3c8f9d0378272f5ac2bd2b3dc9..8e7feecb08e9c819ac05bdfa4bc44460ed92e72f 100644 --- a/core/modules/user/src/RoleListBuilder.php +++ b/core/modules/user/src/RoleListBuilder.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\Entity\DraggableListBuilder; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormStateInterface; /** * Defines a class to build a listing of user role entities. @@ -58,7 +59,7 @@ public function getDefaultOperations(EntityInterface $entity) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); drupal_set_message(t('The role settings have been updated.')); diff --git a/core/modules/user/src/Tests/UserAccountFormFieldsTest.php b/core/modules/user/src/Tests/UserAccountFormFieldsTest.php index b560a0c6c8771c65a59743c98d270853f60ff21f..47849b9edec9d79680edbe2b6d6ccfaa3027f493 100644 --- a/core/modules/user/src/Tests/UserAccountFormFieldsTest.php +++ b/core/modules/user/src/Tests/UserAccountFormFieldsTest.php @@ -7,6 +7,7 @@ namespace Drupal\user\Tests; +use Drupal\Core\Form\FormState; use Drupal\simpletest\DrupalUnitTestBase; /** @@ -30,7 +31,7 @@ class UserAccountFormFieldsTest extends DrupalUnitTestBase { function testInstallConfigureForm() { require_once DRUPAL_ROOT . '/core/includes/install.core.inc'; $install_state = install_state_defaults(); - $form_state = array(); + $form_state = new FormState(); $form_state['build_info']['args'][] = &$install_state; $form = $this->container->get('form_builder') ->buildForm('Drupal\Core\Installer\Form\SiteConfigureForm', $form_state); diff --git a/core/modules/user/src/Tests/Views/ArgumentValidateTest.php b/core/modules/user/src/Tests/Views/ArgumentValidateTest.php index f1e9c0eb35dd1497654d16cdcc67ae0fe832020c..04c8b0add9cc867b8d1d451573db973bfed7ebbf 100644 --- a/core/modules/user/src/Tests/Views/ArgumentValidateTest.php +++ b/core/modules/user/src/Tests/Views/ArgumentValidateTest.php @@ -7,6 +7,7 @@ namespace Drupal\user\Tests\Views; +use Drupal\Core\Form\FormState; use Drupal\views\Plugin\views\argument\ArgumentPluginBase; use Drupal\views\Views; @@ -45,7 +46,8 @@ function testArgumentValidateUserUid() { // Fail for a valid numeric, but for a user that doesn't exist $this->assertFalse($view->argument['null']->validateArgument(32)); - $form = $form_state = array(); + $form = array(); + $form_state = new FormState(); $view->argument['null']->buildOptionsForm($form, $form_state); $sanitized_id = ArgumentPluginBase::encodeValidatorId('entity:user'); $this->assertTrue($form['validate']['options'][$sanitized_id]['roles']['#states']['visible'][':input[name="options[validate][options][' . $sanitized_id . '][restrict_roles]"]']['checked']); diff --git a/core/modules/user/tests/modules/user_form_test/src/Form/TestCurrentPassword.php b/core/modules/user/tests/modules/user_form_test/src/Form/TestCurrentPassword.php index 1acbea5b8067786c369ca2e1a73791778987409d..b01fc79f23afbb50f279d9b3f8e8724ad7bdd2dd 100644 --- a/core/modules/user/tests/modules/user_form_test/src/Form/TestCurrentPassword.php +++ b/core/modules/user/tests/modules/user_form_test/src/Form/TestCurrentPassword.php @@ -8,6 +8,7 @@ namespace Drupal\user_form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\user\UserInterface; /** @@ -28,7 +29,7 @@ public function getFormId() { * @param \Drupal\user\Entity\UserInterface $user * The user account. */ - public function buildForm(array $form, array &$form_state, UserInterface $user = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, UserInterface $user = NULL) { $form_state['user'] = $user ; $form['user_form_test_field'] = array( '#type' => 'textfield', @@ -60,7 +61,7 @@ public function buildForm(array $form, array &$form_state, UserInterface $user = /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The password has been validated and the form submitted successfully.')); } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 0b3d45311d793bdb852775cae064d832c4223e91..c23cc2ca3fac26c403eede8ea447aee01056de27 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -4,6 +4,7 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AnonymousUserSession; @@ -482,7 +483,7 @@ function user_user_view(array &$build, UserInterface $account, EntityViewDisplay /** * Sets the value of the user register and profile forms' langcode element. */ -function _user_language_selector_langcode_value($element, $input, &$form_state) { +function _user_language_selector_langcode_value($element, $input, FormStateInterface $form_state) { // Only add to the description if the form element have a description. if (isset($form_state['complete_form']['language']['preferred_langcode']['#description'])) { $form_state['complete_form']['language']['preferred_langcode']['#description'] .= ' ' . t("This is also assumed to be the primary language of this account's profile information."); @@ -495,7 +496,7 @@ function _user_language_selector_langcode_value($element, $input, &$form_state) * * @see AccountForm::form() */ -function user_validate_current_pass(&$form, &$form_state) { +function user_validate_current_pass(&$form, FormStateInterface $form_state) { $account = $form_state['user']; foreach ($form_state['values']['current_pass_required_values'] as $key => $name) { // This validation only works for required textfields (like mail) or diff --git a/core/modules/views/includes/ajax.inc b/core/modules/views/includes/ajax.inc index 84c33ebe8f3a00fa46c87c930b0fec351bfaafe3..59308567365a53cb47dabc62e44bdc11a04c5c06 100644 --- a/core/modules/views/includes/ajax.inc +++ b/core/modules/views/includes/ajax.inc @@ -5,6 +5,7 @@ * Handles the server side AJAX interactions of Views. */ +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Ajax\HighlightCommand; use Drupal\Core\Ajax\OpenModalDialogCommand; use Drupal\Core\Ajax\AjaxResponse; @@ -14,16 +15,14 @@ * some AJAX stuff automatically. * This makes some assumptions about the client. */ -function views_ajax_form_wrapper($form_class, &$form_state) { +function views_ajax_form_wrapper($form_class, FormStateInterface &$form_state) { // This won't override settings already in. - $form_state += array( - 'rerender' => FALSE, - 'no_redirect' => !empty($form_state['ajax']), - 'no_cache' => TRUE, - 'build_info' => array( - 'args' => array(), - ), - ); + $form_state->setIfNotExists('rerender', FALSE); + $form_state->setIfNotExists('no_redirect', !empty($form_state['ajax'])); + $form_state->setIfNotExists('no_cache', TRUE); + $form_state->setIfNotExists('build_info', array( + 'args' => array(), + )); $form = \Drupal::formBuilder()->buildForm($form_class, $form_state); $output = drupal_render($form); diff --git a/core/modules/views/src/Form/ViewsExposedForm.php b/core/modules/views/src/Form/ViewsExposedForm.php index ae3da03e4b2943a36bece76c69adb98aa80acb10..2c78f5f2be5d27ad3e8412e8d136fe4dcf4987a6 100644 --- a/core/modules/views/src/Form/ViewsExposedForm.php +++ b/core/modules/views/src/Form/ViewsExposedForm.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ExposedFormCache; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -51,7 +52,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { // Don't show the form when batch operations are in progress. if ($batch = batch_get() && isset($batch['current_set'])) { return array( @@ -131,7 +132,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { foreach (array('field', 'filter') as $type) { /** @var \Drupal\views\Plugin\views\HandlerBase[] $handlers */ $handlers = &$form_state['view']->$type; @@ -147,7 +148,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { foreach (array('field', 'filter') as $type) { /** @var \Drupal\views\Plugin\views\HandlerBase[] $handlers */ $handlers = &$form_state['view']->$type; diff --git a/core/modules/views/src/Form/ViewsForm.php b/core/modules/views/src/Form/ViewsForm.php index 02bf7cb3fc8fba14fbfd76db3540e71af35fcc65..ac88a11ac0c5f20ae407d162fabfd5ef3d7170fb 100644 --- a/core/modules/views/src/Form/ViewsForm.php +++ b/core/modules/views/src/Form/ViewsForm.php @@ -13,6 +13,7 @@ use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\views\ViewExecutable; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -115,7 +116,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, ViewExecutable $view = NULL, $output = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, ViewExecutable $view = NULL, $output = NULL) { $form_state['step'] = isset($form_state['step']) ? $form_state['step'] : 'views_form_views_form'; $form_state['step_controller']['views_form_views_form'] = 'Drupal\views\Form\ViewsFormMainForm'; @@ -146,7 +147,7 @@ public function buildForm(array $form, array &$form_state, ViewExecutable $view /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $form_object = $this->getFormObject($form_state); $form_object->validateForm($form, $form_state); } @@ -154,7 +155,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_object = $this->getFormObject($form_state); $form_object->submitForm($form, $form_state); } @@ -162,13 +163,13 @@ public function submitForm(array &$form, array &$form_state) { /** * Returns the object used to build the step form. * - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The form_state of the current form. * * @return \Drupal\Core\Form\FormInterface * The form object to use. */ - protected function getFormObject(array $form_state) { + protected function getFormObject($form_state) { // If this is a class, instantiate it. $form_step_class = isset($form_state['step_controller'][$form_state['step']]) ? $form_state['step_controller'][$form_state['step']] : 'Drupal\views\Form\ViewsFormMainForm'; return $this->classResolver->getInstanceFromDefinition($form_step_class); diff --git a/core/modules/views/src/Form/ViewsFormMainForm.php b/core/modules/views/src/Form/ViewsFormMainForm.php index 98cdc4f97f7ac45f0c3ddaf88819428cb3fe194c..6c48b7e38b7aa6a69ed3b73d4ec03018b2e6a25c 100644 --- a/core/modules/views/src/Form/ViewsFormMainForm.php +++ b/core/modules/views/src/Form/ViewsFormMainForm.php @@ -8,6 +8,7 @@ namespace Drupal\views\Form; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; class ViewsFormMainForm implements FormInterface { @@ -21,7 +22,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, ViewExecutable $view = NULL, $output = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, ViewExecutable $view = NULL, $output = NULL) { $form['#prefix'] = '
'; $form['#suffix'] = '
'; $form['#theme'] = 'form'; @@ -106,7 +107,7 @@ public function buildForm(array $form, array &$form_state, ViewExecutable $view /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $view = $form_state['build_info']['args'][0]; // Call the validation method on every field handler that has it. @@ -129,7 +130,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $view = $form_state['build_info']['args'][0]; // Call the submit method on every field handler that has it. diff --git a/core/modules/views/src/ManyToOneHelper.php b/core/modules/views/src/ManyToOneHelper.php index 4c4d2ae60336f65804e0928916f31be900c18a32..12bfc35585b51efc8fc62f58273a3e7b0544b852 100644 --- a/core/modules/views/src/ManyToOneHelper.php +++ b/core/modules/views/src/ManyToOneHelper.php @@ -7,6 +7,7 @@ namespace Drupal\views; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\HandlerBase; /** @@ -33,7 +34,7 @@ public static function defineOptions(&$options) { $options['reduce_duplicates'] = array('default' => FALSE, 'bool' => TRUE); } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['reduce_duplicates'] = array( '#type' => 'checkbox', '#title' => t('Reduce duplicates'), diff --git a/core/modules/views/src/Plugin/Block/ViewsBlock.php b/core/modules/views/src/Plugin/Block/ViewsBlock.php index a80aa97b20bcc6a7da77bcb23e68f0cd918ff7d7..9e5bc99c97c787082b5ff3a7d909ca07909ab6de 100644 --- a/core/modules/views/src/Plugin/Block/ViewsBlock.php +++ b/core/modules/views/src/Plugin/Block/ViewsBlock.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\Entity\Query\Query; use Drupal\Component\Utility\Xss; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -78,7 +79,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function blockForm($form, &$form_state) { + public function blockForm($form, FormStateInterface $form_state) { if ($this->displaySet) { return $this->view->display_handler->blockForm($this, $form, $form_state); } @@ -89,7 +90,7 @@ public function blockForm($form, &$form_state) { /** * {@inheritdoc} */ - public function blockValidate($form, &$form_state) { + public function blockValidate($form, FormStateInterface $form_state) { if ($this->displaySet) { $this->view->display_handler->blockValidate($this, $form, $form_state); } @@ -98,7 +99,7 @@ public function blockValidate($form, &$form_state) { /** * {@inheritdoc} */ - public function blockSubmit($form, &$form_state) { + public function blockSubmit($form, FormStateInterface $form_state) { parent::blockSubmit($form, $form_state); if ($this->displaySet) { $this->view->display_handler->blockSubmit($this, $form, $form_state); diff --git a/core/modules/views/src/Plugin/Block/ViewsBlockBase.php b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php index 5a63e76635eb4560c09b9e0ea8b56598cfbfb829..1d4dd9826d9a359fa4684a308553de26768f0b00 100644 --- a/core/modules/views/src/Plugin/Block/ViewsBlockBase.php +++ b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\Block; use Drupal\block\BlockBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\views\ViewExecutableFactory; use Drupal\Core\Entity\EntityStorageInterface; @@ -105,7 +106,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); // Set the default label to '' so the views internal title is used. @@ -163,7 +164,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function blockSubmit($form, &$form_state) { + public function blockSubmit($form, FormStateInterface $form_state) { if (!empty($form_state['values']['views_label_checkbox'])) { $this->configuration['views_label'] = $form_state['values']['views_label']; } diff --git a/core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php b/core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php index d97b204ff5b524a0a13908b73a6845a21da75923..e1dc0033a7b718781ea5de4c6d739993f0e91ab9 100644 --- a/core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php +++ b/core/modules/views/src/Plugin/Menu/Form/ViewsMenuLinkForm.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\Menu\Form; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Menu\Form\MenuLinkDefaultForm; /** @@ -29,7 +30,7 @@ class ViewsMenuLinkForm extends MenuLinkDefaultForm { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { // Put the title field first. $form['title'] = array( @@ -72,7 +73,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function extractFormValues(array &$form, array &$form_state) { + public function extractFormValues(array &$form, FormStateInterface $form_state) { $definition = parent::extractFormValues($form, $form_state); $definition['title'] = $form_state['values']['title']; $definition['description'] = $form_state['values']['description']; diff --git a/core/modules/views/src/Plugin/entity_reference/selection/ViewsSelection.php b/core/modules/views/src/Plugin/entity_reference/selection/ViewsSelection.php index aa84db2ba9fb4f1376eeb3ff42bf50e42e980283..aa8294ab50ce7e7ec540f1c4cff4e407d13c7e2e 100644 --- a/core/modules/views/src/Plugin/entity_reference/selection/ViewsSelection.php +++ b/core/modules/views/src/Plugin/entity_reference/selection/ViewsSelection.php @@ -10,6 +10,7 @@ use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\entity_reference\Plugin\Type\Selection\SelectionInterface; use Drupal\views\Views; @@ -203,7 +204,7 @@ public function validateReferenceableEntities(array $ids) { /** * {@inheritdoc} */ - public function validateAutocompleteInput($input, &$element, &$form_state, $form, $strict = TRUE) { + public function validateAutocompleteInput($input, &$element, FormStateInterface $form_state, $form, $strict = TRUE) { return NULL; } @@ -215,7 +216,7 @@ public function entityQueryAlter(SelectInterface $query) {} /** * Element validate; Check View is valid. */ - public function settingsFormValidate($element, &$form_state, $form) { + public function settingsFormValidate($element, FormStateInterface $form_state, $form) { // Split view name and display name from the 'view_and_display' value. if (!empty($element['view_and_display']['#value'])) { list($view, $display) = explode(':', $element['view_and_display']['#value']); diff --git a/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php b/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php index 2135813bbe49bf81c0d99630c63740ea9edf07b4..4bd99483ad6c362fda80b061d69a07b031837326 100644 --- a/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php +++ b/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views; +use Drupal\Core\Form\FormStateInterface; + /** * A Trait for Views broken handlers. */ @@ -55,7 +57,7 @@ public function query($group_by = FALSE) { * * @see \Drupal\views\Plugin\views\PluginBase::defineOptions(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $description_top = t('The handler for this item is broken or missing. The following details are available:'); $items = array( diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php index e53cf7541968b37a256bbbc9c14773d5f861fba1..368b4aceb4452cc386e8fbd21b9906964cbf3b82 100644 --- a/core/modules/views/src/Plugin/views/HandlerBase.php +++ b/core/modules/views/src/Plugin/views/HandlerBase.php @@ -12,6 +12,7 @@ use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\Xss; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Session\AccountInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -278,7 +279,7 @@ protected function caseTransform($string, $option) { /** * Build the options form. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { // Some form elements belong in a fieldset for presentation, but can't // be moved into one because of the form_state['values'] hierarchy. Those // elements can add a #fieldset => 'fieldset_name' property, and they'll @@ -349,7 +350,7 @@ public function usesGroupBy() { /** * Provide a form for aggregation settings. */ - public function buildGroupByForm(&$form, &$form_state) { + public function buildGroupByForm(&$form, FormStateInterface $form_state) { $display_id = $form_state['display_id']; $type = $form_state['type']; $id = $form_state['id']; @@ -375,7 +376,7 @@ public function buildGroupByForm(&$form, &$form_state) { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - public function submitGroupByForm(&$form, &$form_state) { + public function submitGroupByForm(&$form, FormStateInterface $form_state) { $form_state['handler']->options['group_type'] = $form_state['values']['options']['group_type']; } @@ -393,18 +394,18 @@ public function defineExtraOptions(&$option) { } /** * Provide a form for setting options. */ - public function buildExtraOptionsForm(&$form, &$form_state) { } + public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) { } /** * Validate the options form. */ - public function validateExtraOptionsForm($form, &$form_state) { } + public function validateExtraOptionsForm($form, FormStateInterface $form_state) { } /** * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - public function submitExtraOptionsForm($form, &$form_state) { } + public function submitExtraOptionsForm($form, FormStateInterface $form_state) { } /** * Determine if a handler can be exposed. @@ -425,43 +426,43 @@ public function exposedInfo() { } /** * Render our chunk of the exposed handler form when selecting */ - public function buildExposedForm(&$form, &$form_state) { } + public function buildExposedForm(&$form, FormStateInterface $form_state) { } /** * Validate the exposed handler form */ - public function validateExposed(&$form, &$form_state) { } + public function validateExposed(&$form, FormStateInterface $form_state) { } /** * Submit the exposed handler form */ - public function submitExposed(&$form, &$form_state) { } + public function submitExposed(&$form, FormStateInterface $form_state) { } /** * Form for exposed handler options. */ - public function buildExposeForm(&$form, &$form_state) { } + public function buildExposeForm(&$form, FormStateInterface $form_state) { } /** * Validate the options form. */ - public function validateExposeForm($form, &$form_state) { } + public function validateExposeForm($form, FormStateInterface $form_state) { } /** * Perform any necessary changes to the form exposes prior to storage. * There is no need for this function to actually store the data. */ - public function submitExposeForm($form, &$form_state) { } + public function submitExposeForm($form, FormStateInterface $form_state) { } /** * Shortcut to display the expose/hide button. */ - public function showExposeButton(&$form, &$form_state) { } + public function showExposeButton(&$form, FormStateInterface $form_state) { } /** * Shortcut to display the exposed options form. */ - public function showExposeForm(&$form, &$form_state) { + public function showExposeForm(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed'])) { return; } @@ -887,7 +888,7 @@ public static function breakPhraseString($str, &$handler = NULL) { /** * Displays the Expose form. */ - public function displayExposedForm($form, &$form_state) { + public function displayExposedForm($form, FormStateInterface $form_state) { $item = &$this->options; // flip $item['exposed'] = empty($item['exposed']); @@ -911,7 +912,7 @@ public function displayExposedForm($form, &$form_state) { * A submit handler that is used for storing temporary items when using * multi-step changes, such as ajax requests. */ - public function submitTemporaryForm($form, &$form_state) { + public function submitTemporaryForm($form, FormStateInterface $form_state) { // Run it through the handler's submit function. $this->submitOptionsForm($form['options'], $form_state); $item = $this->options; diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index f19520aef96ac5a471aa4e7598ac26c4a2ccded1..c2a4869401747e75549e342bb1160f143119686f 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginBase as ComponentPluginBase; use Drupal\Core\Render\Element; @@ -216,7 +217,7 @@ public function destroy() { /** * Provide a form to edit options for this plugin. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { // Some form elements belong in a fieldset for presentation, but can't // be moved into one because of the form_state['values'] hierarchy. Those // elements can add a #fieldset => 'fieldset_name' property, and they'll @@ -227,12 +228,12 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Validate the options form. */ - public function validateOptionsForm(&$form, &$form_state) { } + public function validateOptionsForm(&$form, FormStateInterface $form_state) { } /** * Handle any special handling on the validate form. */ - public function submitOptionsForm(&$form, &$form_state) { } + public function submitOptionsForm(&$form, FormStateInterface $form_state) { } /** * Add anything to the query that we might need to. @@ -336,10 +337,10 @@ public function getAvailableGlobalTokens($prepared = FALSE, array $types = array * * @param array $form * The form array to alter, passed by reference. - * @param array $form_state - * The form state array to alter, passed by reference. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function globalTokenForm(&$form, &$form_state) { + public function globalTokenForm(&$form, FormStateInterface $form_state) { $token_items = array(); foreach ($this->getAvailableGlobalTokens() as $type => $tokens) { diff --git a/core/modules/views/src/Plugin/views/area/AreaPluginBase.php b/core/modules/views/src/Plugin/views/area/AreaPluginBase.php index 12d1a488d1810df7cff418966b51f42d9df456ae..54a11bf4212f0f6877eba3035f6033b8efa8b64f 100644 --- a/core/modules/views/src/Plugin/views/area/AreaPluginBase.php +++ b/core/modules/views/src/Plugin/views/area/AreaPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\area; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\HandlerBase; @@ -81,7 +82,7 @@ public function adminSummary() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); if ($form_state['type'] != 'empty') { diff --git a/core/modules/views/src/Plugin/views/area/Entity.php b/core/modules/views/src/Plugin/views/area/Entity.php index f762c0350b7b2820535ff150de0b025427d290c4..1cb3f1e1642419b379e49a63bd4c13da7e802b8f 100644 --- a/core/modules/views/src/Plugin/views/area/Entity.php +++ b/core/modules/views/src/Plugin/views/area/Entity.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\area; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; @@ -54,7 +55,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['view_mode'] = array( diff --git a/core/modules/views/src/Plugin/views/area/HTTPStatusCode.php b/core/modules/views/src/Plugin/views/area/HTTPStatusCode.php index 11181694387f712478b174fbb0534d92085df80a..79d395e674d9d53a0dedf18748e8ae903b651f9e 100644 --- a/core/modules/views/src/Plugin/views/area/HTTPStatusCode.php +++ b/core/modules/views/src/Plugin/views/area/HTTPStatusCode.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\area; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\Response; /** @@ -32,7 +33,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Get all possible status codes defined by symfony. diff --git a/core/modules/views/src/Plugin/views/area/Result.php b/core/modules/views/src/Plugin/views/area/Result.php index c675ed68f1d03ad4bcc827eb72fe74f44ae625dc..db596a701c176cd6088b1fe50b8f9b8772d6364c 100644 --- a/core/modules/views/src/Plugin/views/area/Result.php +++ b/core/modules/views/src/Plugin/views/area/Result.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Xss; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\style\DefaultSummary; /** @@ -37,7 +38,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $item_list = array( '#theme' => 'item_list', diff --git a/core/modules/views/src/Plugin/views/area/Text.php b/core/modules/views/src/Plugin/views/area/Text.php index de892106a9a7a70b040c03f8337deb6b1d006586..5a137c595b9bab95e856b55814b7d50f51f85dc5 100644 --- a/core/modules/views/src/Plugin/views/area/Text.php +++ b/core/modules/views/src/Plugin/views/area/Text.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\area; +use Drupal\Core\Form\FormStateInterface; + /** * Views area text handler. * @@ -29,7 +31,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['content'] = array( @@ -45,7 +47,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * {@inheritdoc} */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { $form_state['values']['options']['format'] = $form_state['values']['options']['content']['format']; $form_state['values']['options']['content'] = $form_state['values']['options']['content']['value']; parent::submitOptionsForm($form, $form_state); diff --git a/core/modules/views/src/Plugin/views/area/TextCustom.php b/core/modules/views/src/Plugin/views/area/TextCustom.php index fcd798cb6b94754a847f1848322bbd85f72ac0de..5f6a63dc78551a506a0b188147a5909723e62070 100644 --- a/core/modules/views/src/Plugin/views/area/TextCustom.php +++ b/core/modules/views/src/Plugin/views/area/TextCustom.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\area; +use Drupal\Core\Form\FormStateInterface; + /** * Views area text handler. * @@ -28,7 +30,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['content'] = array( diff --git a/core/modules/views/src/Plugin/views/area/Title.php b/core/modules/views/src/Plugin/views/area/Title.php index ef29f3f88ca10a84e27d349831294aa814d97d99..bf4eaa020e65f427f8b53a3acdec75ae02b36eb2 100644 --- a/core/modules/views/src/Plugin/views/area/Title.php +++ b/core/modules/views/src/Plugin/views/area/Title.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\area; +use Drupal\Core\Form\FormStateInterface; use \Drupal\Core\Utility\Title as UtilityTitle; /** @@ -30,7 +31,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['title'] = array( diff --git a/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php b/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php index 6f0add586d12679de8cdd33ad5cbd709706fb053..9cf0988fc56a922582901976f6ef9d2a5bf94021 100644 --- a/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php +++ b/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\area; +use Drupal\Core\Form\FormStateInterface; + /** * Tokenized base class for area handlers. * @@ -31,7 +33,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Add tokenization form elements. @@ -41,7 +43,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Adds tokenization form elements. */ - public function tokenForm(&$form, &$form_state) { + public function tokenForm(&$form, FormStateInterface $form_state) { $form['tokenize'] = array( '#type' => 'checkbox', '#title' => t('Use replacement tokens from the first row'), diff --git a/core/modules/views/src/Plugin/views/area/View.php b/core/modules/views/src/Plugin/views/area/View.php index a0ec5089162b9fab8d3ec6e68cde79f78c46db58..19650fe4cba2f7266cf4958bc87a4c96bdf241b0 100644 --- a/core/modules/views/src/Plugin/views/area/View.php +++ b/core/modules/views/src/Plugin/views/area/View.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\area; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Views; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -78,7 +79,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $view_display = $this->view->storage->id() . ':' . $this->view->current_display; diff --git a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php index a253a6bbb53acc5e0dd312fed7185d8c1a89ecff..3a8bf48250d9bb82cb427966b9ec5646ddfb83a3 100644 --- a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php +++ b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\argument; use Drupal\Component\Utility\String as UtilityString; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -150,7 +151,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $argument_text = $this->view->display_handler->getArgumentText(); @@ -343,7 +344,7 @@ public function buildOptionsForm(&$form, &$form_state) { ); } - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { if (empty($form_state['values']['options'])) { return; } @@ -372,7 +373,7 @@ public function validateOptionsForm(&$form, &$form_state) { } - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { if (empty($form_state['values']['options'])) { return; } @@ -473,7 +474,7 @@ protected function defaultActions($which = NULL) { * Provide a form for selecting the default argument when the * default action is set to provide default argument. */ - public function defaultArgumentForm(&$form, &$form_state) { + public function defaultArgumentForm(&$form, FormStateInterface $form_state) { $plugins = Views::pluginManager('argument_default')->getDefinitions(); $options = array(); @@ -538,7 +539,7 @@ public function defaultArgumentForm(&$form, &$form_state) { * Provide a form for selecting further summary options when the * default action is set to display one. */ - public function defaultSummaryForm(&$form, &$form_state) { + public function defaultSummaryForm(&$form, FormStateInterface $form_state) { $style_plugins = Views::pluginManager('style')->getDefinitions(); $summary_plugins = array(); $format_options = array(); diff --git a/core/modules/views/src/Plugin/views/argument/Date.php b/core/modules/views/src/Plugin/views/argument/Date.php index 67c005529b57953f53afb365025a54133f8190c6..3a3db7f01e345999e7c20ae147c5b79f4b1a101e 100644 --- a/core/modules/views/src/Plugin/views/argument/Date.php +++ b/core/modules/views/src/Plugin/views/argument/Date.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\argument; use Drupal\Core\Database\Database; +use Drupal\Core\Form\FormStateInterface; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -49,7 +50,7 @@ class Date extends Formula { /** * Add an option to set the default value to the current date. */ - public function defaultArgumentForm(&$form, &$form_state) { + public function defaultArgumentForm(&$form, FormStateInterface $form_state) { parent::defaultArgumentForm($form, $form_state); $form['default_argument_type']['#options'] += array('date' => $this->t('Current date')); $form['default_argument_type']['#options'] += array('node_created' => $this->t("Current node's creation time")); diff --git a/core/modules/views/src/Plugin/views/argument/ManyToOne.php b/core/modules/views/src/Plugin/views/argument/ManyToOne.php index 3180862a53922cc8b5055fd7198b24275a57e874..4e3042689230f06e61edaf72bc4e2b7f41630a7d 100644 --- a/core/modules/views/src/Plugin/views/argument/ManyToOne.php +++ b/core/modules/views/src/Plugin/views/argument/ManyToOne.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\argument; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ManyToOneHelper; @@ -62,7 +63,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // allow + for or, , for and diff --git a/core/modules/views/src/Plugin/views/argument/Null.php b/core/modules/views/src/Plugin/views/argument/Null.php index e4fdab61c73150fe567d0d904a9a13d79e1ba6ec..3c2e7582231bdf950adc11595becd39838fc564f 100644 --- a/core/modules/views/src/Plugin/views/argument/Null.php +++ b/core/modules/views/src/Plugin/views/argument/Null.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\argument; +use Drupal\Core\Form\FormStateInterface; + /** * Argument handler that ignores the argument. * @@ -26,7 +28,7 @@ protected function defineOptions() { * Override buildOptionsForm() so that only the relevant options * are displayed to the user. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['must_not_be'] = array( '#type' => 'checkbox', diff --git a/core/modules/views/src/Plugin/views/argument/Numeric.php b/core/modules/views/src/Plugin/views/argument/Numeric.php index 565b2850f4b688369cc3d3d99c777a06d90392aa..951ce654220c556bee45dcd36858b96234cd59fc 100644 --- a/core/modules/views/src/Plugin/views/argument/Numeric.php +++ b/core/modules/views/src/Plugin/views/argument/Numeric.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\argument; +use Drupal\Core\Form\FormStateInterface; + /** * Basic argument handler for arguments that are numeric. Incorporates * break_phrase. @@ -38,7 +40,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // allow + for or, , for and diff --git a/core/modules/views/src/Plugin/views/argument/String.php b/core/modules/views/src/Plugin/views/argument/String.php index b606de7f984661a6549c2d68eedf65c2cca31d92..3f92185b8092c9e8db74b03f87946dab24ce2fcb 100644 --- a/core/modules/views/src/Plugin/views/argument/String.php +++ b/core/modules/views/src/Plugin/views/argument/String.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\argument; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ManyToOneHelper; @@ -54,7 +55,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['glossary'] = array( diff --git a/core/modules/views/src/Plugin/views/argument_default/ArgumentDefaultPluginBase.php b/core/modules/views/src/Plugin/views/argument_default/ArgumentDefaultPluginBase.php index 500e64249894952819eebb56b0cef7cf2318e904..13330b32c81543da48b1189b86863a2be49ca17d 100644 --- a/core/modules/views/src/Plugin/views/argument_default/ArgumentDefaultPluginBase.php +++ b/core/modules/views/src/Plugin/views/argument_default/ArgumentDefaultPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\argument_default; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\argument\ArgumentPluginBase; use Drupal\views\Plugin\views\PluginBase; @@ -68,17 +69,17 @@ protected function defineOptions() { return array(); } /** * Provide the default form for setting options. */ - public function buildOptionsForm(&$form, &$form_state) { } + public function buildOptionsForm(&$form, FormStateInterface $form_state) { } /** * Provide the default form form for validating options */ - public function validateOptionsForm(&$form, &$form_state) { } + public function validateOptionsForm(&$form, FormStateInterface $form_state) { } /** * Provide the default form form for submitting options */ - public function submitOptionsForm(&$form, &$form_state, &$options = array()) { } + public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = array()) { } /** * Determine if the administrator has the privileges to use this diff --git a/core/modules/views/src/Plugin/views/argument_default/Fixed.php b/core/modules/views/src/Plugin/views/argument_default/Fixed.php index 4dcb180dc320cce0ceea291af3a3f32f5a433554..68f3d934ee692a61451ab0de2b2c534ff08a34ea 100644 --- a/core/modules/views/src/Plugin/views/argument_default/Fixed.php +++ b/core/modules/views/src/Plugin/views/argument_default/Fixed.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\argument_default; +use Drupal\Core\Form\FormStateInterface; + /** * The fixed argument default handler. * @@ -26,7 +28,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['argument'] = array( '#type' => 'textfield', diff --git a/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php b/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php index d8eb1ab3f9b840ee8688a8330ef5c34df5691127..82bf1fabeb1bfe6bcb8a8a17a8125bc3b618ec19 100644 --- a/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php +++ b/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\argument_default; +use Drupal\Core\Form\FormStateInterface; + /** * A query parameter argument default handler. * @@ -34,7 +36,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['query_param'] = array( '#type' => 'textfield', diff --git a/core/modules/views/src/Plugin/views/argument_default/Raw.php b/core/modules/views/src/Plugin/views/argument_default/Raw.php index afbd7af1a60eda5ed7bc9a62af36a036a4625077..022d0291a6ccdd41414d78d6fee946f3372d754a 100644 --- a/core/modules/views/src/Plugin/views/argument_default/Raw.php +++ b/core/modules/views/src/Plugin/views/argument_default/Raw.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\argument_default; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Path\AliasManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -68,7 +69,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['index'] = array( '#type' => 'select', diff --git a/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php b/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php index 655bc2aeab5fcc1f736d736d0bc983997702bf37..875c6fd7851a71d048ea1a52f1c9a6896271247c 100644 --- a/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php +++ b/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\argument_validator; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\argument\ArgumentPluginBase; use Drupal\views\Plugin\views\PluginBase; @@ -64,17 +65,17 @@ protected function defineOptions() { return array(); } /** * Provide the default form for setting options. */ - public function buildOptionsForm(&$form, &$form_state) { } + public function buildOptionsForm(&$form, FormStateInterface $form_state) { } /** * Provide the default form form for validating options */ - public function validateOptionsForm(&$form, &$form_state) { } + public function validateOptionsForm(&$form, FormStateInterface $form_state) { } /** * Provide the default form form for submitting options */ - public function submitOptionsForm(&$form, &$form_state, &$options = array()) { } + public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = array()) { } /** * Determine if the administrator has the privileges to use this plugin diff --git a/core/modules/views/src/Plugin/views/argument_validator/Entity.php b/core/modules/views/src/Plugin/views/argument_validator/Entity.php index a807cbc467f09f30fe8e7efebbbf02307879124c..fc5f8796df99dfc20641bd5f708f4e430eadf744 100644 --- a/core/modules/views/src/Plugin/views/argument_validator/Entity.php +++ b/core/modules/views/src/Plugin/views/argument_validator/Entity.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\argument\ArgumentPluginBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -85,7 +86,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $entity_type_id = $this->definition['entity_type']; @@ -149,7 +150,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * {@inheritdoc} */ - public function submitOptionsForm(&$form, &$form_state, &$options = array()) { + public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = array()) { // Filter out unused options so we don't store giant unnecessary arrays. $options['bundles'] = array_filter($options['bundles']); } diff --git a/core/modules/views/src/Plugin/views/cache/Time.php b/core/modules/views/src/Plugin/views/cache/Time.php index aa1194da6ffee02f51e05a200ea4b105295eb7a7..48fad3e5b5723f088bd934d9ba8be8428ecf3e7b 100644 --- a/core/modules/views/src/Plugin/views/cache/Time.php +++ b/core/modules/views/src/Plugin/views/cache/Time.php @@ -9,8 +9,8 @@ use Drupal\Core\Datetime\Date as DateFormatter; use Drupal\Core\Cache\Cache; -use Drupal\Core\Plugin\PluginBase; use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Form\FormStateInterface; /** * Simple caching of query results for Views displays. @@ -76,7 +76,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $options = array(60, 300, 1800, 3600, 21600, 518400); $options = array_map(array($this->dateFormatter, 'formatInterval'), array_combine($options, $options)); @@ -124,7 +124,7 @@ public function buildOptionsForm(&$form, &$form_state) { ); } - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { $custom_fields = array('output_lifespan', 'results_lifespan'); foreach ($custom_fields as $field) { if ($form_state['values']['cache_options'][$field] == 'custom' && !is_numeric($form_state['values']['cache_options'][$field . '_custom'])) { diff --git a/core/modules/views/src/Plugin/views/display/Attachment.php b/core/modules/views/src/Plugin/views/display/Attachment.php index 9673e55af1b7145d2dfed487d079221e488b6d53..1382933e56bd8f39390fee4b46a52c73c1909562 100644 --- a/core/modules/views/src/Plugin/views/display/Attachment.php +++ b/core/modules/views/src/Plugin/views/display/Attachment.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\display; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; /** @@ -140,7 +141,7 @@ public function optionsSummary(&$categories, &$options) { /** * Provide the default form for setting options. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { // It is very important to call the parent function here: parent::buildOptionsForm($form, $form_state); @@ -214,7 +215,7 @@ public function buildOptionsForm(&$form, &$form_state) { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { // It is very important to call the parent function here: parent::submitOptionsForm($form, $form_state); switch ($form_state['section']) { diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 8507f906575874d641eda452d68ee7d5b637b15b..b2245672a7d404c795b373a1c300885d7774cad5 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Cache\Cache; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Theme\Registry; @@ -1375,7 +1376,7 @@ public function optionsSummary(&$categories, &$options) { /** * Provide the default form for setting options. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); if ($this->defaultableSections($form_state['section'])) { views_ui_standard_display_dropdown($form, $form_state, $form_state['section']); @@ -1867,7 +1868,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Validate the options form. */ - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { switch ($form_state['section']) { case 'display_title': if (empty($form_state['values']['display_title'])) { @@ -1919,7 +1920,7 @@ public function validateOptionsForm(&$form, &$form_state) { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { // Not sure I like this being here, but it seems (?) like a logical place. $cache_plugin = $this->getPlugin('cache'); if ($cache_plugin) { @@ -2021,7 +2022,7 @@ public function submitOptionsForm(&$form, &$form_state) { /** * If override/revert was clicked, perform the proper toggle. */ - public function optionsOverride($form, &$form_state) { + public function optionsOverride($form, FormStateInterface $form_state) { $this->setOverride($form_state['section']); } diff --git a/core/modules/views/src/Plugin/views/display/Feed.php b/core/modules/views/src/Plugin/views/display/Feed.php index ed7a571a1fe031c7949376206b30a8cd20bcf2dc..a6e6fdda081e61c5826cfb80b62690a66bd5b5d9 100644 --- a/core/modules/views/src/Plugin/views/display/Feed.php +++ b/core/modules/views/src/Plugin/views/display/Feed.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\display; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Views; use Symfony\Component\HttpFoundation\Response; @@ -193,7 +194,7 @@ public function optionsSummary(&$categories, &$options) { /** * Overrides \Drupal\views\Plugin\views\display\PathPluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { // It is very important to call the parent function here. parent::buildOptionsForm($form, $form_state); @@ -239,7 +240,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::submitOptionsForm(). */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { parent::submitOptionsForm($form, $form_state); switch ($form_state['section']) { case 'title': diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php index 21a4de22dcdd15a39438a0c341afbc758bfa5953..ca099a2f293c01749f29a54a6c54feab2997a5f7 100644 --- a/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\display; use Drupal\Component\Utility\Xss; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -148,7 +149,7 @@ public function optionsSummary(&$categories, &$options) { /** * Overrides \Drupal\views\Plugin\views\display\callbackPluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); switch ($form_state['section']) { @@ -377,7 +378,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Overrides \Drupal\views\Plugin\views\display\callbackPluginBase::validateOptionsForm(). */ - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { parent::validateOptionsForm($form, $form_state); if ($form_state['section'] == 'menu') { @@ -403,7 +404,7 @@ public function validateOptionsForm(&$form, &$form_state) { /** * Overrides \Drupal\views\Plugin\views\display\callbackPluginBase::submitOptionsForm(). */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { parent::submitOptionsForm($form, $form_state); switch ($form_state['section']) { diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index 60f41ae6167b4723a2b171a587315ae4e5af0335..58c9cfaba2125ce86f27afeddad892d7bfdda944 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Access\AccessManagerInterface; use Drupal\Core\Form\FormErrorInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Routing\RouteCompiler; use Drupal\Core\Routing\RouteProviderInterface; @@ -387,7 +388,7 @@ public function optionsSummary(&$categories, &$options) { /** * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); switch ($form_state['section']) { @@ -411,7 +412,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::validateOptionsForm(). */ - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { parent::validateOptionsForm($form, $form_state); if ($form_state['section'] == 'path') { @@ -428,7 +429,7 @@ public function validateOptionsForm(&$form, &$form_state) { /** * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::submitOptionsForm(). */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { parent::submitOptionsForm($form, $form_state); if ($form_state['section'] == 'path') { diff --git a/core/modules/views/src/Plugin/views/display_extender/DisplayExtenderPluginBase.php b/core/modules/views/src/Plugin/views/display_extender/DisplayExtenderPluginBase.php index bbfdcd18197bd926d834a9ced1ded149d2216788..aebc61442156c0a72c76c1fe1ee66e6dc903ea41 100644 --- a/core/modules/views/src/Plugin/views/display_extender/DisplayExtenderPluginBase.php +++ b/core/modules/views/src/Plugin/views/display_extender/DisplayExtenderPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\display_extender; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\PluginBase; @@ -46,17 +47,17 @@ public function defineOptionsAlter(&$options) { } /** * Provide a form to edit options for this plugin. */ - public function buildOptionsForm(&$form, &$form_state) { } + public function buildOptionsForm(&$form, FormStateInterface $form_state) { } /** * Validate the options form. */ - public function validateOptionsForm(&$form, &$form_state) { } + public function validateOptionsForm(&$form, FormStateInterface $form_state) { } /** * Handle any special handling on the validate form. */ - public function submitOptionsForm(&$form, &$form_state) { } + public function submitOptionsForm(&$form, FormStateInterface $form_state) { } /** * Set up any variables on the view prior to execution. diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php index edaa44596f84d9eeef885f3150cfab3730677dd2..276a4dd2d0c75819ac60d613aae3ee019f78f575 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php @@ -8,6 +8,8 @@ namespace Drupal\views\Plugin\views\exposed_form; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormState; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Form\ViewsExposedForm; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -51,7 +53,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['submit_button'] = array( '#type' => 'textfield', @@ -127,14 +129,14 @@ public function buildOptionsForm(&$form, &$form_state) { */ public function renderExposedForm($block = FALSE) { // Deal with any exposed filters we may have, before building. - $form_state = array( + $form_state = new FormState(array( 'view' => &$this->view, 'display' => &$this->view->display_handler->display, 'method' => 'get', 'rerender' => TRUE, 'no_redirect' => TRUE, 'always_process' => TRUE, - ); + )); // Some types of displays (eg. attachments) may wish to use the exposed // filters of their parent displays instead of showing an additional @@ -199,7 +201,7 @@ public function postExecute() { } * @param $form_state * The form state. Passed by reference. */ - public function exposedFormAlter(&$form, &$form_state) { + public function exposedFormAlter(&$form, FormStateInterface $form_state) { if (!empty($this->options['submit_button'])) { $form['actions']['submit']['#value'] = $this->options['submit_button']; } @@ -274,7 +276,7 @@ public function exposedFormAlter(&$form, &$form_state) { } } - public function exposedFormValidate(&$form, &$form_state) { + public function exposedFormValidate(&$form, FormStateInterface $form_state) { if (isset($form_state['pager_plugin'])) { $form_state['pager_plugin']->exposedFormValidate($form, $form_state); } @@ -286,12 +288,12 @@ public function exposedFormValidate(&$form, &$form_state) { * @param $form * Nested array of form elements that comprise the form. * @param $form_state - * A keyed array containing the current state of the form. + * The current state of the form. * @param $exclude * Nested array of keys to exclude of insert into * $view->exposed_raw_input */ - public function exposedFormSubmit(&$form, &$form_state, &$exclude) { + public function exposedFormSubmit(&$form, FormStateInterface $form_state, &$exclude) { if (!empty($form_state['values']['op']) && $form_state['values']['op'] == $this->options['reset_button_label']) { $this->resetForm($form, $form_state); } @@ -301,7 +303,7 @@ public function exposedFormSubmit(&$form, &$form_state, &$exclude) { } } - public function resetForm(&$form, &$form_state) { + public function resetForm(&$form, FormStateInterface $form_state) { // _SESSION is not defined for users who are not logged in. // If filters are not overridden, store the 'remember' settings on the diff --git a/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php b/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php index 99f5ea49c29da1864c314ba3dac9760b933a3873..af186179d63d039392b799b6650124079c5ce757 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php +++ b/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\exposed_form; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Views; /** @@ -30,7 +31,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['text_input_required'] = array( @@ -43,7 +44,7 @@ public function buildOptionsForm(&$form, &$form_state) { ); } - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { $form_state['values']['exposed_form_options']['text_input_required_format'] = $form_state['values']['exposed_form_options']['text_input_required']['format']; $form_state['values']['exposed_form_options']['text_input_required'] = $form_state['values']['exposed_form_options']['text_input_required']['value']; parent::submitOptionsForm($form, $form_state); diff --git a/core/modules/views/src/Plugin/views/field/Boolean.php b/core/modules/views/src/Plugin/views/field/Boolean.php index cf4ef7798597a4f78f4ea9e66e85f58e97cf06fa..13b58580d03ec874a8cbfef08ce2a463b34741c1 100644 --- a/core/modules/views/src/Plugin/views/field/Boolean.php +++ b/core/modules/views/src/Plugin/views/field/Boolean.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\field; use Drupal\Component\Utility\Xss as UtilityXss; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -61,7 +62,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o $this->formats = array_merge($default_formats, $output_formats, $custom_format); } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { foreach ($this->formats as $key => $item) { $options[$key] = implode('/', $item); } diff --git a/core/modules/views/src/Plugin/views/field/Counter.php b/core/modules/views/src/Plugin/views/field/Counter.php index a8a4ffd6f134060a594d536b8823f0de4d9d7732..62b2580fa6f752e973c58725faee7849a706792b 100644 --- a/core/modules/views/src/Plugin/views/field/Counter.php +++ b/core/modules/views/src/Plugin/views/field/Counter.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -32,7 +33,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['counter_start'] = array( '#type' => 'textfield', '#title' => t('Starting value'), diff --git a/core/modules/views/src/Plugin/views/field/Custom.php b/core/modules/views/src/Plugin/views/field/Custom.php index e3c347abec7a566dfe7b5791eba9b52e4e1fa86d..14e7e24f33dbec29a67d6e656dc481a6dba63aaf 100644 --- a/core/modules/views/src/Plugin/views/field/Custom.php +++ b/core/modules/views/src/Plugin/views/field/Custom.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -38,7 +39,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Remove the checkbox diff --git a/core/modules/views/src/Plugin/views/field/Date.php b/core/modules/views/src/Plugin/views/field/Date.php index 9125f3e39c5c72aab880d6872291f8f4f8d91498..588867066b3d419ce1bd273e06415785658c314f 100644 --- a/core/modules/views/src/Plugin/views/field/Date.php +++ b/core/modules/views/src/Plugin/views/field/Date.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\field; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Datetime\Date as DateFormatter; @@ -79,7 +80,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $date_formats = array(); foreach ($this->dateFormatStorage->loadMultiple() as $machine_name => $value) { diff --git a/core/modules/views/src/Plugin/views/field/EntityLabel.php b/core/modules/views/src/Plugin/views/field/EntityLabel.php index 60ad43edec0b51595d5072a9e3aac2689a511639..376c497e9600302e7e1c52569000192c147fe2da 100644 --- a/core/modules/views/src/Plugin/views/field/EntityLabel.php +++ b/core/modules/views/src/Plugin/views/field/EntityLabel.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\field; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; @@ -85,7 +86,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['link_to_entity'] = array( '#title' => t('Link to entity'), '#description' => t('Make entity label a link to entity page.'), diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php index 615f852d5e437991de0a239bd0ef78839ec0dc5f..5acf50a2462eaab0fe3e0b1bec176740af988c7b 100644 --- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php +++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php @@ -12,6 +12,7 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\Xss; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\HandlerBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ResultRow; @@ -479,7 +480,7 @@ protected function defineOptions() { /** * Performs some cleanup tasks on the options array before saving it. */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { $options = &$form_state['values']['options']; $types = array('element_type', 'element_label_type', 'element_wrapper_type'); $classes = array_combine(array('element_class', 'element_label_class', 'element_wrapper_class'), $types); @@ -506,7 +507,7 @@ public function submitOptionsForm(&$form, &$form_state) { * Default options form that provides the label widget that all fields * should have. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $label = $this->label(); diff --git a/core/modules/views/src/Plugin/views/field/FileSize.php b/core/modules/views/src/Plugin/views/field/FileSize.php index e89a1a4474bbd4cba574de76fba23e958935eb0d..57bd1bbc195ae275d26c784fd4e5a490aacf252a 100644 --- a/core/modules/views/src/Plugin/views/field/FileSize.php +++ b/core/modules/views/src/Plugin/views/field/FileSize.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -26,7 +27,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['file_size_display'] = array( '#title' => t('File size display'), diff --git a/core/modules/views/src/Plugin/views/field/LanguageField.php b/core/modules/views/src/Plugin/views/field/LanguageField.php index 7c6c35c937e2abddc60e734057b5e053b56e02bc..3878e6cce518fc3c75bfcdb5a2eea76623c7eced 100644 --- a/core/modules/views/src/Plugin/views/field/LanguageField.php +++ b/core/modules/views/src/Plugin/views/field/LanguageField.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -25,7 +26,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['native_language'] = array( '#title' => t('Native language'), diff --git a/core/modules/views/src/Plugin/views/field/Links.php b/core/modules/views/src/Plugin/views/field/Links.php index f466bc601843cf0180eb8b1b80e1468b1fbff558..1d6a82acf906214160c00929078c70eafcd1b4d9 100644 --- a/core/modules/views/src/Plugin/views/field/Links.php +++ b/core/modules/views/src/Plugin/views/field/Links.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; + /** * A abstract handler which provides a collection of links. * @@ -36,7 +38,7 @@ public function defineOptions() { /** * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::defineOptions(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Only show fields that precede this one. $field_options = $this->getPreviousFieldLabels(); diff --git a/core/modules/views/src/Plugin/views/field/MachineName.php b/core/modules/views/src/Plugin/views/field/MachineName.php index e07da1f8abf3dba0e07625a961b41f2bf9a26d6c..4b3521b96e184e59fafaecf528376b62ded94ff4 100644 --- a/core/modules/views/src/Plugin/views/field/MachineName.php +++ b/core/modules/views/src/Plugin/views/field/MachineName.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\field; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -52,7 +53,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['machine_name'] = array( diff --git a/core/modules/views/src/Plugin/views/field/Numeric.php b/core/modules/views/src/Plugin/views/field/Numeric.php index 7a4c99451eceba66d9cc778bf98d15351744a75d..df9343b5ae8fc5397349e23302e252ba57bbbf84 100644 --- a/core/modules/views/src/Plugin/views/field/Numeric.php +++ b/core/modules/views/src/Plugin/views/field/Numeric.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -38,7 +39,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { if (!empty($this->definition['float'])) { $form['set_precision'] = array( '#type' => 'checkbox', diff --git a/core/modules/views/src/Plugin/views/field/PrerenderList.php b/core/modules/views/src/Plugin/views/field/PrerenderList.php index 4530423b0abad8c747ace446ff3990241bc48bbe..c309879c84dfd590cf1bc63febe29cb7cff2c855 100644 --- a/core/modules/views/src/Plugin/views/field/PrerenderList.php +++ b/core/modules/views/src/Plugin/views/field/PrerenderList.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; + /** * Field handler to provide a list of items. * @@ -40,7 +42,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['type'] = array( '#type' => 'radios', '#title' => t('Display type'), diff --git a/core/modules/views/src/Plugin/views/field/Serialized.php b/core/modules/views/src/Plugin/views/field/Serialized.php index aa933eb1027aeb8c32ae12a3a08cd61c618cfe24..5d8c27b867c4d756557540bec766a92288e364e1 100644 --- a/core/modules/views/src/Plugin/views/field/Serialized.php +++ b/core/modules/views/src/Plugin/views/field/Serialized.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\field; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -27,7 +28,7 @@ protected function defineOptions() { } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['format'] = array( @@ -53,7 +54,7 @@ public function buildOptionsForm(&$form, &$form_state) { ); } - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { // Require a key if the format is key. if ($form_state['values']['options']['format'] == 'key' && $form_state['values']['options']['key'] == '') { form_error($form['key'], $form_state, t('You have to enter a key if you want to display a key of the data.')); diff --git a/core/modules/views/src/Plugin/views/field/TimeInterval.php b/core/modules/views/src/Plugin/views/field/TimeInterval.php index 545f7214afe342aa53c6e33cf3ed20290e03fdf7..bd3fae4a1933b9f8bce577d48ae0e439f125c29e 100644 --- a/core/modules/views/src/Plugin/views/field/TimeInterval.php +++ b/core/modules/views/src/Plugin/views/field/TimeInterval.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\field; use Drupal\Core\Datetime\Date as DateFormatter; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -64,7 +65,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['granularity'] = array( diff --git a/core/modules/views/src/Plugin/views/field/Url.php b/core/modules/views/src/Plugin/views/field/Url.php index 6b59c92a34719ffeebf626ce2606763e8ae8c58b..22ced7daf16ae49bac161018304df05c3c3e3a9a 100644 --- a/core/modules/views/src/Plugin/views/field/Url.php +++ b/core/modules/views/src/Plugin/views/field/Url.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\field; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; /** @@ -29,7 +30,7 @@ protected function defineOptions() { /** * Provide link to the page being visited. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['display_as_link'] = array( '#title' => t('Display as link'), '#type' => 'checkbox', diff --git a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php index 115857599175021081bc2e887ba35b533bc9b44b..e0d2ed46b7aee0594494d8d3816444b48bed010e 100644 --- a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php +++ b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; @@ -131,7 +132,7 @@ protected function defineOptions() { return $options; } - protected function valueForm(&$form, &$form_state) { + protected function valueForm(&$form, FormStateInterface $form_state) { if (empty($this->value_options)) { // Initialize the array of possible values for this filter. $this->getValueOptions(); @@ -162,7 +163,7 @@ protected function valueForm(&$form, &$form_state) { } } - protected function valueValidate($form, &$form_state) { + protected function valueValidate($form, FormStateInterface $form_state) { if (isset($form_state['values']['options']['value']) && $form_state['values']['options']['value'] == 'All' && !empty($form_state['values']['options']['expose']['required'])) { form_set_error('value', $form_state, t('You must select a value unless this is an non-required exposed filter.')); } diff --git a/core/modules/views/src/Plugin/views/filter/Combine.php b/core/modules/views/src/Plugin/views/filter/Combine.php index 3621378f0f1cabe44610dfe911cf37feb86d0cc4..12e6f22e940cc6372b2813b8ecaaddb17f7318f5 100644 --- a/core/modules/views/src/Plugin/views/filter/Combine.php +++ b/core/modules/views/src/Plugin/views/filter/Combine.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; + /** * Filter handler which allows to search on multiple fields. * @@ -28,7 +30,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $this->view->initStyle(); diff --git a/core/modules/views/src/Plugin/views/filter/Date.php b/core/modules/views/src/Plugin/views/filter/Date.php index 52ea7ce0e240a184cde9895a26225ddd369f6c1e..ead1f1d366aa910e6237d48e4628f1ecb0a98aa2 100644 --- a/core/modules/views/src/Plugin/views/filter/Date.php +++ b/core/modules/views/src/Plugin/views/filter/Date.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; + /** * Filter to handle dates stored as a timestamp. * @@ -28,7 +30,7 @@ protected function defineOptions() { /** * Add a type selector to the value form */ - protected function valueForm(&$form, &$form_state) { + protected function valueForm(&$form, FormStateInterface $form_state) { if (empty($form_state['exposed'])) { $form['value']['type'] = array( '#type' => 'radios', @@ -43,7 +45,7 @@ protected function valueForm(&$form, &$form_state) { parent::valueForm($form, $form_state); } - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { parent::validateOptionsForm($form, $form_state); if (!empty($this->options['exposed']) && empty($form_state['values']['options']['expose']['required'])) { @@ -54,7 +56,7 @@ public function validateOptionsForm(&$form, &$form_state) { $this->validateValidTime($form['value'], $form_state, $form_state['values']['options']['operator'], $form_state['values']['options']['value']); } - public function validateExposed(&$form, &$form_state) { + public function validateExposed(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed'])) { return; } @@ -79,7 +81,7 @@ public function validateExposed(&$form, &$form_state) { /** * Validate that the time values convert to something usable. */ - public function validateValidTime(&$form, array &$form_state, $operator, $value) { + public function validateValidTime(&$form, FormStateInterface $form_state, $operator, $value) { $operators = $this->operators(); if ($operators[$operator]['values'] == 1) { @@ -103,7 +105,7 @@ public function validateValidTime(&$form, array &$form_state, $operator, $value) /** * Validate the build group options form. */ - protected function buildGroupValidate($form, &$form_state) { + protected function buildGroupValidate($form, FormStateInterface $form_state) { // Special case to validate grouped date filters, this is because the // $group['value'] array contains the type of filter (date or offset) // and therefore the number of items the comparission has to be done diff --git a/core/modules/views/src/Plugin/views/filter/Equality.php b/core/modules/views/src/Plugin/views/filter/Equality.php index f0cda43252da89b29447fb8db3dd2c396569e161..f83cefaf81dd26c7c9ea6f4569695f1061447b04 100644 --- a/core/modules/views/src/Plugin/views/filter/Equality.php +++ b/core/modules/views/src/Plugin/views/filter/Equality.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; + /** * Simple filter to handle equal to / not equal to filters * @@ -32,7 +34,7 @@ public function operatorOptions() { /** * Provide a simple textfield for equality */ - protected function valueForm(&$form, &$form_state) { + protected function valueForm(&$form, FormStateInterface $form_state) { $form['value'] = array( '#type' => 'textfield', '#title' => t('Value'), diff --git a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php index fe110db040fa5fec9979ef708a5d42762afdec60..c92184e1a6c6ed7611929291601df881fcef56f3 100644 --- a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\views\Plugin\views\HandlerBase; use Drupal\Component\Utility\String as UtilityString; @@ -196,7 +197,7 @@ public function isAGroup() { * or to at least make sure all of the functions in this form * are called. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); if ($this->canExpose()) { $this->showExposeButton($form, $form_state); @@ -237,7 +238,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Simple validate handler */ - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { $this->operatorValidate($form, $form_state); $this->valueValidate($form, $form_state); if (!empty($this->options['exposed']) && !$this->isAGroup()) { @@ -251,7 +252,7 @@ public function validateOptionsForm(&$form, &$form_state) { /** * Simple submit handler */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { unset($form_state['values']['expose_button']); // don't store this. unset($form_state['values']['group_button']); // don't store this. if (!$this->isAGroup()) { @@ -269,7 +270,7 @@ public function submitOptionsForm(&$form, &$form_state) { /** * Shortcut to display the operator form. */ - public function showOperatorForm(&$form, &$form_state) { + public function showOperatorForm(&$form, FormStateInterface $form_state) { $this->operatorForm($form, $form_state); $form['operator']['#prefix'] = '
'; $form['operator']['#suffix'] = '
'; @@ -283,7 +284,7 @@ public function showOperatorForm(&$form, &$form_state) { * * @see buildOptionsForm() */ - protected function operatorForm(&$form, &$form_state) { + protected function operatorForm(&$form, FormStateInterface $form_state) { $options = $this->operatorOptions(); if (!empty($options)) { $form['operator'] = array( @@ -304,18 +305,18 @@ public function operatorOptions() { return array(); } /** * Validate the operator form. */ - protected function operatorValidate($form, &$form_state) { } + protected function operatorValidate($form, FormStateInterface $form_state) { } /** * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - public function operatorSubmit($form, &$form_state) { } + public function operatorSubmit($form, FormStateInterface $form_state) { } /** * Shortcut to display the value form. */ - protected function showValueForm(&$form, &$form_state) { + protected function showValueForm(&$form, FormStateInterface $form_state) { $this->valueForm($form, $form_state); if (empty($this->no_operator)) { $form['value']['#prefix'] = '
' . (isset($form['value']['#prefix']) ? $form['value']['#prefix'] : ''); @@ -331,23 +332,25 @@ protected function showValueForm(&$form, &$form_state) { * * @see buildOptionsForm() */ - protected function valueForm(&$form, &$form_state) { $form['value'] = array(); } + protected function valueForm(&$form, FormStateInterface $form_state) { + $form['value'] = array(); + } /** * Validate the options form. */ - protected function valueValidate($form, &$form_state) { } + protected function valueValidate($form, FormStateInterface $form_state) { } /** * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - protected function valueSubmit($form, &$form_state) { } + protected function valueSubmit($form, FormStateInterface $form_state) { } /** * Shortcut to display the exposed options form. */ - public function showBuildGroupForm(&$form, &$form_state) { + public function showBuildGroupForm(&$form, FormStateInterface $form_state) { if (empty($this->options['is_grouped'])) { return; } @@ -370,7 +373,7 @@ public function showBuildGroupForm(&$form, &$form_state) { /** * Shortcut to display the build_group/hide button. */ - protected function showBuildGroupButton(&$form, &$form_state) { + protected function showBuildGroupButton(&$form, FormStateInterface $form_state) { $form['group_button'] = array( '#prefix' => '
', @@ -422,7 +425,7 @@ protected function showBuildGroupButton(&$form, &$form_state) { /** * Displays the Build Group form. */ - public function buildGroupForm($form, &$form_state) { + public function buildGroupForm($form, FormStateInterface $form_state) { $item = &$this->options; // flip. If the filter was a group, set back to a standard filter. $item['is_grouped'] = empty($item['is_grouped']); @@ -445,7 +448,7 @@ public function buildGroupForm($form, &$form_state) { /** * Shortcut to display the expose/hide button. */ - public function showExposeButton(&$form, &$form_state) { + public function showExposeButton(&$form, FormStateInterface $form_state) { $form['expose_button'] = array( '#prefix' => '
', '#suffix' => '
', @@ -498,7 +501,7 @@ public function showExposeButton(&$form, &$form_state) { * * @see buildOptionsForm() */ - public function buildExposeForm(&$form, &$form_state) { + public function buildExposeForm(&$form, FormStateInterface $form_state) { $form['#theme'] = 'views_ui_expose_filter_form'; // #flatten will move everything from $form['expose'][$key] to $form[$key] // prior to rendering. That's why the preRender for it needs to run first, @@ -608,7 +611,7 @@ public function buildExposeForm(&$form, &$form_state) { /** * Validate the options form. */ - public function validateExposeForm($form, &$form_state) { + public function validateExposeForm($form, FormStateInterface $form_state) { if (empty($form_state['values']['options']['expose']['identifier'])) { form_error($form['expose']['identifier'], $form_state, t('The identifier is required if the filter is exposed.')); } @@ -625,7 +628,7 @@ public function validateExposeForm($form, &$form_state) { /** * Validate the build group options form. */ - protected function buildGroupValidate($form, &$form_state) { + protected function buildGroupValidate($form, FormStateInterface $form_state) { if (!empty($form_state['values']['options']['group_info'])) { if (empty($form_state['values']['options']['group_info']['identifier'])) { form_error($form['group_info']['identifier'], $form_state, t('The identifier is required if the filter is exposed.')); @@ -671,7 +674,7 @@ protected function buildGroupValidate($form, &$form_state) { /** * Save new group items, re-enumerates and remove groups marked to delete. */ - protected function buildGroupSubmit($form, &$form_state) { + protected function buildGroupSubmit($form, FormStateInterface $form_state) { $groups = array(); uasort($form_state['values']['options']['group_info']['group_items'], array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); // Filter out removed items. @@ -739,7 +742,7 @@ protected function buildGroupOptions() { * Build a form containing a group of operator | values to apply as a * single filter. */ - public function groupForm(&$form, &$form_state) { + public function groupForm(&$form, FormStateInterface $form_state) { if (!empty($this->options['group_info']['optional']) && !$this->multipleExposedInput()) { $groups = array('All' => t('- Any -')); } @@ -783,7 +786,7 @@ public function groupForm(&$form, &$form_state) { * * You can override this if it doesn't do what you expect. */ - public function buildExposedForm(&$form, &$form_state) { + public function buildExposedForm(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed'])) { return; } @@ -829,7 +832,7 @@ public function buildExposedForm(&$form, &$form_state) { * Build the form to let users create the group of exposed filters. * This form is displayed when users click on button 'Build group' */ - protected function buildExposedFiltersGroupForm(&$form, &$form_state) { + protected function buildExposedFiltersGroupForm(&$form, FormStateInterface $form_state) { if (empty($this->options['exposed']) || empty($this->options['is_grouped'])) { return; } @@ -1092,7 +1095,7 @@ protected function buildExposedFiltersGroupForm(&$form, &$form_state) { /** * Add a new group to the exposed filter groups. */ - public function addGroupForm($form, &$form_state) { + public function addGroupForm($form, FormStateInterface $form_state) { $item = &$this->options; // Add a new row. diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php index 1902b3bf0af44375461d6cf461d76b5e6dca9e43..f99041edb380f3c76a346d2441a6bd8ff811e4bf 100644 --- a/core/modules/views/src/Plugin/views/filter/InOperator.php +++ b/core/modules/views/src/Plugin/views/filter/InOperator.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String as UtilityString; use Drupal\Component\Utility\Unicode; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; @@ -79,7 +80,7 @@ public function defaultExposeOptions() { $this->options['expose']['reduce'] = FALSE; } - public function buildExposeForm(&$form, &$form_state) { + public function buildExposeForm(&$form, FormStateInterface $form_state) { parent::buildExposeForm($form, $form_state); $form['expose']['reduce'] = array( '#type' => 'checkbox', @@ -165,7 +166,7 @@ protected function operatorValues($values = 1) { return $options; } - protected function valueForm(&$form, &$form_state) { + protected function valueForm(&$form, FormStateInterface $form_state) { $form['value'] = array(); $options = array(); @@ -295,7 +296,7 @@ public function acceptExposedInput($input) { return parent::acceptExposedInput($input); } - protected function valueSubmit($form, &$form_state) { + protected function valueSubmit($form, FormStateInterface $form_state) { // Drupal's FAPI system automatically puts '0' in for any checkbox that // was not set, and the key to the checkbox if it is set. // Unfortunately, this means that if the key to that checkbox is 0, diff --git a/core/modules/views/src/Plugin/views/filter/ManyToOne.php b/core/modules/views/src/Plugin/views/filter/ManyToOne.php index a3999649049c370a67e80ade1c61760ad4c86871..cc8b448537c60aa4ee441644df72283ac53e52b4 100644 --- a/core/modules/views/src/Plugin/views/filter/ManyToOne.php +++ b/core/modules/views/src/Plugin/views/filter/ManyToOne.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ManyToOneHelper; @@ -107,7 +108,7 @@ function operators() { } protected $valueFormType = 'select'; - protected function valueForm(&$form, &$form_state) { + protected function valueForm(&$form, FormStateInterface $form_state) { parent::valueForm($form, $form_state); if (empty($form_state['exposed'])) { diff --git a/core/modules/views/src/Plugin/views/filter/Numeric.php b/core/modules/views/src/Plugin/views/filter/Numeric.php index 53b94fa3b588993d87f54fc5e98c7026ccc8fce7..0348a33cc32ffb65b818edb1ba01e1c6834fc7aa 100644 --- a/core/modules/views/src/Plugin/views/filter/Numeric.php +++ b/core/modules/views/src/Plugin/views/filter/Numeric.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String as UtilityString; use Drupal\Core\Database\Database; +use Drupal\Core\Form\FormStateInterface; /** * Simple filter to handle greater than/less than filters @@ -139,7 +140,7 @@ protected function operatorValues($values = 1) { /** * Provide a simple textfield for equality */ - protected function valueForm(&$form, &$form_state) { + protected function valueForm(&$form, FormStateInterface $form_state) { $form['value']['#tree'] = TRUE; // We have to make some choices when creating this as an exposed diff --git a/core/modules/views/src/Plugin/views/filter/String.php b/core/modules/views/src/Plugin/views/filter/String.php index ea1b3fe57e55e01ec08d6bf7accc9cb8ed635547..185252d0bb153130ae2a5ee2c8b0e87691876ea0 100644 --- a/core/modules/views/src/Plugin/views/filter/String.php +++ b/core/modules/views/src/Plugin/views/filter/String.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String as UtilityString; use Drupal\Core\Database\Database; +use Drupal\Core\Form\FormStateInterface; /** * Basic textfield filter to handle string filtering commands @@ -183,7 +184,7 @@ protected function operatorValues($values = 1) { /** * Provide a simple textfield for equality */ - protected function valueForm(&$form, &$form_state) { + protected function valueForm(&$form, FormStateInterface $form_state) { // We have to make some choices when creating this as an exposed // filter form. For example, if the operator is locked and thus // not rendered, we can't render dependencies; instead we only diff --git a/core/modules/views/src/Plugin/views/pager/Full.php b/core/modules/views/src/Plugin/views/pager/Full.php index fda4c4e552d529325bf46b83c5a97c9004747edf..ed8bbd1582dedb64c26aae525ea67ec2712f3925 100644 --- a/core/modules/views/src/Plugin/views/pager/Full.php +++ b/core/modules/views/src/Plugin/views/pager/Full.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\pager; +use Drupal\Core\Form\FormStateInterface; + /** * The plugin to handle full pager. * @@ -41,7 +43,7 @@ protected function defineOptions() { /** * Overrides \Drupal\views\Plugin\views\SqlBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['quantity'] = array( diff --git a/core/modules/views/src/Plugin/views/pager/None.php b/core/modules/views/src/Plugin/views/pager/None.php index e5ccad348b054022fca68befc303069ceecce277..15bfa130f6486d63fb93ffb595552a901ca5cad8 100644 --- a/core/modules/views/src/Plugin/views/pager/None.php +++ b/core/modules/views/src/Plugin/views/pager/None.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\pager; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -51,7 +52,7 @@ protected function defineOptions() { /** * Provide the default form for setting options. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['offset'] = array( '#type' => 'textfield', diff --git a/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php b/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php index b5a7af2635964db431f99927276437b17388f55d..12a70983039cf98eeb9e5e6deb964c8f09a6fe30 100644 --- a/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php +++ b/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\pager; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\PluginBase; use Drupal\views\ViewExecutable; @@ -119,12 +120,12 @@ public function getPagerId() { /** * Provide the default form form for validating options */ - public function validateOptionsForm(&$form, &$form_state) { } + public function validateOptionsForm(&$form, FormStateInterface $form_state) { } /** * Provide the default form form for submitting options */ - public function submitOptionsForm(&$form, &$form_state) { } + public function submitOptionsForm(&$form, FormStateInterface $form_state) { } /** * Return a string to display as the clickable title for the @@ -216,11 +217,11 @@ public function hasMoreRecords() { && $this->total_items > (intval($this->current_page) + 1) * $this->getItemsPerPage(); } - public function exposedFormAlter(&$form, &$form_state) { } + public function exposedFormAlter(&$form, FormStateInterface $form_state) { } - public function exposedFormValidate(&$form, &$form_state) { } + public function exposedFormValidate(&$form, FormStateInterface $form_state) { } - public function exposedFormSubmit(&$form, &$form_state, &$exclude) { } + public function exposedFormSubmit(&$form, FormStateInterface $form_state, &$exclude) { } public function usesExposed() { return FALSE; diff --git a/core/modules/views/src/Plugin/views/pager/Some.php b/core/modules/views/src/Plugin/views/pager/Some.php index ded554f388336bdd5feb094c110a4ebc7b5f9a87..d024960fc3a5067cbc948a4e19d81f9518f679e0 100644 --- a/core/modules/views/src/Plugin/views/pager/Some.php +++ b/core/modules/views/src/Plugin/views/pager/Some.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\pager; +use Drupal\Core\Form\FormStateInterface; + /** * Plugin for views without pagers. * @@ -39,7 +41,7 @@ protected function defineOptions() { /** * Provide the default form for setting options. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $pager_text = $this->displayHandler->getPagerText(); $form['items_per_page'] = array( diff --git a/core/modules/views/src/Plugin/views/pager/SqlBase.php b/core/modules/views/src/Plugin/views/pager/SqlBase.php index 7aeb69e966ecf2e377f71ecee85c9f09cc7d5c72..c38edd9fb8178ab195eb407b916669ea349654a0 100644 --- a/core/modules/views/src/Plugin/views/pager/SqlBase.php +++ b/core/modules/views/src/Plugin/views/pager/SqlBase.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\pager; +use Drupal\Core\Form\FormStateInterface; + /** * A common base class for sql based pager. */ @@ -42,7 +44,7 @@ protected function defineOptions() { /** * Provide the default form for setting options. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $pager_text = $this->displayHandler->getPagerText(); $form['items_per_page'] = array( @@ -176,7 +178,7 @@ public function buildOptionsForm(&$form, &$form_state) { ); } - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { // Only accept integer values. $error = FALSE; $exposed_options = $form_state['values']['pager_options']['expose']['items_per_page_options']; @@ -335,7 +337,7 @@ protected function isOffsetExposed() { return !empty($this->options['expose']['offset']); } - public function exposedFormAlter(&$form, &$form_state) { + public function exposedFormAlter(&$form, FormStateInterface $form_state) { if ($this->itemsPerPageExposed()) { $options = explode(',', $this->options['expose']['items_per_page_options']); $sanitized_options = array(); @@ -366,7 +368,7 @@ public function exposedFormAlter(&$form, &$form_state) { } } - public function exposedFormValidate(&$form, &$form_state) { + public function exposedFormValidate(&$form, FormStateInterface $form_state) { if (!empty($form_state['values']['offset']) && trim($form_state['values']['offset'])) { if (!is_numeric($form_state['values']['offset']) || $form_state['values']['offset'] < 0) { form_set_error('offset', $form_state, t('Offset must be an number greather or equal than 0.')); diff --git a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php index 4e917c11d8f00d9c0235e0a79a954570acb85600..4097efa35e8a2ce7fa032e3fadafc02cd48b0860 100644 --- a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php +++ b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\query; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; @@ -108,9 +109,9 @@ public function addSignature(ViewExecutable $view) { } */ public function getAggregationInfo() { } - public function validateOptionsForm(&$form, &$form_state) { } + public function validateOptionsForm(&$form, FormStateInterface $form_state) { } - public function submitOptionsForm(&$form, &$form_state) { } + public function submitOptionsForm(&$form, FormStateInterface $form_state) { } public function summaryTitle() { return t('Settings'); diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php index 6e2f1889bd8c3b91482918b64fcd268d7248621e..1cabb79c65774e5a4cc5aa08ac4263b1ddd59e5c 100644 --- a/core/modules/views/src/Plugin/views/query/Sql.php +++ b/core/modules/views/src/Plugin/views/query/Sql.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Database\Database; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\views\Plugin\views\join\JoinPluginBase; @@ -200,7 +201,7 @@ protected function defineOptions() { /** * Add settings for the ui. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['disable_sql_rewrite'] = array( @@ -240,7 +241,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Special submit handling. */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { $element = array('#parents' => array('query', 'options', 'query_tags')); $value = explode(',', NestedArray::getValue($form_state['values'], $element['#parents'])); $value = array_filter(array_map('trim', $value)); diff --git a/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php b/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php index 7a85bbcbd1011ca27071bb03ed14b5590398b00b..621b1c19b1a3ce2ae9c70440f0e1d53b9b652d2e 100644 --- a/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php +++ b/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\relationship; use Drupal\Core\Database\Query\AlterableInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Views; /** @@ -81,7 +82,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Get the sorts that apply to our base. @@ -168,7 +169,7 @@ protected function getTemporaryView() { /** * When the form is submitted, make sure to clear the subquery string cache. */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { $cid = 'views_relationship_groupwise_max:' . $this->view->storage->id() . ':' . $this->view->current_display . ':' . $this->options['id']; \Drupal::cache('views_results')->delete($cid); } diff --git a/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php b/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php index a52d7dd733331c61e8fac670e02ea0a28ddfe672..a75ffeb87881beb0d3b7be89b7c63d83cc0b3f38 100644 --- a/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php +++ b/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\relationship; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\HandlerBase; @@ -104,7 +105,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); unset($form['admin_label']['#fieldset']); diff --git a/core/modules/views/src/Plugin/views/row/EntityRow.php b/core/modules/views/src/Plugin/views/row/EntityRow.php index c46d354e3d58e74b559c2558db37d5b02a695963..d830017b46a91b6467cf0f18cad9ffd6e2b0c409 100644 --- a/core/modules/views/src/Plugin/views/row/EntityRow.php +++ b/core/modules/views/src/Plugin/views/row/EntityRow.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\DependencyInjection\Container; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; @@ -125,7 +126,7 @@ protected function defineOptions() { /** * Overrides Drupal\views\Plugin\views\row\RowPluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['view_mode'] = array( diff --git a/core/modules/views/src/Plugin/views/row/Fields.php b/core/modules/views/src/Plugin/views/row/Fields.php index d49b2137acc7a5ff75a0b07528eefa562d4a2843..5851d4991fe81ef11a0aaa492324e015f6f33967 100644 --- a/core/modules/views/src/Plugin/views/row/Fields.php +++ b/core/modules/views/src/Plugin/views/row/Fields.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; + /** * The basic 'fields' row plugin * @@ -45,7 +47,7 @@ protected function defineOptions() { /** * Provide a form for setting options. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $options = $this->displayHandler->getFieldLabels(); @@ -99,7 +101,7 @@ public function buildOptionsForm(&$form, &$form_state) { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { $form_state['values']['row_options']['inline'] = array_filter($form_state['values']['row_options']['inline']); } diff --git a/core/modules/views/src/Plugin/views/row/OpmlFields.php b/core/modules/views/src/Plugin/views/row/OpmlFields.php index 2274f66c48e0381727c6e28365f7358e7adfc91c..2e936f58e4f5751ee09890c04310a3686c46f21a 100644 --- a/core/modules/views/src/Plugin/views/row/OpmlFields.php +++ b/core/modules/views/src/Plugin/views/row/OpmlFields.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; + /** * Renders an OPML item based on fields. * @@ -46,7 +48,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $initial_labels = array('' => $this->t('- None -')); diff --git a/core/modules/views/src/Plugin/views/row/RowPluginBase.php b/core/modules/views/src/Plugin/views/row/RowPluginBase.php index 41decedcef2c9535c02be3df160e3d07d9b2b961..905f04e2d477562d22f4187dab2019ba35cee46d 100644 --- a/core/modules/views/src/Plugin/views/row/RowPluginBase.php +++ b/core/modules/views/src/Plugin/views/row/RowPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\PluginBase; use Drupal\views\ViewExecutable; use Drupal\views\Views; @@ -78,7 +79,7 @@ protected function defineOptions() { /** * Provide a form for setting options. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); if (isset($this->base_table)) { $executable = $form_state['view']->getExecutable(); @@ -127,13 +128,13 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Validate the options form. */ - public function validateOptionsForm(&$form, &$form_state) { } + public function validateOptionsForm(&$form, FormStateInterface $form_state) { } /** * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - public function submitOptionsForm(&$form, &$form_state) { } + public function submitOptionsForm(&$form, FormStateInterface $form_state) { } /** * {@inheritdoc} diff --git a/core/modules/views/src/Plugin/views/row/RssFields.php b/core/modules/views/src/Plugin/views/row/RssFields.php index b59b72e3eee8e62f334411bd5d63fad99b229296..48dcefe29ba2ac080dd3867333e45d82799b8fa8 100644 --- a/core/modules/views/src/Plugin/views/row/RssFields.php +++ b/core/modules/views/src/Plugin/views/row/RssFields.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; + /** * Renders an RSS item based on fields. * @@ -39,7 +41,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $initial_labels = array('' => t('- None -')); diff --git a/core/modules/views/src/Plugin/views/sort/Date.php b/core/modules/views/src/Plugin/views/sort/Date.php index 558321d45d00e849bcc4aaad71ec821a8d56ba41..6c0b75455317654899ee6aebba46216cb16e3408 100644 --- a/core/modules/views/src/Plugin/views/sort/Date.php +++ b/core/modules/views/src/Plugin/views/sort/Date.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\sort; +use Drupal\Core\Form\FormStateInterface; + /** * Basic sort handler for dates. * @@ -25,7 +27,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['granularity'] = array( diff --git a/core/modules/views/src/Plugin/views/sort/Random.php b/core/modules/views/src/Plugin/views/sort/Random.php index ebce478691155dd791469e68a8eb72d03ec551f4..f0223df42ce4c801ec9e18907202d03d32b25472 100644 --- a/core/modules/views/src/Plugin/views/sort/Random.php +++ b/core/modules/views/src/Plugin/views/sort/Random.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\sort; +use Drupal\Core\Form\FormStateInterface; + /** * Handle a random sort. * @@ -25,7 +27,7 @@ public function query() { $this->query->addOrderBy('rand'); } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['order']['#access'] = FALSE; } diff --git a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php index 5623ebe609512c8f949e72dd3821911a929cebb8..cfe4d3fb2d90f021b04051b818f0804876dff01c 100644 --- a/core/modules/views/src/Plugin/views/sort/SortPluginBase.php +++ b/core/modules/views/src/Plugin/views/sort/SortPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\sort; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\HandlerBase; /** @@ -77,7 +78,7 @@ public function adminSummary() { /** * Basic options for all sort criteria */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); if ($this->canExpose()) { $this->showExposeButton($form, $form_state); @@ -93,7 +94,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Shortcut to display the expose/hide button. */ - public function showExposeButton(&$form, &$form_state) { + public function showExposeButton(&$form, FormStateInterface $form_state) { $form['expose_button'] = array( '#prefix' => '
', '#suffix' => '
', @@ -144,7 +145,7 @@ public function showExposeButton(&$form, &$form_state) { /** * Simple validate handler */ - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { $this->sortValidate($form, $form_state); if (!empty($this->options['exposed'])) { $this->validateExposeForm($form, $form_state); @@ -155,7 +156,7 @@ public function validateOptionsForm(&$form, &$form_state) { /** * Simple submit handler */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { unset($form_state['values']['expose_button']); // don't store this. $this->sortSubmit($form, $form_state); if (!empty($this->options['exposed'])) { @@ -166,7 +167,7 @@ public function submitOptionsForm(&$form, &$form_state) { /** * Shortcut to display the value form. */ - protected function showSortForm(&$form, &$form_state) { + protected function showSortForm(&$form, FormStateInterface $form_state) { $options = $this->sortOptions(); if (!empty($options)) { $form['order'] = array( @@ -178,9 +179,9 @@ protected function showSortForm(&$form, &$form_state) { } } - protected function sortValidate(&$form, &$form_state) { } + protected function sortValidate(&$form, FormStateInterface $form_state) { } - public function sortSubmit(&$form, &$form_state) { } + public function sortSubmit(&$form, FormStateInterface $form_state) { } /** * Provide a list of options for the default sort form. @@ -193,7 +194,7 @@ protected function sortOptions() { ); } - public function buildExposeForm(&$form, &$form_state) { + public function buildExposeForm(&$form, FormStateInterface $form_state) { // #flatten will move everything from $form['expose'][$key] to $form[$key] // prior to rendering. That's why the preRender for it needs to run first, // so that when the next preRender (the one for fieldsets) runs, it gets diff --git a/core/modules/views/src/Plugin/views/style/DefaultSummary.php b/core/modules/views/src/Plugin/views/style/DefaultSummary.php index 693c02a91c14764519b3caf8c5fc4355f3d50c08..7401a9584d8f68919ae6a6ca097450fa59263e33 100644 --- a/core/modules/views/src/Plugin/views/style/DefaultSummary.php +++ b/core/modules/views/src/Plugin/views/style/DefaultSummary.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\style; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\style\StylePluginBase; /** @@ -41,7 +42,7 @@ public function query() { } } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['base_path'] = array( '#type' => 'textfield', '#title' => t('Base path'), diff --git a/core/modules/views/src/Plugin/views/style/Grid.php b/core/modules/views/src/Plugin/views/style/Grid.php index 11918f710b1d75902ac3708428617adefbf0ab8e..ab5c6a2dc9e51bcc968962b4b5843f4e621bb224 100644 --- a/core/modules/views/src/Plugin/views/style/Grid.php +++ b/core/modules/views/src/Plugin/views/style/Grid.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\style; +use Drupal\Core\Form\FormStateInterface; + /** * Style plugin to render each item in a grid cell. * @@ -47,7 +49,7 @@ protected function defineOptions() { /** * {@inheritdoc} */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['columns'] = array( '#type' => 'number', diff --git a/core/modules/views/src/Plugin/views/style/HtmlList.php b/core/modules/views/src/Plugin/views/style/HtmlList.php index 9d18903130051149424d1bb90cb33f307895aea8..bf4422d2ac64978ba71fdebda88675ee63d37406 100644 --- a/core/modules/views/src/Plugin/views/style/HtmlList.php +++ b/core/modules/views/src/Plugin/views/style/HtmlList.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\style; +use Drupal\Core\Form\FormStateInterface; + /** * Style plugin to render each item in an ordered or unordered list. * @@ -52,7 +54,7 @@ protected function defineOptions() { /** * Render the given style. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['type'] = array( '#type' => 'radios', diff --git a/core/modules/views/src/Plugin/views/style/Mapping.php b/core/modules/views/src/Plugin/views/style/Mapping.php index 101d32f3362713dcabd9c26a9aafeeb55aa3dbaf..7c538a33deabe0b98e2df1ceb1efef9d94f35eaa 100644 --- a/core/modules/views/src/Plugin/views/style/Mapping.php +++ b/core/modules/views/src/Plugin/views/style/Mapping.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\style; +use Drupal\Core\Form\FormStateInterface; + /** * Allows fields to be mapped to specific use cases. * @@ -70,7 +72,7 @@ protected function defineOptions() { /** * Overrides Drupal\views\Plugin\views\style\StylePluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Get the mapping. diff --git a/core/modules/views/src/Plugin/views/style/Rss.php b/core/modules/views/src/Plugin/views/style/Rss.php index 362370ff952544027a3d9e6073f9c163998fe5b0..996684d90de90337a1d7138782dde9d8bfe2bc61 100644 --- a/core/modules/views/src/Plugin/views/style/Rss.php +++ b/core/modules/views/src/Plugin/views/style/Rss.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\style; use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\Form\FormStateInterface; /** * Default style plugin to render an RSS feed. @@ -74,7 +75,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['description'] = array( diff --git a/core/modules/views/src/Plugin/views/style/StylePluginBase.php b/core/modules/views/src/Plugin/views/style/StylePluginBase.php index 6662bf89d921066c22bdbfe5ec0686807eafc19c..2f18209c5283a7a7a1645be700badd79f3c4aaad 100644 --- a/core/modules/views/src/Plugin/views/style/StylePluginBase.php +++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\style; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\wizard\WizardInterface; @@ -244,7 +245,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Only fields-based views can handle grouping. Style plugins can also exclude // themselves from being groupable by setting their "usesGrouping" property @@ -335,7 +336,7 @@ public function buildOptionsForm(&$form, &$form_state) { } } - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { // Don't run validation on style plugins without the grouping setting. if (isset($form_state['values']['style_options']['grouping'])) { // Don't save grouping if no field is specified. @@ -352,12 +353,12 @@ public function validateOptionsForm(&$form, &$form_state) { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param string $type * The display type, either block or page. */ - public function wizardForm(&$form, &$form_state, $type) { + public function wizardForm(&$form, FormStateInterface $form_state, $type) { } /** @@ -365,8 +366,8 @@ public function wizardForm(&$form, &$form_state, $type) { * * @param array $form * An associative array containing the structure of the form. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param \Drupal\views\Plugin\views\wizard\WizardInterface $wizard * The current used wizard. * @param array $display_options @@ -375,7 +376,7 @@ public function wizardForm(&$form, &$form_state, $type) { * @param string $display_type * The display type, either block or page. */ - public function wizardSubmit(&$form, &$form_state, WizardInterface $wizard, &$display_options, $display_type) { + public function wizardSubmit(&$form, FormStateInterface $form_state, WizardInterface $wizard, &$display_options, $display_type) { } /** diff --git a/core/modules/views/src/Plugin/views/style/Table.php b/core/modules/views/src/Plugin/views/style/Table.php index 789857efc594a56622a9247415ce9c65b1c00f40..69c8b1800818c67e8705e8078117625550f79ffc 100644 --- a/core/modules/views/src/Plugin/views/style/Table.php +++ b/core/modules/views/src/Plugin/views/style/Table.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\style; use Drupal\Component\Plugin\Discovery\DiscoveryInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\wizard\WizardInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -196,7 +197,7 @@ public function sanitizeColumns($columns, $fields = NULL) { /** * Render the given style. */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $handlers = $this->displayHandler->getHandlers('field'); if (empty($handlers)) { @@ -411,7 +412,7 @@ public function evenEmpty() { return parent::evenEmpty() || !empty($this->options['empty_table']); } - public function wizardSubmit(&$form, &$form_state, WizardInterface $wizard, &$display_options, $display_type) { + public function wizardSubmit(&$form, FormStateInterface $form_state, WizardInterface $wizard, &$display_options, $display_type) { // If any of the displays use the table style, make sure that the fields // always have a labels by unsetting the override. foreach ($display_options['default']['fields'] as &$field) { diff --git a/core/modules/views/src/Plugin/views/style/UnformattedSummary.php b/core/modules/views/src/Plugin/views/style/UnformattedSummary.php index 3c7d47b2edabd5b526a764e948d29806fb1eb49a..05c9e8ef241fa6069530e5f2df75a736e1ee5a9a 100644 --- a/core/modules/views/src/Plugin/views/style/UnformattedSummary.php +++ b/core/modules/views/src/Plugin/views/style/UnformattedSummary.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\style; +use Drupal\Core\Form\FormStateInterface; + /** * The default style plugin for summaries. * @@ -29,7 +31,7 @@ protected function defineOptions() { return $options; } - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['inline'] = array( '#type' => 'checkbox', diff --git a/core/modules/views/src/Plugin/views/wizard/WizardInterface.php b/core/modules/views/src/Plugin/views/wizard/WizardInterface.php index 6e1a54852f6f29bbeb9ada88df97e0e571fb15db..893afee8dac2bd6c893679625714b2432894cbe5 100644 --- a/core/modules/views/src/Plugin/views/wizard/WizardInterface.php +++ b/core/modules/views/src/Plugin/views/wizard/WizardInterface.php @@ -7,6 +7,8 @@ namespace Drupal\views\Plugin\views\wizard; +use Drupal\Core\Form\FormStateInterface; + /** * Defines a common interface for Views Wizard plugins. * @@ -22,34 +24,34 @@ interface WizardInterface { * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * * @return array * Returns the changed wizard form. */ - public function buildForm(array $form, array &$form_state); + public function buildForm(array $form, FormStateInterface $form_state); /** * Validate form and values. * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * * @return array * An empty array if the view is valid; an array of error strings if it is * not. */ - public function validateView(array $form, array &$form_state); + public function validateView(array $form, FormStateInterface $form_state); /** * Creates a view from values that have already been validated. * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * * @return \Drupal\views\ViewStorageInterface @@ -57,6 +59,6 @@ public function validateView(array $form, array &$form_state); * * @throws \Drupal\views\Plugin\views\wizard\WizardException */ - public function createView(array $form, array &$form_state); + public function createView(array $form, FormStateInterface $form_state); } diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php index 1ba7c2354d083421ef3fc21caba276e1f1dad58d..3c55b1a1a322e9dcd1c1d44326c8cc40aff02f2d 100644 --- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\wizard; use Drupal\Component\Utility\NestedArray; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Entity\View; use Drupal\views\Views; use Drupal\views_ui\ViewUI; @@ -214,7 +215,7 @@ public function getSorts() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $style_options = Views::fetchPluginNames('style', 'normal', array($this->base_table)); $feed_row_options = Views::fetchPluginNames('row', 'feed', array($this->base_table)); $path_prefix = url(NULL, array('absolute' => TRUE)); @@ -461,8 +462,8 @@ public function buildForm(array $form, array &$form_state) { * the results of this function for any other purpose besides deciding how to * build the next version of the form. * - * @param $form_state - * The standard associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param $parents * An array of parent keys that point to the part of the submitted form * values that are expected to contain the element's value (in the case where @@ -524,12 +525,12 @@ public static function getSelected($form_state, $parents, $default_value, $eleme * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * @param string $type * The display ID (e.g. 'page' or 'block'). */ - protected function buildFormStyle(array &$form, array &$form_state, $type) { + protected function buildFormStyle(array &$form, FormStateInterface $form_state, $type) { $style_form = &$form['displays'][$type]['options']['style']; $style = $style_form['style_plugin']['#default_value']; $style_plugin = Views::pluginManager('style')->createInstance($style); @@ -578,7 +579,7 @@ protected function rowStyleOptions() { * By default, this adds "of type" and "tagged with" filters (when they are * available). */ - protected function buildFilters(&$form, &$form_state) { + protected function buildFilters(&$form, FormStateInterface $form_state) { module_load_include('inc', 'views_ui', 'admin'); $bundles = entity_get_bundles($this->entityTypeId); @@ -608,7 +609,7 @@ protected function buildFilters(&$form, &$form_state) { * * By default, this adds a "sorted by [date]" filter (when it is available). */ - protected function buildSorts(&$form, &$form_state) { + protected function buildSorts(&$form, FormStateInterface $form_state) { $sorts = array( 'none' => t('Unsorted'), ); @@ -641,7 +642,7 @@ protected function buildSorts(&$form, &$form_state) { * @return \Drupal\views_ui\ViewUI * The instantiated view UI object. */ - protected function instantiateView($form, &$form_state) { + protected function instantiateView($form, FormStateInterface $form_state) { // Build the basic view properties and create the view. $values = array( 'id' => $form_state['values']['id'], @@ -822,7 +823,7 @@ protected function defaultDisplayOptions() { * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * * @return array @@ -848,14 +849,14 @@ protected function defaultDisplayFilters($form, $form_state) { * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * * @return array * An array of filter arrays keyed by ID. A sort array contains the options * accepted by a filter handler. */ - protected function defaultDisplayFiltersUser(array $form, array &$form_state) { + protected function defaultDisplayFiltersUser(array $form, FormStateInterface $form_state) { $filters = array(); if (!empty($form_state['values']['show']['type']) && $form_state['values']['show']['type'] != 'all') { @@ -907,7 +908,7 @@ protected function defaultDisplayFiltersUser(array $form, array &$form_state) { * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * * @return array @@ -933,7 +934,7 @@ protected function defaultDisplaySorts($form, $form_state) { * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * * @return array @@ -981,13 +982,13 @@ protected function defaultDisplaySortsUser($form, $form_state) { * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * * @return array * Returns an array of display options. */ - protected function pageDisplayOptions(array $form, array &$form_state) { + protected function pageDisplayOptions(array $form, FormStateInterface $form_state) { $display_options = array(); $page = $form_state['values']['page']; $display_options['title'] = $page['title']; @@ -1027,13 +1028,13 @@ protected function pageDisplayOptions(array $form, array &$form_state) { * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * * @return array * Returns an array of display options. */ - protected function blockDisplayOptions(array $form, array &$form_state) { + protected function blockDisplayOptions(array $form, FormStateInterface $form_state) { $display_options = array(); $block = $form_state['values']['block']; $display_options['title'] = $block['title']; @@ -1049,7 +1050,7 @@ protected function blockDisplayOptions(array $form, array &$form_state) { * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * * @return array @@ -1143,7 +1144,7 @@ protected function setOverrideOptions(array $options, DisplayPluginBase $display * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * @param bool $unset * Should the view be removed from the list of validated views. @@ -1151,7 +1152,7 @@ protected function setOverrideOptions(array $options, DisplayPluginBase $display * @return \Drupal\views_ui\ViewUI $view * The validated view object. */ - protected function retrieveValidatedView(array $form, array &$form_state, $unset = TRUE) { + protected function retrieveValidatedView(array $form, FormStateInterface $form_state, $unset = TRUE) { // @todo Figure out why all this hashing is done. Wouldn't it be easier to // store a single entry and that's it? $key = hash('sha256', serialize($form_state['values'])); @@ -1167,12 +1168,12 @@ protected function retrieveValidatedView(array $form, array &$form_state, $unset * * @param array $form * The full wizard form array. - * @param array $form_state + * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the wizard form. * @param \Drupal\views_ui\ViewUI $view * The validated view object. */ - protected function setValidatedView(array $form, array &$form_state, ViewUI $view) { + protected function setValidatedView(array $form, FormStateInterface $form_state, ViewUI $view) { $key = hash('sha256', serialize($form_state['values'])); $this->validated_views[$key] = $view; } @@ -1182,7 +1183,7 @@ protected function setValidatedView(array $form, array &$form_state, ViewUI $vie * * Instantiates the view from the form submission and validates its values. */ - public function validateView(array $form, array &$form_state) { + public function validateView(array $form, FormStateInterface $form_state) { $view = $this->instantiateView($form, $form_state); $errors = $view->getExecutable()->validate(); @@ -1196,7 +1197,7 @@ public function validateView(array $form, array &$form_state) { /** * {@inheritDoc} */ - public function createView(array $form, array &$form_state) { + public function createView(array $form, FormStateInterface $form_state) { $view = $this->retrieveValidatedView($form, $form_state); if (empty($view)) { throw new WizardException('Attempted to create a view with values that have not been validated.'); diff --git a/core/modules/views/src/Tests/Handler/AreaEntityTest.php b/core/modules/views/src/Tests/Handler/AreaEntityTest.php index ac62de15f1f6d595fe229cdebe3165a3bfafbc53..f66a137aef5fd8947a84c29761881216db31ae3c 100644 --- a/core/modules/views/src/Tests/Handler/AreaEntityTest.php +++ b/core/modules/views/src/Tests/Handler/AreaEntityTest.php @@ -8,6 +8,7 @@ namespace Drupal\views\Tests\Handler; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Form\FormState; use Drupal\views\Tests\ViewTestBase; use Drupal\views\Views; @@ -121,7 +122,7 @@ public function testEntityArea() { // Test the available view mode options. $form = array(); - $form_state = array(); + $form_state = new FormState(); $form_state['type'] = 'header'; $view->display_handler->getHandler('header', 'entity_entity_test')->buildOptionsForm($form, $form_state); $this->assertTrue(isset($form['view_mode']['#options']['test']), 'Ensure that the test view mode is available.'); diff --git a/core/modules/views/src/Tests/Plugin/RowEntityTest.php b/core/modules/views/src/Tests/Plugin/RowEntityTest.php index e422d9688aa6d28eecafec370f755a2c6793ee34..6111f42507c0b2d7b8c1311f3db97602b1279036 100644 --- a/core/modules/views/src/Tests/Plugin/RowEntityTest.php +++ b/core/modules/views/src/Tests/Plugin/RowEntityTest.php @@ -7,6 +7,7 @@ namespace Drupal\views\Tests\Plugin; +use Drupal\Core\Form\FormState; use Drupal\views\Views; use Drupal\views\Tests\ViewUnitTestBase; @@ -59,7 +60,7 @@ public function testEntityRow() { // Tests the available view mode options. $form = array(); - $form_state = array(); + $form_state = new FormState(); $form_state['view'] = $view->storage; $view->rowPlugin->buildOptionsForm($form, $form_state); diff --git a/core/modules/views/src/Tests/Wizard/WizardPluginBaseUnitTest.php b/core/modules/views/src/Tests/Wizard/WizardPluginBaseUnitTest.php index 37880d4adaa0310c548c4f9b963a50e3dc151dd9..a121e70fff6b628f3e6c6cb57b8e5cd171bc2fc6 100644 --- a/core/modules/views/src/Tests/Wizard/WizardPluginBaseUnitTest.php +++ b/core/modules/views/src/Tests/Wizard/WizardPluginBaseUnitTest.php @@ -7,6 +7,7 @@ namespace Drupal\views\Tests\Wizard; +use Drupal\Core\Form\FormState; use Drupal\Core\Language\Language; use Drupal\views\Tests\ViewUnitTestBase; use Drupal\views_ui\ViewUI; @@ -50,7 +51,7 @@ protected function setUp() { */ public function testCreateView() { $form = array(); - $form_state = array(); + $form_state = new FormState(); $form = $this->wizard->buildForm($form, $form_state); $random_id = strtolower($this->randomName()); $random_label = $this->randomName(); diff --git a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementForm.php b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementForm.php index 808855994ae17e588f2fe06585985e412cc00dc6..27f71606c97351f863dfd9c255b73de00d5673b3 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementForm.php +++ b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataElementForm.php @@ -7,6 +7,7 @@ namespace Drupal\views_test_data\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Simple form page callback to test the view element. @@ -23,7 +24,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form['view'] = array( '#type' => 'view', '#name' => 'test_view', @@ -37,7 +38,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php index 93254b8702ff1b89e5564494ab961191554e2a60..e61997e643297c62774f6df35750dda43700b4a5 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php @@ -7,6 +7,7 @@ namespace Drupal\views_test_data\Plugin\views\area; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\area\AreaPluginBase; /** @@ -31,7 +32,7 @@ public function defineOptions() { /** * Overrides Drupal\views\Plugin\views\area\AreaPluginBase::buildOptionsForm() */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $this->globalTokenForm($form, $form_state); } diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php index 1447c67ccbfa4f540d9630bfebe825734f0db13c..ca9b746793ea20974591ace52dbd044e2cf252e1 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php @@ -8,6 +8,7 @@ namespace Drupal\views_test_data\Plugin\views\display; use Drupal\Component\Utility\Xss; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; /** @@ -74,7 +75,7 @@ public function optionsSummary(&$categories, &$options) { /** * Overrides Drupal\views\Plugin\views\display\DisplayPluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); switch ($form_state['section']) { @@ -93,7 +94,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Overrides Drupal\views\Plugin\views\display\DisplayPluginBase::validateOptionsForm(). */ - public function validateOptionsForm(&$form, &$form_state) { + public function validateOptionsForm(&$form, FormStateInterface $form_state) { parent::validateOptionsForm($form, $form_state); watchdog('views', $form_state['values']['test_option']); switch ($form_state['section']) { @@ -108,7 +109,7 @@ public function validateOptionsForm(&$form, &$form_state) { /** * Overrides Drupal\views\Plugin\views\display\DisplayPluginBase::submitOptionsForm(). */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { parent::submitOptionsForm($form, $form_state); switch ($form_state['section']) { case 'test_option': diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display_extender/DisplayExtenderTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display_extender/DisplayExtenderTest.php index b13a2f8a2787c849a20a53ef5ceaab559b39d88e..e7a35ea9f58f7b5891923c77338bc0b65cdecf8d 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display_extender/DisplayExtenderTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display_extender/DisplayExtenderTest.php @@ -7,6 +7,7 @@ namespace Drupal\views_test_data\Plugin\views\display_extender; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase; /** @@ -61,7 +62,7 @@ public function optionsSummary(&$categories, &$options) { /** * Overrides Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { switch ($form_state['section']) { case 'test_extender_test_option': $form['#title'] .= t('Test option'); @@ -77,7 +78,7 @@ public function buildOptionsForm(&$form, &$form_state) { /** * Overrides Drupal\views\Plugin\views\display\DisplayExtenderPluginBase::submitOptionsForm(). */ - public function submitOptionsForm(&$form, &$form_state) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { parent::submitOptionsForm($form, $form_state); switch ($form_state['section']) { case 'test_extender_test_option': diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php index 3abcc166a3d45e5ea58c6e1991012eb6b9e2cf60..c7e00c8de62ed21c0b0b521833d1b0c0347ed80d 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterTest.php @@ -7,6 +7,7 @@ namespace Drupal\views_test_data\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\filter\FilterPluginBase; /** @@ -31,7 +32,7 @@ protected function defineOptions() { * * @return array */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['test_enable'] = array( diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php index 77a9607284b67729bc931080b89dd48b7a20a584..5a1b61b3cae0bb7109df542d09a2130fc95ed8ef 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php @@ -7,6 +7,7 @@ namespace Drupal\views_test_data\Plugin\views\query; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\query\QueryPluginBase; use Drupal\views\Plugin\views\join\JoinPluginBase; use Drupal\views\ViewExecutable; @@ -39,7 +40,7 @@ protected function defineOptions() { /** * Implements \Drupal\views\Plugin\views\query\QueryPluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['test_setting'] = array( diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php index e6edd02d44154b49b22b0ff699d3cb598db2f047..cb759a34cb7c4e59158d93562d95ff333e481eaf 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/row/RowTest.php @@ -7,6 +7,7 @@ namespace Drupal\views_test_data\Plugin\views\row; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\row\RowPluginBase; /** @@ -44,7 +45,7 @@ protected function defineOptions() { /** * Overrides Drupal\views\Plugin\views\row\RowPluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['test_option'] = array( diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php index 02dd245e36f33795e6096efe1c3b9fdea5defde4..748dbd28c021e08c69536520f77ff474203c8067 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/StyleTest.php @@ -7,6 +7,7 @@ namespace Drupal\views_test_data\Plugin\views\style; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\style\StylePluginBase; /** @@ -52,7 +53,7 @@ protected function defineOptions() { /** * Overrides Drupal\views\Plugin\views\style\StylePluginBase::buildOptionsForm(). */ - public function buildOptionsForm(&$form, &$form_state) { + public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['test_option'] = array( diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 7ad98f59a64d164e9aad63416180943b8f125332..6cda6a9115a67860db192bf2bdcf3fceca1a8228 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -12,6 +12,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Cache\Cache; use Drupal\Core\Database\Query\AlterableInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; @@ -860,7 +861,7 @@ function views_pre_render_views_form_views_form($element) { * Since the exposed form is a GET form, we don't want it to send a wide * variety of information. */ -function views_form_views_exposed_form_alter(&$form, &$form_state) { +function views_form_views_exposed_form_alter(&$form, FormStateInterface $form_state) { $form['form_build_id']['#access'] = FALSE; $form['form_token']['#access'] = FALSE; $form['form_id']['#access'] = FALSE; @@ -995,7 +996,7 @@ function views_get_view_result($name, $display_id = NULL) { /** * Validation callback for query tags. */ -function views_element_validate_tags($element, &$form_state) { +function views_element_validate_tags($element, FormStateInterface $form_state) { $values = array_map('trim', explode(',', $element['#value'])); foreach ($values as $value) { if (preg_match("/[^a-z_]/", $value)) { diff --git a/core/modules/views_ui/admin.inc b/core/modules/views_ui/admin.inc index 1bd863661f04448d6ddfce398eb66a62338e8c49..504e93cfc5671da9f8b1cdace737a89f8ae11bfd 100644 --- a/core/modules/views_ui/admin.inc +++ b/core/modules/views_ui/admin.inc @@ -7,6 +7,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\Tags; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\Views; @@ -120,7 +121,7 @@ function views_ui_add_ajax_trigger(&$wrapping_element, $trigger_key, $refresh_pa /** * Processes a non-JavaScript fallback submit button to limit its validation errors. */ -function views_ui_add_limited_validation($element, &$form_state) { +function views_ui_add_limited_validation($element, FormStateInterface $form_state) { // Retrieve the AJAX triggering element so we can determine its parents. (We // know it's at the same level of the complete form array as the submit // button, so all we have to do to find it is swap out the submit button's @@ -158,7 +159,7 @@ function views_ui_add_limited_validation($element, &$form_state) { * be refreshed by AJAX, based on information stored in the corresponding * submit button form element. */ -function views_ui_add_ajax_wrapper($element, &$form_state) { +function views_ui_add_ajax_wrapper($element, FormStateInterface $form_state) { // Don't add the wrapper
if the same one was already inserted on this // form. if (empty($element['#views_ui_ajax_data']['duplicate_wrapper'])) { @@ -202,7 +203,7 @@ function views_ui_ajax_update_form($form, $form_state) { /** * Non-Javascript fallback for updating the add view form. */ -function views_ui_nojs_submit($form, &$form_state) { +function views_ui_nojs_submit($form, FormStateInterface $form_state) { $form_state['rebuild'] = TRUE; } @@ -220,7 +221,7 @@ function views_ui_nojs_submit($form, &$form_state) { * * @see taxonomy_autocomplete_validate() */ -function views_ui_taxonomy_autocomplete_validate($element, &$form_state) { +function views_ui_taxonomy_autocomplete_validate($element, FormStateInterface $form_state) { $value = array(); if ($tags = $element['#value']) { // Get the machine names of the vocabularies we will search, keyed by the @@ -261,7 +262,7 @@ function views_ui_taxonomy_autocomplete_validate($element, &$form_state) { * change whether this info is stored on the default display or on * the current display. */ -function views_ui_standard_display_dropdown(&$form, &$form_state, $section) { +function views_ui_standard_display_dropdown(&$form, FormStateInterface $form_state, $section) { $view = $form_state['view']; $display_id = $form_state['display_id']; $executable = $view->getExecutable(); @@ -352,7 +353,7 @@ function views_ui_build_form_path($form_state) { * @see _form_builder_handle_input_element() * @see _form_button_was_clicked() */ -function views_ui_form_button_was_clicked($element, &$form_state) { +function views_ui_form_button_was_clicked($element, FormStateInterface $form_state) { $process_input = empty($element['#disabled']) && ($form_state['programmed'] || ($form_state['process_input'] && (!isset($element['#access']) || $element['#access']))); if ($process_input && !isset($form_state['triggering_element']) && !empty($element['#is_button']) && isset($form_state['input'][$element['#name']]) && isset($element['#values']) && in_array($form_state['input'][$element['#name']], $element['#values'], TRUE)) { $form_state['triggering_element'] = $element; diff --git a/core/modules/views_ui/src/Form/AdvancedSettingsForm.php b/core/modules/views_ui/src/Form/AdvancedSettingsForm.php index 9ba103d40aca44819cea3a5892eae9048bdcc467..b84eb29b6be4a8b827c4ea5b959671f61788bd25 100644 --- a/core/modules/views_ui/src/Form/AdvancedSettingsForm.php +++ b/core/modules/views_ui/src/Form/AdvancedSettingsForm.php @@ -8,6 +8,7 @@ namespace Drupal\views_ui\Form; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Views; /** @@ -25,7 +26,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $config = $this->config('views.settings'); @@ -90,7 +91,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('views.settings') ->set('skip_cache', $form_state['values']['skip_cache']) ->set('sql_signature', $form_state['values']['sql_signature']) diff --git a/core/modules/views_ui/src/Form/Ajax/AddHandler.php b/core/modules/views_ui/src/Form/Ajax/AddHandler.php index 95b3fd04c2832338904ff115fdcb507eb8d757a3..4b69e937fb989ab4942bfd3be749f488b709e282 100644 --- a/core/modules/views_ui/src/Form/Ajax/AddHandler.php +++ b/core/modules/views_ui/src/Form/Ajax/AddHandler.php @@ -7,6 +7,7 @@ namespace Drupal\views_ui\Form\Ajax; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; use Drupal\views\ViewStorageInterface; use Drupal\views\Views; @@ -48,7 +49,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $view = $form_state['view']; $display_id = $form_state['display_id']; $type = $form_state['type']; diff --git a/core/modules/views_ui/src/Form/Ajax/Analyze.php b/core/modules/views_ui/src/Form/Ajax/Analyze.php index 41a7d94b2f597c35c7957dcbf729b52ab5d1dd98..23840cb3dfaf68a39362d798b86321346d57f100 100644 --- a/core/modules/views_ui/src/Form/Ajax/Analyze.php +++ b/core/modules/views_ui/src/Form/Ajax/Analyze.php @@ -7,6 +7,7 @@ namespace Drupal\views_ui\Form\Ajax; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Views; use Drupal\views_ui\ViewUI; use Drupal\views\Analyzer; @@ -33,7 +34,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $view = $form_state['view']; $form['#title'] = $this->t('View analysis'); @@ -57,7 +58,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { /** @var $view \Drupal\views_ui\ViewUI */ $view = $form_state['view']; $form_state['redirect_route'] = $view->urlInfo('edit-form'); diff --git a/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php b/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php index 8533e6958d49e6986dfa6689de2a8e31dc1b46f5..066efe7899d3a3169ac6a07c0d496aedeeeb7a3b 100644 --- a/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php +++ b/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php @@ -7,6 +7,7 @@ namespace Drupal\views_ui\Form\Ajax; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewStorageInterface; use Drupal\views\ViewExecutable; use Drupal\views\Views; @@ -50,7 +51,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $view = $form_state['view']; $display_id = $form_state['display_id']; $type = $form_state['type']; @@ -189,7 +190,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $form_state['handler']->validateOptionsForm($form['options'], $form_state); if (form_get_errors($form_state)) { @@ -200,7 +201,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Run it through the handler's submit function. $form_state['handler']->submitOptionsForm($form['options'], $form_state); $item = $form_state['handler']->options; @@ -261,7 +262,7 @@ public function submitForm(array &$form, array &$form_state) { /** * Submit handler for removing an item from a view */ - public function remove(&$form, &$form_state) { + public function remove(&$form, FormStateInterface $form_state) { // Store the item back on the view list($was_defaulted, $is_defaulted) = $form_state['view']->getOverrideValues($form, $form_state); $executable = $form_state['view']->getExecutable(); diff --git a/core/modules/views_ui/src/Form/Ajax/ConfigHandlerExtra.php b/core/modules/views_ui/src/Form/Ajax/ConfigHandlerExtra.php index 02ed828a0f04dc25648c5fb33ab67ee06766b383..16bc2306365c19378e7011638fc2f66a3712f9bf 100644 --- a/core/modules/views_ui/src/Form/Ajax/ConfigHandlerExtra.php +++ b/core/modules/views_ui/src/Form/Ajax/ConfigHandlerExtra.php @@ -7,6 +7,7 @@ namespace Drupal\views_ui\Form\Ajax; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewStorageInterface; use Drupal\views\ViewExecutable; @@ -49,7 +50,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $view = $form_state['view']; $display_id = $form_state['display_id']; $type = $form_state['type']; @@ -92,14 +93,14 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $form_state['handler']->validateExtraOptionsForm($form['options'], $form_state); } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { // Run it through the handler's submit function. $form_state['handler']->submitExtraOptionsForm($form['options'], $form_state); $item = $form_state['handler']->options; diff --git a/core/modules/views_ui/src/Form/Ajax/ConfigHandlerGroup.php b/core/modules/views_ui/src/Form/Ajax/ConfigHandlerGroup.php index f00d26ffd185b006c39456d3a78183aaa47cc17b..fba13ea4e415d23100239b1019b769c974acac12 100644 --- a/core/modules/views_ui/src/Form/Ajax/ConfigHandlerGroup.php +++ b/core/modules/views_ui/src/Form/Ajax/ConfigHandlerGroup.php @@ -7,6 +7,7 @@ namespace Drupal\views_ui\Form\Ajax; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Views; use Drupal\views\ViewStorageInterface; use Drupal\views\ViewExecutable; @@ -50,7 +51,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $view = $form_state['view']; $display_id = $form_state['display_id']; $type = $form_state['type']; @@ -95,7 +96,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $item = &$form_state['handler']->options; $type = $form_state['type']; diff --git a/core/modules/views_ui/src/Form/Ajax/Display.php b/core/modules/views_ui/src/Form/Ajax/Display.php index c2dbad62b334db05a0e534bd0bc493126427e9f8..c653fc1763af47c36f81ae61dc4d813ff1cef4f8 100644 --- a/core/modules/views_ui/src/Form/Ajax/Display.php +++ b/core/modules/views_ui/src/Form/Ajax/Display.php @@ -7,6 +7,7 @@ namespace Drupal\views_ui\Form\Ajax; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewStorageInterface; /** @@ -35,9 +36,9 @@ public function getFormKey() { * $form_state['type']. */ public function getFormState(ViewStorageInterface $view, $display_id, $js) { - return array( - 'section' => $this->type, - ) + parent::getFormState($view, $display_id, $js); + $form_state = parent::getFormState($view, $display_id, $js); + $form_state['section'] = $this->type; + return $form_state; } /** @@ -58,7 +59,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $view = $form_state['view']; $display_id = $form_state['display_id']; @@ -95,7 +96,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { $form_state['view']->getExecutable()->displayHandlers->get($form_state['display_id'])->validateOptionsForm($form['options'], $form_state); if (form_get_errors($form_state)) { @@ -106,7 +107,7 @@ public function validateForm(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $form_state['view']->getExecutable()->displayHandlers->get($form_state['display_id'])->submitOptionsForm($form['options'], $form_state); $form_state['view']->cacheSet(); diff --git a/core/modules/views_ui/src/Form/Ajax/EditDetails.php b/core/modules/views_ui/src/Form/Ajax/EditDetails.php index 6269af1f24173a832ae1ee633e8ef736b16eb3d1..f6684a2d1f6ad4bac6d51b928c2f6f280e9b8cdb 100644 --- a/core/modules/views_ui/src/Form/Ajax/EditDetails.php +++ b/core/modules/views_ui/src/Form/Ajax/EditDetails.php @@ -7,6 +7,7 @@ namespace Drupal\views_ui\Form\Ajax; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Views; use Drupal\views_ui\ViewUI; @@ -32,7 +33,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $view = $form_state['view']; $form['#title'] = $this->t('Name and description'); @@ -73,7 +74,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $view = $form_state['view']; foreach ($form_state['values'] as $key => $value) { // Only save values onto the view if they're actual view properties diff --git a/core/modules/views_ui/src/Form/Ajax/Rearrange.php b/core/modules/views_ui/src/Form/Ajax/Rearrange.php index 86b327443bec71eea69f29353df04fb982efa0dc..5e3d7090e63434427ef6e8194ae5a2678c91ea72 100644 --- a/core/modules/views_ui/src/Form/Ajax/Rearrange.php +++ b/core/modules/views_ui/src/Form/Ajax/Rearrange.php @@ -7,6 +7,7 @@ namespace Drupal\views_ui\Form\Ajax; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewStorageInterface; use Drupal\views\ViewExecutable; @@ -47,7 +48,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $view = $form_state['view']; $display_id = $form_state['display_id']; $type = $form_state['type']; @@ -134,7 +135,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $types = ViewExecutable::getHandlerTypes(); $display = &$form_state['view']->getExecutable()->displayHandlers->get($form_state['display_id']); diff --git a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php index e15e4404fdfe19e7b51b429de92d0dfaf1d40503..54ba06e86a6cd274892d04411b1473957d8ed45b 100644 --- a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php +++ b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php @@ -8,6 +8,7 @@ namespace Drupal\views_ui\Form\Ajax; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\views_ui\ViewUI; use Drupal\views\ViewExecutable; @@ -33,7 +34,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $view = $form_state['view']; $display_id = $form_state['display_id']; $type = 'filter'; @@ -213,7 +214,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $types = ViewExecutable::getHandlerTypes(); $display = &$form_state['view']->getExecutable()->displayHandlers->get($form_state['display_id']); $remember_groups = array(); diff --git a/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php b/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php index 61e5693956d4f209a3cc3c8c073409d5f9d41ea4..d9bfd29d8011148e997217a5b25faac77560cf8c 100644 --- a/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php +++ b/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php @@ -7,6 +7,7 @@ namespace Drupal\views_ui\Form\Ajax; +use Drupal\Core\Form\FormStateInterface; use Drupal\views_ui\ViewUI; /** @@ -31,7 +32,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { /** @var $view \Drupal\views\ViewStorageInterface */ $view = $form_state['view']; $display_id = $form_state['display_id']; @@ -148,7 +149,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { /** @var $view \Drupal\views_ui\ViewUI */ $view = $form_state['view']; $order = array(); diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php index f7d4b8687e28615e4c2d22c8795281a09757ccfb..f9050607144c2c44797a3a3170633b1315f6ce41 100644 --- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php +++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php @@ -8,6 +8,8 @@ namespace Drupal\views_ui\Form\Ajax; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormState; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewStorageInterface; use Drupal\views\Ajax; use Drupal\Core\Ajax\AjaxResponse; @@ -63,7 +65,7 @@ protected function setType($type) { public function getFormState(ViewStorageInterface $view, $display_id, $js) { // $js may already have been converted to a Boolean. $ajax = is_string($js) ? $js === 'ajax' : $js; - return array( + return new FormState(array( 'form_id' => $this->getFormId(), 'form_key' => $this->getFormKey(), 'ajax' => $ajax, @@ -76,7 +78,7 @@ public function getFormState(ViewStorageInterface $view, $display_id, $js) { 'args' => array(), 'callback_object' => $this, ), - ); + )); } /** @@ -179,13 +181,13 @@ public function getForm(ViewStorageInterface $view, $display_id, $js) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormInterface.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormInterface.php index d109ea394028fa202f4872aa24effca9f4ebdbdd..8bc8adfbf61a637f5f2f4c0dae44ae1c8f0078c5 100644 --- a/core/modules/views_ui/src/Form/Ajax/ViewsFormInterface.php +++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormInterface.php @@ -32,8 +32,8 @@ public function getFormKey(); * If this is an AJAX form, it will be the string 'ajax'. Otherwise, it will * be 'nojs'. This determines the response. * - * @return array - * An associative array containing the current state of the form. + * @return \Drupal\Core\Form\FormStateInterface + * The current state of the form. */ public function getFormState(ViewStorageInterface $view, $display_id, $js); diff --git a/core/modules/views_ui/src/Form/BasicSettingsForm.php b/core/modules/views_ui/src/Form/BasicSettingsForm.php index f898f9ae8f8555968f95374497a76d6c77d57bf9..6b15d791295b337cf581ce9e00bbee2cf3b1ebe5 100644 --- a/core/modules/views_ui/src/Form/BasicSettingsForm.php +++ b/core/modules/views_ui/src/Form/BasicSettingsForm.php @@ -8,6 +8,7 @@ namespace Drupal\views_ui\Form; use Drupal\Core\Form\ConfigFormBase; +use Drupal\Core\Form\FormStateInterface; /** * Form builder for the admin display defaults page. @@ -24,7 +25,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $config = $this->config('views.settings'); @@ -126,7 +127,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('views.settings') ->set('ui.show.master_display', $form_state['values']['ui_show_master_display']) ->set('ui.show.advanced_column', $form_state['values']['ui_show_advanced_column']) diff --git a/core/modules/views_ui/src/Form/BreakLockForm.php b/core/modules/views_ui/src/Form/BreakLockForm.php index e981a48ec5ad1b4298342b73175839ba260bb68b..b95b65e5141dcea8abaf7ae15a33c6f5d4d5fbfc 100644 --- a/core/modules/views_ui/src/Form/BreakLockForm.php +++ b/core/modules/views_ui/src/Form/BreakLockForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\user\TempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -98,7 +99,7 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { if (!$this->tempStore->getMetadata($this->entity->id())) { $form['message']['#markup'] = $this->t('There is no lock on view %name to break.', array('%name' => $this->entity->id())); return $form; @@ -109,7 +110,7 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $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/src/ViewAddForm.php b/core/modules/views_ui/src/ViewAddForm.php index fac46e3ebc6912c217c55454de3d5be22daf13e9..9c2c6624f49cd9b972f637d40295f75825f9def5 100644 --- a/core/modules/views_ui/src/ViewAddForm.php +++ b/core/modules/views_ui/src/ViewAddForm.php @@ -7,6 +7,7 @@ namespace Drupal\views_ui; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\wizard\WizardPluginBase; use Drupal\views\Plugin\views\wizard\WizardException; use Drupal\views\Plugin\ViewsPluginManager; @@ -53,7 +54,7 @@ protected function prepareEntity() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $form['#attached']['css'] = static::getAdminCSS(); $form['#attached']['js'][] = drupal_get_path('module', 'views_ui') . '/js/views-admin.js'; $form['#attributes']['class'] = array('views-admin'); @@ -145,7 +146,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); $actions['submit']['#value'] = $this->t('Save and edit'); @@ -163,7 +164,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { $wizard_type = $form_state['values']['show']['wizard_key']; $wizard_instance = $this->wizardManager->createInstance($wizard_type); $form_state['wizard'] = $wizard_instance->getPluginDefinition(); @@ -180,7 +181,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { try { /** @var $wizard \Drupal\views\Plugin\views\wizard\WizardInterface */ $wizard = $form_state['wizard_instance']; @@ -202,10 +203,10 @@ public function submit(array $form, array &$form_state) { * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function cancel(array $form, array &$form_state) { + public function cancel(array $form, FormStateInterface $form_state) { $form_state['redirect_route']['route_name'] = 'views_ui.list'; } diff --git a/core/modules/views_ui/src/ViewDeleteForm.php b/core/modules/views_ui/src/ViewDeleteForm.php index fa446eeacb0a0ff55899929d617be40f8ee2b149..555d1a8229bd56423e367de900c140b0c45a5656 100644 --- a/core/modules/views_ui/src/ViewDeleteForm.php +++ b/core/modules/views_ui/src/ViewDeleteForm.php @@ -8,6 +8,7 @@ namespace Drupal\views_ui; use Drupal\Core\Entity\EntityConfirmFormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** @@ -39,13 +40,13 @@ public function getConfirmText() { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); $this->entity->delete(); drupal_set_message($this->t('View %name deleted',array('%name' => $this->entity->label()))); - $form_state['redirect_route'] = $this->getCancelUrl(); + $form_state->setRedirect($this->getCancelUrl()); } } diff --git a/core/modules/views_ui/src/ViewDuplicateForm.php b/core/modules/views_ui/src/ViewDuplicateForm.php index c46101a8f09354ccc0ef4ce7ae6a10823657a533..b4b5eef5e5930fec13c81c58f3112608032d3d7a 100644 --- a/core/modules/views_ui/src/ViewDuplicateForm.php +++ b/core/modules/views_ui/src/ViewDuplicateForm.php @@ -7,6 +7,8 @@ namespace Drupal\views_ui; +use Drupal\Core\Form\FormStateInterface; + /** * Form controller for the Views duplicate form. */ @@ -22,7 +24,7 @@ protected function prepareEntity() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { parent::form($form, $form_state); $form['#title'] = $this->t('Duplicate of @label', array('@label' => $this->entity->label())); @@ -52,7 +54,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions['submit'] = array( '#type' => 'submit', '#value' => $this->t('Duplicate'), @@ -66,7 +68,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { $original = parent::submit($form, $form_state); $this->entity = $original->createDuplicate(); $this->entity->set('id', $form_state['values']['id']); diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index ebb273606e3f48b31ebb920ec7f856f085c537c8..677ef1ef43436e8d3b95dcb7a61588b120ae72aa 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -14,6 +14,7 @@ use Drupal\Core\Datetime\Date as DateFormatter; use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\user\TempStoreFactory; use Drupal\views\Views; @@ -76,7 +77,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $view = $this->entity; $display_id = $this->displayID; // Do not allow the form to be cached, because $form_state['view'] can become @@ -230,7 +231,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $actions = parent::actions($form, $form_state); unset($actions['delete']); @@ -251,7 +252,7 @@ protected function actions(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { + public function validate(array $form, FormStateInterface $form_state) { parent::validate($form, $form_state); $view = $this->entity; @@ -268,7 +269,7 @@ public function validate(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); $view = $this->entity; @@ -338,10 +339,10 @@ public function submit(array $form, array &$form_state) { * * @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. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. */ - public function cancel(array $form, array &$form_state) { + public function cancel(array $form, FormStateInterface $form_state) { // Remove this view from cache so edits will be lost. $view = $this->entity; $this->tempStore->delete($view->id()); @@ -576,7 +577,7 @@ public function getDisplayDetails($view, $display) { /** * Submit handler to add a restore a removed display to a view. */ - public function submitDisplayUndoDelete($form, &$form_state) { + public function submitDisplayUndoDelete($form, FormStateInterface $form_state) { $view = $this->entity; // Create the new display $id = $form_state['display_id']; @@ -597,7 +598,7 @@ public function submitDisplayUndoDelete($form, &$form_state) { /** * Submit handler to enable a disabled display. */ - public function submitDisplayEnable($form, &$form_state) { + public function submitDisplayEnable($form, FormStateInterface $form_state) { $view = $this->entity; $id = $form_state['display_id']; // setOption doesn't work because this would might affect upper displays @@ -616,7 +617,7 @@ public function submitDisplayEnable($form, &$form_state) { /** * Submit handler to disable display. */ - public function submitDisplayDisable($form, &$form_state) { + public function submitDisplayDisable($form, FormStateInterface $form_state) { $view = $this->entity; $id = $form_state['display_id']; $view->getExecutable()->displayHandlers->get($id)->setOption('enabled', FALSE); @@ -634,7 +635,7 @@ public function submitDisplayDisable($form, &$form_state) { /** * Submit handler to delete a display from a view. */ - public function submitDisplayDelete($form, &$form_state) { + public function submitDisplayDelete($form, FormStateInterface $form_state) { $view = $this->entity; $display_id = $form_state['display_id']; @@ -776,7 +777,7 @@ public function renderDisplayTop(ViewUI $view) { * contextual link). This handler can be added to buttons whose form submission * should not yet redirect to the destination. */ - public function submitDelayDestination($form, &$form_state) { + public function submitDelayDestination($form, FormStateInterface $form_state) { $query = $this->requestStack->getCurrentRequest()->query; // @todo: Revisit this when http://drupal.org/node/1668866 is in. $destination = $query->get('destination'); @@ -799,7 +800,7 @@ public function submitDelayDestination($form, &$form_state) { /** * Submit handler to duplicate a display for a view. */ - public function submitDisplayDuplicate($form, &$form_state) { + public function submitDisplayDuplicate($form, FormStateInterface $form_state) { $view = $this->entity; $display_id = $this->displayID; @@ -826,7 +827,7 @@ public function submitDisplayDuplicate($form, &$form_state) { /** * Submit handler to add a display to a view. */ - public function submitDisplayAdd($form, &$form_state) { + public function submitDisplayAdd($form, FormStateInterface $form_state) { $view = $this->entity; // Create the new display. $parents = $form_state['triggering_element']['#parents']; @@ -848,7 +849,7 @@ public function submitDisplayAdd($form, &$form_state) { /** * Submit handler to Duplicate a display as another display type. */ - public function submitDuplicateDisplayAsType($form, &$form_state) { + public function submitDuplicateDisplayAsType($form, FormStateInterface $form_state) { $view = $this->entity; $display_id = $this->displayID; diff --git a/core/modules/views_ui/src/ViewFormBase.php b/core/modules/views_ui/src/ViewFormBase.php index 61b872f77721db902a7e4ebc9d289a0432ec1dac..e9841b78d7d465825a1290ac11edb74c58d29dae 100644 --- a/core/modules/views_ui/src/ViewFormBase.php +++ b/core/modules/views_ui/src/ViewFormBase.php @@ -8,6 +8,7 @@ namespace Drupal\views_ui; use Drupal\Core\Entity\EntityForm; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; @@ -26,7 +27,7 @@ abstract class ViewFormBase extends EntityForm { /** * {@inheritdoc} */ - public function init(array &$form_state) { + public function init(FormStateInterface $form_state) { parent::init($form_state); if ($display_id = \Drupal::request()->attributes->get('display_id')) { @@ -35,7 +36,7 @@ public function init(array &$form_state) { // @todo Remove the need for this. form_load_include($form_state, 'inc', 'views_ui', 'admin'); - $form_state['view'] = $this->entity; + $form_state->set('view', $this->entity); } /** diff --git a/core/modules/views_ui/src/ViewPreviewForm.php b/core/modules/views_ui/src/ViewPreviewForm.php index e2d2899e37721d2017fbbd2063884a59cc3d1e68..a8a08557604825f7f84f0970860093cd9918e4bd 100644 --- a/core/modules/views_ui/src/ViewPreviewForm.php +++ b/core/modules/views_ui/src/ViewPreviewForm.php @@ -7,6 +7,7 @@ namespace Drupal\views_ui; +use Drupal\Core\Form\FormStateInterface; use Drupal\user\TempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -44,7 +45,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $view = $this->entity; $form['#prefix'] = '
'; @@ -100,7 +101,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - protected function actions(array $form, array &$form_state) { + protected function actions(array $form, FormStateInterface $form_state) { $view = $this->entity; return array( '#attributes' => array( @@ -126,7 +127,7 @@ protected function actions(array $form, array &$form_state) { /** * Form submission handler for the Preview button. */ - public function submitPreview($form, &$form_state) { + public function submitPreview($form, FormStateInterface $form_state) { // Rebuild the form with a pristine $view object. $view = $this->entity; // Attempt to load the view from temp store, otherwise create a new one. diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index 81f85fe2ce9fe142b26116cee2b98793798c28b9..ab36fdbcd1c728cfc7054e8b0dba85b71d0be543 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -11,6 +11,7 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Timer; use Drupal\Component\Utility\Xss; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Views; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\views\ViewExecutable; @@ -241,7 +242,7 @@ public function isUninstalling() { * to apply to the default display or to the current display, and dispatches * control appropriately. */ - public function standardSubmit($form, &$form_state) { + public function standardSubmit($form, FormStateInterface $form_state) { // Determine whether the values the user entered are intended to apply to // the current display or the default display. @@ -296,7 +297,7 @@ public function standardSubmit($form, &$form_state) { /** * Submit handler for cancel button */ - public function standardCancel($form, &$form_state) { + public function standardCancel($form, FormStateInterface $form_state) { if (!empty($this->changed) && isset($this->form_cache)) { unset($this->form_cache); $this->cacheSet(); @@ -313,7 +314,7 @@ public function standardCancel($form, &$form_state) { * TODO: Is the hidden op operator still here somewhere, or is that part of the * docblock outdated? */ - public function getStandardButtons(&$form, &$form_state, $form_id, $name = NULL) { + public function getStandardButtons(&$form, FormStateInterface $form_state, $form_id, $name = NULL) { $form['actions'] = array( '#type' => 'actions', ); @@ -475,7 +476,7 @@ public function addFormToStack($key, $display_id, $type, $id = NULL, $top = FALS /** * Submit handler for adding new item(s) to a view. */ - public function submitItemAdd($form, &$form_state) { + public function submitItemAdd($form, FormStateInterface $form_state) { $type = $form_state['type']; $types = ViewExecutable::getHandlerTypes(); $section = $types[$type]['plural']; diff --git a/core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php b/core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php index add47b1589502ef2ccbbab9a5286f8ca6bf75c7d..4ec28d2b5198ed8a0967c1873b47162de944bba2 100644 --- a/core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php +++ b/core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php @@ -7,6 +7,7 @@ namespace Drupal\Tests\Core\Display; +use Drupal\Core\Form\FormState; use Drupal\Tests\UnitTestCase; /** @@ -142,6 +143,7 @@ public function testSubmitConfigurationForm() { $form = array(); $label = $this->randomName(); + $form_state = new FormState(); $form_state['values']['label'] = $label; $display_variant->submitConfigurationForm($form, $form_state); $this->assertSame($label, $display_variant->label()); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php index 14622d23513295da89895fbeff9780285f470a1c..2e7ab80e458d067468cd5d7474f7a5d8b8de701b 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php @@ -60,7 +60,7 @@ public function testGetForm() { $this->formBuilder->expects($this->once()) ->method('buildForm') - ->with($form_controller, $this->isType('array')) + ->with($form_controller, $this->isInstanceOf('Drupal\Core\Form\FormStateInterface')) ->will($this->returnValue('the form contents')); $entity = $this->getMock('Drupal\Core\Entity\EntityInterface'); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php index 40a000d013ffb0c1a5971799b5b0c7407647699a..23bd5c920193b910865e82272d8e8edbee41f944 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php @@ -12,6 +12,7 @@ use Drupal\Core\Entity\EntityResolverManager; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Tests\UnitTestCase; use Symfony\Component\Routing\Route; @@ -418,13 +419,13 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, EntityInterface $entity_test = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity_test = NULL) { } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } @@ -443,13 +444,13 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $entity_test = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $entity_test = NULL) { } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } @@ -465,19 +466,19 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, EntityInterface $entity_test = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity_test = NULL) { } /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function validateForm(array &$form, FormStateInterface $form_state) { } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { + public function submitForm(array &$form, FormStateInterface $form_state) { } } diff --git a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php index 4702b9da1a47c5f1ed27a79f504d88ca995951f2..fede0c1a53bb4eefbd87afe524fa26c3f62d6416 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php @@ -9,6 +9,8 @@ use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormState; +use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -26,11 +28,12 @@ class FormBuilderTest extends FormTestBase { public function testGetFormIdWithString() { $form_arg = 'foo'; - $form_state = array(); + $clean_form_state = new FormState(); + $form_state = new FormState(); $form_id = $this->formBuilder->getFormId($form_arg, $form_state); $this->assertSame($form_arg, $form_id); - $this->assertEmpty($form_state); + $this->assertSame($clean_form_state, $form_state); } /** @@ -39,7 +42,7 @@ public function testGetFormIdWithString() { public function testGetFormIdWithClassName() { $form_arg = 'Drupal\Tests\Core\Form\TestForm'; - $form_state = array(); + $form_state = new FormState(); $form_id = $this->formBuilder->getFormId($form_arg, $form_state); $this->assertSame('test_form', $form_id); @@ -55,7 +58,7 @@ public function testGetFormIdWithInjectedClassName() { $form_arg = 'Drupal\Tests\Core\Form\TestFormInjected'; - $form_state = array(); + $form_state = new FormState(); $form_id = $this->formBuilder->getFormId($form_arg, $form_state); $this->assertSame('test_form', $form_id); @@ -70,7 +73,7 @@ public function testGetFormIdWithObject() { $form_arg = $this->getMockForm($expected_form_id); - $form_state = array(); + $form_state = new FormState(); $form_id = $this->formBuilder->getFormId($form_arg, $form_state); $this->assertSame($expected_form_id, $form_id); @@ -92,7 +95,7 @@ public function testGetFormIdWithBaseForm() { ->method('getBaseFormId') ->will($this->returnValue($base_form_id)); - $form_state = array(); + $form_state = new FormState(); $form_id = $this->formBuilder->getFormId($form_arg, $form_state); $this->assertSame($expected_form_id, $form_id); @@ -119,11 +122,11 @@ public function testHandleFormStateResponse($class, $form_state_key) { $form_arg = $this->getMockForm($form_id, $expected_form); $form_arg->expects($this->any()) ->method('submitForm') - ->will($this->returnCallback(function ($form, &$form_state) use ($response, $form_state_key) { + ->will($this->returnCallback(function ($form, FormStateInterface $form_state) use ($response, $form_state_key) { $form_state[$form_state_key] = $response; })); - $form_state = array(); + $form_state = new FormState(); try { $form_state['values'] = array(); $form_state['input']['form_id'] = $form_id; @@ -171,13 +174,13 @@ public function testHandleRedirectWithResponse() { $form_arg = $this->getMockForm($form_id, $expected_form); $form_arg->expects($this->any()) ->method('submitForm') - ->will($this->returnCallback(function ($form, &$form_state) use ($response, $redirect) { + ->will($this->returnCallback(function ($form, FormStateInterface $form_state) use ($response, $redirect) { // Set both the response and the redirect. $form_state['response'] = $response; $form_state['redirect'] = $redirect; })); - $form_state = array(); + $form_state = new FormState(); try { $form_state['values'] = array(); $form_state['input']['form_id'] = $form_id; @@ -226,7 +229,7 @@ public function testGetFormWithClassString() { $form_id = '\Drupal\Tests\Core\Form\TestForm'; $object = new TestForm(); $form = array(); - $form_state = array(); + $form_state = new FormState(); $expected_form = $object->buildForm($form, $form_state); $form = $this->formBuilder->getForm($form_id); @@ -256,7 +259,7 @@ public function testBuildFormWithClassString() { $form_id = '\Drupal\Tests\Core\Form\TestForm'; $object = new TestForm(); $form = array(); - $form_state = array(); + $form_state = new FormState(); $expected_form = $object->buildForm($form, $form_state); $form = $this->formBuilder->buildForm($form_id, $form_state); @@ -273,7 +276,7 @@ public function testBuildFormWithObject() { $form_arg = $this->getMockForm($form_id, $expected_form); - $form_state = array(); + $form_state = new FormState(); $form = $this->formBuilder->buildForm($form_arg, $form_state); $this->assertFormElement($expected_form, $form, 'test'); $this->assertSame($form_id, $form_state['build_info']['form_id']); @@ -297,7 +300,7 @@ public function testRebuildForm() { ->will($this->returnValue($expected_form)); // Do an initial build of the form and track the build ID. - $form_state = array(); + $form_state = new FormState(); $form = $this->formBuilder->buildForm($form_arg, $form_state); $original_build_id = $form['#build_id']; @@ -348,7 +351,7 @@ public function testGetCache() { ->will($this->returnValue(TRUE)); // Do an initial build of the form and track the build ID. - $form_state = array(); + $form_state = new FormState(); $form_state['build_info']['args'] = array(); $form_state['build_info']['files'] = array(array('module' => 'node', 'type' => 'pages.inc')); $form_state['cache'] = TRUE; @@ -365,10 +368,11 @@ public function testGetCache() { ->will($this->returnValue($cached_form)); $this->formStateCache->expects($this->once()) ->method('get') - ->will($this->returnValue($form_state)); + ->will($this->returnValue($form_state->getCacheableArray())); // The final form build will not trigger any actual form building, but will // use the form cache. + $form_state['executed'] = TRUE; $form_state['input']['form_id'] = $form_id; $form_state['input']['form_build_id'] = $form['#build_id']; $this->formBuilder->buildForm($form_arg, $form_state); @@ -392,7 +396,7 @@ public function testSendResponse() { $form_arg = $this->getMockForm($form_id, $expected_form); // Do an initial build of the form and track the build ID. - $form_state = array(); + $form_state = new FormState(); $this->formBuilder->buildForm($form_arg, $form_state); } @@ -413,11 +417,15 @@ public function testUniqueHtmlId() { ->method('buildForm') ->will($this->returnValue($expected_form)); - $form_state = array(); + $form_state = $this->getMockBuilder('Drupal\Core\Form\FormState') + ->setMethods(array('drupalSetMessage')) + ->getMock(); $form = $this->simulateFormSubmission($form_id, $form_arg, $form_state); $this->assertSame($form_id, $form['#id']); - $form_state = array(); + $form_state = $this->getMockBuilder('Drupal\Core\Form\FormState') + ->setMethods(array('drupalSetMessage')) + ->getMock(); $form = $this->simulateFormSubmission($form_id, $form_arg, $form_state); $this->assertSame("$form_id--2", $form['#id']); } @@ -429,11 +437,11 @@ public function getFormId() { return 'test_form'; } - public function buildForm(array $form, array &$form_state) { + public function buildForm(array $form, FormStateInterface $form_state) { return test_form_id(); } - public function validateForm(array &$form, array &$form_state) { } - public function submitForm(array &$form, array &$form_state) { } + public function validateForm(array &$form, FormStateInterface $form_state) { } + public function submitForm(array &$form, FormStateInterface $form_state) { } } class TestFormInjected extends TestForm implements ContainerInjectionInterface { public static function create(ContainerInterface $container) { @@ -444,7 +452,9 @@ public static function create(ContainerInterface $container) { } namespace { - function test_form_id_custom_submit(array &$form, array &$form_state) { + use Drupal\Core\Form\FormStateInterface; + + function test_form_id_custom_submit(array &$form, FormStateInterface $form_state) { } // @todo Remove once watchdog() is removed. if (!defined('WATCHDOG_ERROR')) { diff --git a/core/tests/Drupal/Tests/Core/Form/FormStateTest.php b/core/tests/Drupal/Tests/Core/Form/FormStateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3c60ddfb2b13825e1525d8cbd743c9d8e732c2bc --- /dev/null +++ b/core/tests/Drupal/Tests/Core/Form/FormStateTest.php @@ -0,0 +1,162 @@ +getRedirect(); + $this->assertEquals($expected, $redirect); + } + + /** + * Provides test data for testing the getRedirect() method. + * + * @return array + * Returns some test data. + */ + public function providerTestGetRedirect() { + $data = array(); + $data[] = array(array(), NULL); + + $data[] = array(array('redirect' => 'foo'), 'foo'); + $data[] = array(array('redirect' => array('foo')), array('foo')); + $data[] = array(array('redirect' => array('bar', array('query' => array('foo' => 'baz')))), array('bar', array('query' => array('foo' => 'baz')))); + $data[] = array(array('redirect' => array('baz', array(), 301)), array('baz', array(), 301)); + + $redirect = new RedirectResponse('/example'); + $data[] = array(array('redirect' => $redirect), $redirect); + + $data[] = array(array('redirect_route' => array('route_name' => 'test_route_a')), new Url('test_route_a', array(), array('absolute' => TRUE))); + $data[] = array(array('redirect_route' => array('route_name' => 'test_route_b', 'route_parameters' => array('key' => 'value'))), new Url('test_route_b', array('key' => 'value'), array('absolute' => TRUE))); + $data[] = array(array('redirect_route' => new Url('test_route_b', array('key' => 'value'))), new Url('test_route_b', array('key' => 'value'), array('absolute' => TRUE))); + + $data[] = array(array('programmed' => TRUE), NULL); + $data[] = array(array('rebuild' => TRUE), NULL); + $data[] = array(array('no_redirect' => TRUE), NULL); + $data[] = array(array('redirect' => FALSE), NULL); + + return $data; + } + + /** + * Tests the setError() method. + * + * @covers ::setError + */ + public function testSetError() { + $form_state = $this->getMockBuilder('Drupal\Core\Form\FormState') + ->setMethods(array('drupalSetMessage')) + ->getMock(); + $form_state->expects($this->once()) + ->method('drupalSetMessage') + ->willReturn('Fail'); + + $element['#parents'] = array('foo', 'bar'); + $form_state->setError($element, 'Fail'); + } + + /** + * Tests the getError() method. + * + * @covers ::getError + * + * @dataProvider providerTestGetError + */ + public function testGetError($errors, $parents, $error = NULL) { + $element['#parents'] = $parents; + $form_state = new FormState(array( + 'errors' => $errors, + )); + $this->assertSame($error, $form_state->getError($element)); + } + + public function providerTestGetError() { + return array( + array(array(), array('foo')), + array(array('foo][bar' => 'Fail'), array()), + array(array('foo][bar' => 'Fail'), array('foo')), + array(array('foo][bar' => 'Fail'), array('bar')), + array(array('foo][bar' => 'Fail'), array('baz')), + array(array('foo][bar' => 'Fail'), array('foo', 'bar'), 'Fail'), + array(array('foo][bar' => 'Fail'), array('foo', 'bar', 'baz'), 'Fail'), + array(array('foo][bar' => 'Fail 2'), array('foo')), + array(array('foo' => 'Fail 1', 'foo][bar' => 'Fail 2'), array('foo'), 'Fail 1'), + array(array('foo' => 'Fail 1', 'foo][bar' => 'Fail 2'), array('foo', 'bar'), 'Fail 1'), + ); + } + + /** + * @covers ::setErrorByName + * + * @dataProvider providerTestSetErrorByName + */ + public function testSetErrorByName($limit_validation_errors, $expected_errors, $set_message = FALSE) { + $form_state = $this->getMockBuilder('Drupal\Core\Form\FormState') + ->setConstructorArgs(array(array('limit_validation_errors' => $limit_validation_errors))) + ->setMethods(array('drupalSetMessage')) + ->getMock(); + $form_state->clearErrors(); + $form_state->expects($set_message ? $this->once() : $this->never()) + ->method('drupalSetMessage'); + + $form_state->setErrorByName('test', 'Fail 1'); + $form_state->setErrorByName('test', 'Fail 2'); + $form_state->setErrorByName('options'); + + $this->assertSame(!empty($expected_errors), $form_state::hasAnyErrors()); + $this->assertSame($expected_errors, $form_state['errors']); + } + + public function providerTestSetErrorByName() { + return array( + // Only validate the 'options' element. + array(array(array('options')), array('options' => '')), + // Do not limit an validation, and, ensuring the first error is returned + // for the 'test' element. + array(NULL, array('test' => 'Fail 1', 'options' => ''), TRUE), + // Limit all validation. + array(array(), array()), + ); + } + + /** + * Tests that form errors during submission throw an exception. + * + * @covers ::setErrorByName + * + * @expectedException \LogicException + * @expectedExceptionMessage Form errors cannot be set after form validation has finished. + */ + public function testFormErrorsDuringSubmission() { + $form_state = $this->getMockBuilder('Drupal\Core\Form\FormState') + ->setConstructorArgs(array(array('validation_complete' => TRUE))) + ->setMethods(array('drupalSetMessage')) + ->getMock(); + $form_state->setErrorByName('test', 'message'); + } + +} diff --git a/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php b/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php index cc34f74dfe866060fa87f3ac95abd363a183978e..0bdc009f26a6a102b179d496eadf5df126577059 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php @@ -8,6 +8,7 @@ namespace Drupal\Tests\Core\Form; use Drupal\Core\DependencyInjection\ContainerBuilder; +use Drupal\Core\Form\FormState; use Drupal\Core\Url; use Drupal\Tests\UnitTestCase; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -41,7 +42,7 @@ public function setUp() { public function testHandleFormSubmissionNotSubmitted() { $form_submitter = $this->getFormSubmitter(); $form = array(); - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $return = $form_submitter->doSubmitForm($form, $form_state); $this->assertFalse($form_state['executed']); @@ -54,9 +55,10 @@ public function testHandleFormSubmissionNotSubmitted() { public function testHandleFormSubmissionNoRedirect() { $form_submitter = $this->getFormSubmitter(); $form = array(); - $form_state = $this->getFormStateDefaults(); - $form_state['submitted'] = TRUE; - $form_state['no_redirect'] = TRUE; + $form_state = new FormState(array( + 'submitted' => TRUE, + 'no_redirect' => TRUE, + )); $return = $form_submitter->doSubmitForm($form, $form_state); $this->assertTrue($form_state['executed']); @@ -76,9 +78,10 @@ public function testHandleFormSubmissionWithResponses($class, $form_state_key) { ->method('prepare') ->will($this->returnValue($response)); - $form_state = $this->getFormStateDefaults(); - $form_state['submitted'] = TRUE; - $form_state[$form_state_key] = $response; + $form_state = new FormState(array( + 'submitted' => TRUE, + $form_state_key => $response, + )); $form_submitter = $this->getFormSubmitter(); $form = array(); @@ -101,7 +104,7 @@ public function providerTestHandleFormSubmissionWithResponses() { * * @dataProvider providerTestRedirectWithResult */ - public function testRedirectWithResult($form_state, $result, $status = 303) { + public function testRedirectWithResult($redirect_value, $result, $status = 303) { $form_submitter = $this->getFormSubmitter(); $this->urlGenerator->expects($this->once()) ->method('generateFromPath') @@ -113,12 +116,31 @@ public function testRedirectWithResult($form_state, $result, $status = 303) { )) ); - $form_state += $this->getFormStateDefaults(); + $form_state = $this->getMock('Drupal\Core\Form\FormStateInterface'); + $form_state->expects($this->once()) + ->method('getRedirect') + ->willReturn($redirect_value); $redirect = $form_submitter->redirectForm($form_state); $this->assertSame($result, $redirect->getTargetUrl()); $this->assertSame($status, $redirect->getStatusCode()); } + /** + * Provides test data for testing the redirectForm() method with a redirect. + * + * @return array + * Returns some test data. + */ + public function providerTestRedirectWithResult() { + return array( + array(NULL, ''), + array('foo', 'foo'), + array(array('foo'), 'foo'), + array(array('bar', array('query' => array('foo' => 'baz'))), 'bar'), + array(array('baz', array(), 301), 'baz', 301), + ); + } + /** * Tests the redirectForm() with redirect_route when a redirect is expected. * @@ -126,7 +148,7 @@ public function testRedirectWithResult($form_state, $result, $status = 303) { * * @dataProvider providerTestRedirectWithRouteWithResult */ - public function testRedirectWithRouteWithResult($form_state, $result, $status = 303) { + public function testRedirectWithRouteWithResult($redirect_value, $result, $status = 303) { $container = new ContainerBuilder(); $container->set('url_generator', $this->urlGenerator); \Drupal::setContainer($container); @@ -139,12 +161,28 @@ public function testRedirectWithRouteWithResult($form_state, $result, $status = )) ); - $form_state += $this->getFormStateDefaults(); + $form_state = $this->getMock('Drupal\Core\Form\FormStateInterface'); + $form_state->expects($this->once()) + ->method('getRedirect') + ->willReturn($redirect_value); $redirect = $form_submitter->redirectForm($form_state); $this->assertSame($result, $redirect->getTargetUrl()); $this->assertSame($status, $redirect->getStatusCode()); } + /** + * Provides test data for testing the redirectForm() method with a route name. + * + * @return array + * Returns some test data. + */ + public function providerTestRedirectWithRouteWithResult() { + return array( + array(new Url('test_route_a', array(), array('absolute' => TRUE)), 'test-route'), + array(new Url('test_route_b', array('key' => 'value'), array('absolute' => TRUE)), 'test-route/value'), + ); + } + /** * Tests the redirectForm() method with a response object. * @@ -153,9 +191,11 @@ public function testRedirectWithRouteWithResult($form_state, $result, $status = public function testRedirectWithResponseObject() { $form_submitter = $this->getFormSubmitter(); $redirect = new RedirectResponse('/example'); - $form_state['redirect'] = $redirect; + $form_state = $this->getMock('Drupal\Core\Form\FormStateInterface'); + $form_state->expects($this->once()) + ->method('getRedirect') + ->willReturn($redirect); - $form_state += $this->getFormStateDefaults(); $result_redirect = $form_submitter->redirectForm($form_state); $this->assertSame($redirect, $result_redirect); @@ -165,66 +205,21 @@ public function testRedirectWithResponseObject() { * Tests the redirectForm() method when no redirect is expected. * * @covers ::redirectForm - * - * @dataProvider providerTestRedirectWithoutResult */ - public function testRedirectWithoutResult($form_state) { + public function testRedirectWithoutResult() { $form_submitter = $this->getFormSubmitter(); $this->urlGenerator->expects($this->never()) ->method('generateFromPath'); $this->urlGenerator->expects($this->never()) ->method('generateFromRoute'); - $form_state += $this->getFormStateDefaults(); + $form_state = $this->getMock('Drupal\Core\Form\FormStateInterface'); + $form_state->expects($this->once()) + ->method('getRedirect') + ->willReturn(FALSE); $redirect = $form_submitter->redirectForm($form_state); $this->assertNull($redirect); } - /** - * Provides test data for testing the redirectForm() method with a redirect. - * - * @return array - * Returns some test data. - */ - public function providerTestRedirectWithResult() { - return array( - array(array(), ''), - array(array('redirect' => 'foo'), 'foo'), - array(array('redirect' => array('foo')), 'foo'), - array(array('redirect' => array('foo')), 'foo'), - array(array('redirect' => array('bar', array('query' => array('foo' => 'baz')))), 'bar'), - array(array('redirect' => array('baz', array(), 301)), 'baz', 301), - ); - } - - /** - * Provides test data for testing the redirectForm() method with a route name. - * - * @return array - * Returns some test data. - */ - public function providerTestRedirectWithRouteWithResult() { - return array( - array(array('redirect_route' => array('route_name' => 'test_route_a')), 'test-route'), - array(array('redirect_route' => array('route_name' => 'test_route_b', 'route_parameters' => array('key' => 'value'))), 'test-route/value'), - array(array('redirect_route' => new Url('test_route_b', array('key' => 'value'))), 'test-route/value'), - ); - } - - /** - * Provides test data for testing the redirectForm() method with no redirect. - * - * @return array - * Returns some test data. - */ - public function providerTestRedirectWithoutResult() { - return array( - array(array('programmed' => TRUE)), - array(array('rebuild' => TRUE)), - array(array('no_redirect' => TRUE)), - array(array('redirect' => FALSE)), - ); - } - /** * @covers ::executeSubmitHandlers */ @@ -233,13 +228,13 @@ public function testExecuteSubmitHandlers() { $mock = $this->getMock('stdClass', array('submit_handler', 'hash_submit')); $mock->expects($this->once()) ->method('submit_handler') - ->with($this->isType('array'), $this->isType('array')); + ->with($this->isType('array'), $this->isInstanceOf('Drupal\Core\Form\FormStateInterface')); $mock->expects($this->once()) ->method('hash_submit') - ->with($this->isType('array'), $this->isType('array')); + ->with($this->isType('array'), $this->isInstanceOf('Drupal\Core\Form\FormStateInterface')); $form = array(); - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $form_submitter->executeSubmitHandlers($form, $form_state); $form['#submit'][] = array($mock, 'hash_submit'); @@ -250,17 +245,6 @@ public function testExecuteSubmitHandlers() { $form_submitter->executeSubmitHandlers($form, $form_state); } - /** - * @return array() - */ - protected function getFormStateDefaults() { - $form_builder = $this->getMockBuilder('Drupal\Core\Form\FormBuilder') - ->disableOriginalConstructor() - ->setMethods(NULL) - ->getMock(); - return $form_builder->getFormStateDefaults(); - } - /** * @return \Drupal\Core\Form\FormSubmitterInterface */ diff --git a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php index 9bb00d2376ddae6560da84a9f429eec4193538eb..08eaa3113ff0283b1709bfd5a03658e6e0480a26 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php +++ b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\FormBuilder; use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Tests\UnitTestCase; use Symfony\Component\HttpFoundation\Request; @@ -221,8 +222,8 @@ protected function getMockForm($form_id, $expected_form = NULL, $count = 1) { * The unique string identifying the form. * @param \Drupal\Core\Form\FormInterface $form_arg * The form object. - * @param array $form_state - * An associative array containing the current state of the form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The current state of the form. * @param bool $programmed * Whether $form_state['programmed'] should be set to TRUE or not. If it is * not set to TRUE, you must provide additional data in $form_state for the @@ -231,7 +232,7 @@ protected function getMockForm($form_id, $expected_form = NULL, $count = 1) { * @return array * The built form. */ - protected function simulateFormSubmission($form_id, FormInterface $form_arg, array &$form_state, $programmed = TRUE) { + protected function simulateFormSubmission($form_id, FormInterface $form_arg, FormStateInterface $form_state, $programmed = TRUE) { $form_state['build_info']['callback_object'] = $form_arg; $form_state['build_info']['args'] = array(); $form_state['input']['op'] = 'Submit'; diff --git a/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php b/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php index 0870788f0630502f03d05fa18698b0e2a7e93987..a0e9f473131a503b3a0c9f55ca29fa33cd7e686b 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php @@ -8,6 +8,7 @@ namespace Drupal\Tests\Core\Form { use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormState; use Drupal\Tests\UnitTestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -18,23 +19,6 @@ */ class FormValidatorTest extends UnitTestCase { - /** - * Tests that form errors during submission throw an exception. - * - * @covers ::setErrorByName - * - * @expectedException \LogicException - * @expectedExceptionMessage Form errors cannot be set after form validation has finished. - */ - public function testFormErrorsDuringSubmission() { - $form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator') - ->disableOriginalConstructor() - ->setMethods(NULL) - ->getMock(); - $form_state['validation_complete'] = TRUE; - $form_validator->setErrorByName('test', $form_state, 'message'); - } - /** * Tests the 'validation_complete' $form_state flag. * @@ -48,7 +32,7 @@ public function testValidationComplete() { ->getMock(); $form = array(); - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $this->assertFalse($form_state['validation_complete']); $form_validator->validateForm('test_form_id', $form, $form_state); $this->assertTrue($form_state['validation_complete']); @@ -68,7 +52,7 @@ public function testPreventDuplicateValidation() { ->method('doValidateForm'); $form = array(); - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $form_state['validation_complete'] = TRUE; $form_validator->validateForm('test_form_id', $form, $form_state); $this->assertArrayNotHasKey('#errors', $form); @@ -88,7 +72,7 @@ public function testMustValidate() { ->method('doValidateForm'); $form = array(); - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $form_state['validation_complete'] = TRUE; $form_state['must_validate'] = TRUE; $form_validator->validateForm('test_form_id', $form, $form_state); @@ -115,12 +99,12 @@ public function testValidateInvalidFormToken() { ->getMock(); $form_validator->expects($this->once()) ->method('setErrorByName') - ->with('form_token', $this->isType('array'), 'The form has become outdated. Copy any unsaved work in the form below and then reload this page.'); + ->with('form_token', $this->isInstanceOf('Drupal\Core\Form\FormStateInterface'), 'The form has become outdated. Copy any unsaved work in the form below and then reload this page.'); $form_validator->expects($this->never()) ->method('doValidateForm'); $form['#token'] = 'test_form_id'; - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $form_state['values']['form_token'] = 'some_random_token'; $form_validator->validateForm('test_form_id', $form, $form_state); $this->assertTrue($form_state['validation_complete']); @@ -148,120 +132,19 @@ public function testValidateValidFormToken() { ->method('doValidateForm'); $form['#token'] = 'test_form_id'; - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $form_state['values']['form_token'] = 'some_random_token'; $form_validator->validateForm('test_form_id', $form, $form_state); $this->assertTrue($form_state['validation_complete']); } - /** - * Tests the setError() method. - * - * @covers ::setError - */ - public function testSetError() { - $form_state = $this->getFormStateDefaults(); - - $form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator') - ->disableOriginalConstructor() - ->setMethods(array('setErrorByName')) - ->getMock(); - $form_validator->expects($this->once()) - ->method('setErrorByName') - ->with('foo][bar', $form_state, 'Fail'); - - $element['#parents'] = array('foo', 'bar'); - $form_validator->setError($element, $form_state, 'Fail'); - } - - /** - * Tests the getError() method. - * - * @covers ::getError - * - * @dataProvider providerTestGetError - */ - public function testGetError($errors, $parents, $error = NULL) { - $form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator') - ->disableOriginalConstructor() - ->setMethods(NULL) - ->getMock(); - - $element['#parents'] = $parents; - $form_state = $this->getFormStateDefaults(); - $form_state['errors'] = $errors; - $this->assertSame($error, $form_validator->getError($element, $form_state)); - } - - public function providerTestGetError() { - return array( - array(array(), array('foo')), - array(array('foo][bar' => 'Fail'), array()), - array(array('foo][bar' => 'Fail'), array('foo')), - array(array('foo][bar' => 'Fail'), array('bar')), - array(array('foo][bar' => 'Fail'), array('baz')), - array(array('foo][bar' => 'Fail'), array('foo', 'bar'), 'Fail'), - array(array('foo][bar' => 'Fail'), array('foo', 'bar', 'baz'), 'Fail'), - array(array('foo][bar' => 'Fail 2'), array('foo')), - array(array('foo' => 'Fail 1', 'foo][bar' => 'Fail 2'), array('foo'), 'Fail 1'), - array(array('foo' => 'Fail 1', 'foo][bar' => 'Fail 2'), array('foo', 'bar'), 'Fail 1'), - ); - } - - /** - * @covers ::setErrorByName - * - * @dataProvider providerTestSetErrorByName - */ - public function testSetErrorByName($limit_validation_errors, $expected_errors, $set_message = FALSE) { - $request_stack = new RequestStack(); - $request = new Request(); - $request_stack->push($request); - $csrf_token = $this->getMockBuilder('Drupal\Core\Access\CsrfTokenGenerator') - ->disableOriginalConstructor() - ->getMock(); - $form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator') - ->setConstructorArgs(array($request_stack, $this->getStringTranslationStub(), $csrf_token)) - ->setMethods(array('drupalSetMessage')) - ->getMock(); - $form_validator->expects($set_message ? $this->once() : $this->never()) - ->method('drupalSetMessage'); - - $form_state = $this->getFormStateDefaults(); - $form_state['limit_validation_errors'] = $limit_validation_errors; - $form_validator->setErrorByName('test', $form_state, 'Fail 1'); - $form_validator->setErrorByName('test', $form_state, 'Fail 2'); - $form_validator->setErrorByName('options', $form_state); - - $this->assertSame(!empty($expected_errors), $request->attributes->get('_form_errors', FALSE)); - $this->assertSame($expected_errors, $form_state['errors']); - } - - public function providerTestSetErrorByName() { - return array( - // Only validate the 'options' element. - array(array(array('options')), array('options' => '')), - // Do not limit an validation, and, ensuring the first error is returned - // for the 'test' element. - array(NULL, array('test' => 'Fail 1', 'options' => ''), TRUE), - // Limit all validation. - array(array(), array()), - ); - } - /** * @covers ::setElementErrorsFromFormState */ public function testSetElementErrorsFromFormState() { - $request_stack = new RequestStack(); - $request = new Request(); - $request_stack->push($request); - $csrf_token = $this->getMockBuilder('Drupal\Core\Access\CsrfTokenGenerator') - ->disableOriginalConstructor() - ->getMock(); $form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator') - ->setConstructorArgs(array($request_stack, $this->getStringTranslationStub(), $csrf_token)) - ->setMethods(array('drupalSetMessage')) + ->disableOriginalConstructor() + ->setMethods(NULL) ->getMock(); $form = array( @@ -272,7 +155,9 @@ public function testSetElementErrorsFromFormState() { '#title' => 'Test', '#parents' => array('test'), ); - $form_state = $this->getFormStateDefaults(); + $form_state = $this->getMockBuilder('Drupal\Core\Form\FormState') + ->setMethods(array('drupalSetMessage')) + ->getMock(); $form_validator->setErrorByName('test', $form_state, 'invalid'); $form_validator->validateForm('test_form_id', $form, $form_state); $this->assertSame('invalid', $form['test']['#errors']); @@ -290,7 +175,7 @@ public function testHandleErrorsWithLimitedValidation($sections, $triggering_ele ->getMock(); $form = array(); - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $form_state['triggering_element'] = $triggering_element; $form_state['triggering_element']['#limit_validation_errors'] = $sections; @@ -387,13 +272,13 @@ public function testExecuteValidateHandlers() { $mock = $this->getMock('stdClass', array('validate_handler', 'hash_validate')); $mock->expects($this->once()) ->method('validate_handler') - ->with($this->isType('array'), $this->isType('array')); + ->with($this->isType('array'), $this->isInstanceOf('Drupal\Core\Form\FormStateInterface')); $mock->expects($this->once()) ->method('hash_validate') - ->with($this->isType('array'), $this->isType('array')); + ->with($this->isType('array'), $this->isInstanceOf('Drupal\Core\Form\FormStateInterface')); $form = array(); - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $form_validator->executeValidateHandlers($form, $form_state); $form['#validate'][] = array($mock, 'hash_validate'); @@ -415,13 +300,13 @@ public function testRequiredErrorMessage($element, $expected_message) { ->getMock(); $form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator') ->setConstructorArgs(array(new RequestStack(), $this->getStringTranslationStub(), $csrf_token)) - ->setMethods(array('executeValidateHandlers', 'setErrorByName')) + ->setMethods(array('executeValidateHandlers', 'setError')) ->getMock(); $form_validator->expects($this->once()) ->method('executeValidateHandlers'); $form_validator->expects($this->once()) - ->method('setErrorByName') - ->with('test', $this->isType('array'), $expected_message); + ->method('setError') + ->with($this->isType('array'), $this->isInstanceOf('Drupal\Core\Form\FormStateInterface'), $expected_message); $form = array(); $form['test'] = $element + array( @@ -431,7 +316,7 @@ public function testRequiredErrorMessage($element, $expected_message) { '#required' => TRUE, '#parents' => array('test'), ); - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $form_validator->validateForm('test_form_id', $form, $form_state); } @@ -468,7 +353,7 @@ public function testElementValidate() { $mock = $this->getMock('stdClass', array('element_validate')); $mock->expects($this->once()) ->method('element_validate') - ->with($this->isType('array'), $this->isType('array'), NULL); + ->with($this->isType('array'), $this->isInstanceOf('Drupal\Core\Form\FormStateInterface'), NULL); $form = array(); $form['test'] = array( @@ -477,7 +362,7 @@ public function testElementValidate() { '#parents' => array('test'), '#element_validate' => array(array($mock, 'element_validate')), ); - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $form_validator->validateForm('test_form_id', $form, $form_state); } @@ -492,11 +377,11 @@ public function testPerformRequiredValidation($element, $expected_message, $call ->getMock(); $form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator') ->setConstructorArgs(array(new RequestStack(), $this->getStringTranslationStub(), $csrf_token)) - ->setMethods(array('setErrorByName', 'watchdog')) + ->setMethods(array('setError', 'watchdog')) ->getMock(); $form_validator->expects($this->once()) - ->method('setErrorByName') - ->with('test', $this->isType('array'), $expected_message); + ->method('setError') + ->with($this->isType('array'), $this->isInstanceOf('Drupal\Core\Form\FormStateInterface'), $expected_message); if ($call_watchdog) { $form_validator->expects($this->once()) @@ -511,7 +396,7 @@ public function testPerformRequiredValidation($element, $expected_message, $call '#required' => FALSE, '#parents' => array('test'), ); - $form_state = $this->getFormStateDefaults(); + $form_state = new FormState(); $form_state['values'] = array(); $form_validator->validateForm('test_form_id', $form, $form_state); } @@ -584,17 +469,6 @@ public function providerTestPerformRequiredValidation() { ); } - /** - * @return array() - */ - protected function getFormStateDefaults() { - $form_builder = $this->getMockBuilder('Drupal\Core\Form\FormBuilder') - ->disableOriginalConstructor() - ->setMethods(NULL) - ->getMock(); - return $form_builder->getFormStateDefaults(); - } - } } diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 0ff1bdd4da76f3f7c78c5084b11b29bed0f0d9dc..18652ad54006598c60e529758e96c08924b85a4d 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -7,6 +7,7 @@ use Drupal\Component\Utility\Xss; use Drupal\Component\Utility\String; +use Drupal\Core\Form\FormStateInterface; /** * Implements hook_preprocess_HOOK() for page templates. @@ -265,9 +266,9 @@ function seven_preprocess_maintenance_page(&$variables) { * * Changes vertical tabs to container and adds meta information. */ -function seven_form_node_form_alter(&$form, &$form_state) { +function seven_form_node_form_alter(&$form, FormStateInterface $form_state) { /** @var \Drupal\node\NodeInterface $node */ - $node = $form_state['controller']->getEntity(); + $node = $form_state->get('controller')->getEntity(); $form['#theme'] = array('node_edit_form'); $form['#attached']['css'][] = drupal_get_path('module', 'node') . '/css/node.module.css';