From 5f4bbab95cf390841503d945baf557af601b3fe3 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 4 Aug 2014 12:21:15 +0100 Subject: [PATCH] Issue #2313823 by tim.plunkett, martin107: Use FormStateInterface for all typehints. --- core/includes/ajax.inc | 2 +- core/includes/form.inc | 10 ++--- core/modules/book/book.module | 4 +- core/modules/comment/comment.module | 8 ++-- .../content_translation.module | 2 +- .../src/ContentTranslationHandler.php | 4 +- .../ContentTranslationHandlerInterface.php | 2 +- core/modules/dblog/dblog.module | 2 +- core/modules/editor/editor.module | 2 +- .../entity/src/Entity/EntityFormDisplay.php | 2 +- .../entity_reference/entity_reference.module | 4 +- .../field_third_party_test.module | 6 ++- core/modules/field_ui/field_ui.api.php | 4 +- core/modules/field_ui/field_ui.module | 2 +- .../Plugin/Field/FieldWidget/FileWidget.php | 2 +- core/modules/locale/locale.module | 8 ++-- core/modules/menu_ui/menu_ui.module | 8 ++-- .../node/src/Plugin/Search/NodeSearch.php | 2 +- core/modules/path/path.module | 3 +- .../search/src/Plugin/SearchInterface.php | 2 +- .../search/src/Plugin/SearchPluginBase.php | 2 +- .../system/src/Form/ModulesListForm.php | 2 +- .../ajax_forms_test/ajax_forms_test.module | 38 +++++++++---------- .../modules/ajax_forms_test/src/Callbacks.php | 5 ++- .../src/Form/FormTestTableSelectFormBase.php | 3 +- core/modules/update/update.module | 2 +- core/modules/views/src/Form/ViewsForm.php | 2 +- .../Plugin/views/wizard/WizardPluginBase.php | 16 ++++---- core/modules/views_ui/admin.inc | 4 +- core/modules/views_ui/src/ViewUI.php | 2 +- core/profiles/minimal/minimal.profile | 4 +- core/profiles/standard/standard.profile | 4 +- 32 files changed, 86 insertions(+), 77 deletions(-) diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index d779bd95c7d..31fbfc6159b 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -94,7 +94,7 @@ use Drupal\Core\Form\FormStateInterface; * return $form; * } * - * function ajax_example_simplest_callback($form, $form_state) { + * function ajax_example_simplest_callback($form, FormStateInterface $form_state) { * // The form has already been submitted and updated. We can return the replaced * // item as it is. * return $form['replace_textfield']; diff --git a/core/includes/form.inc b/core/includes/form.inc index 7d01ceb04ab..edc9afe82e7 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -39,7 +39,7 @@ function form_get_cache($form_build_id, FormStateInterface $form_state) { * * @see \Drupal\Core\Form\FormBuilderInterface::setCache(). */ -function form_set_cache($form_build_id, $form, $form_state) { +function form_set_cache($form_build_id, $form, FormStateInterface $form_state) { \Drupal::formBuilder()->setCache($form_build_id, $form, $form_state); } @@ -136,7 +136,7 @@ function drupal_process_form($form_id, &$form, FormStateInterface $form_state) { * * @see \Drupal\Core\Form\FormSubmitterInterface::redirectForm(). */ -function drupal_redirect_form($form_state) { +function drupal_redirect_form(FormStateInterface $form_state) { return \Drupal::service('form_submitter')->redirectForm($form_state); } @@ -288,7 +288,7 @@ function form_state_values_clean(FormStateInterface $form_state) { * The data that will appear in the $form_state['values'] collection * for this element. Return nothing to use the default. */ -function form_type_image_button_value($form, $input, $form_state) { +function form_type_image_button_value($form, $input, FormStateInterface $form_state) { if ($input !== FALSE) { if (!empty($input)) { // If we're dealing with Mozilla or Opera, we're lucky. It will @@ -1172,7 +1172,7 @@ function form_pre_render_conditional_form_element($element) { /** * Processes a form button element. */ -function form_process_button($element, $form_state) { +function form_process_button($element, FormStateInterface $form_state) { // If this is a button intentionally allowing incomplete form submission // (e.g., a "Previous" or "Add another item" button), then also skip // client-side validation. @@ -1185,7 +1185,7 @@ function form_process_button($element, $form_state) { /** * Sets the #checked property of a checkbox element. */ -function form_process_checkbox($element, $form_state) { +function form_process_checkbox($element, FormStateInterface $form_state) { $value = $element['#value']; $return_value = $element['#return_value']; // On form submission, the #value of an available and enabled checked diff --git a/core/modules/book/book.module b/core/modules/book/book.module index c791b68c49e..f98978ada61 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -231,7 +231,7 @@ function book_pick_book_nojs_submit($form, FormStateInterface $form_state) { * @return * The rendered parent page select element. */ -function book_form_update($form, $form_state) { +function book_form_update($form, FormStateInterface $form_state) { return $form['book']['pid']; } @@ -352,7 +352,7 @@ function book_node_prepare_form(NodeInterface $node, $operation, FormStateInterf * * @see node_delete_confirm() */ -function book_form_node_delete_confirm_alter(&$form, $form_state) { +function book_form_node_delete_confirm_alter(&$form, FormStateInterface $form_state) { $node = node_load($form['nid']['#value']); if (isset($node->book) && $node->book['has_children']) { diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index d5391f366b3..406472b2fde 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -489,7 +489,7 @@ function comment_view_multiple($comments, $view_mode = 'full', $langcode = NULL) /** * Implements hook_form_FORM_ID_alter() for field_ui_field_overview_form. */ -function comment_form_field_ui_field_overview_form_alter(&$form, $form_state) { +function comment_form_field_ui_field_overview_form_alter(&$form, FormStateInterface $form_state) { $request = \Drupal::request(); if ($form['#entity_type'] == 'comment' && $request->attributes->has('commented_entity_type')) { $form['#title'] = \Drupal::service('comment.manager')->getFieldUIPageTitle($request->attributes->get('commented_entity_type'), $request->attributes->get('field_name')); @@ -504,7 +504,7 @@ function comment_form_field_ui_field_overview_form_alter(&$form, $form_state) { /** * Implements hook_form_FORM_ID_alter(). */ -function comment_form_field_ui_form_display_overview_form_alter(&$form, $form_state) { +function comment_form_field_ui_form_display_overview_form_alter(&$form, FormStateInterface $form_state) { $request = \Drupal::request(); if ($form['#entity_type'] == 'comment' && $request->attributes->has('commented_entity_type')) { $form['#title'] = \Drupal::service('comment.manager')->getFieldUIPageTitle($request->attributes->get('commented_entity_type'), $request->attributes->get('field_name')); @@ -514,7 +514,7 @@ function comment_form_field_ui_form_display_overview_form_alter(&$form, $form_st /** * Implements hook_form_FORM_ID_alter(). */ -function comment_form_field_ui_display_overview_form_alter(&$form, $form_state) { +function comment_form_field_ui_display_overview_form_alter(&$form, FormStateInterface $form_state) { $request = \Drupal::request(); if ($form['#entity_type'] == 'comment' && $request->attributes->has('commented_entity_type')) { $form['#title'] = \Drupal::service('comment.manager')->getFieldUIPageTitle($request->attributes->get('commented_entity_type'), $request->attributes->get('field_name')); @@ -524,7 +524,7 @@ function comment_form_field_ui_display_overview_form_alter(&$form, $form_state) /** * Implements hook_form_FORM_ID_alter(). */ -function comment_form_field_ui_field_storage_edit_form_alter(&$form, $form_state) { +function comment_form_field_ui_field_storage_edit_form_alter(&$form, FormStateInterface $form_state) { if ($form['#field']->getType() == 'comment') { // We only support posting one comment at the time so it doesn't make sense // to let the site builder choose anything else. diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index c79213a998f..9b43982f8b8 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -376,7 +376,7 @@ function content_translation_controller($entity_type_id) { * * @todo Move to \Drupal\content_translation\ContentTranslationManager. */ -function content_translation_form_controller($form_state) { +function content_translation_form_controller(FormStateInterface $form_state) { return isset($form_state['controller']) && $form_state['controller'] instanceof EntityFormInterface ? $form_state['controller'] : FALSE; } diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php index d14a945d4f6..d7601e73d64 100644 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@ -76,7 +76,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface { /** * {@inheritdoc} */ - public function getSourceLangcode($form_state) { + public function getSourceLangcode(FormStateInterface $form_state) { return isset($form_state['content_translation']['source']) ? $form_state['content_translation']['source']->id : FALSE; } @@ -288,7 +288,7 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface { * * @see \Drupal\content_translation\ContentTranslationHandler::entityFormAlter() */ - public function entityFormSharedElements($element, $form_state, $form) { + public function entityFormSharedElements($element, FormStateInterface $form_state, $form) { static $ignored_types; // @todo Find a more reliable way to determine if a form element concerns a diff --git a/core/modules/content_translation/src/ContentTranslationHandlerInterface.php b/core/modules/content_translation/src/ContentTranslationHandlerInterface.php index 67c4d0d00e1..8d3d725ee62 100644 --- a/core/modules/content_translation/src/ContentTranslationHandlerInterface.php +++ b/core/modules/content_translation/src/ContentTranslationHandlerInterface.php @@ -44,7 +44,7 @@ interface ContentTranslationHandlerInterface { * @return string * The source language code. */ - public function getSourceLangcode($form_state); + public function getSourceLangcode(FormStateInterface $form_state); /** * Marks translations as outdated. diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module index c941c06b448..41ed76afc5a 100644 --- a/core/modules/dblog/dblog.module +++ b/core/modules/dblog/dblog.module @@ -95,7 +95,7 @@ function _dblog_get_message_types() { /** * Implements hook_form_FORM_ID_alter() for system_logging_settings(). */ -function dblog_form_system_logging_settings_alter(&$form, $form_state) { +function dblog_form_system_logging_settings_alter(&$form, FormStateInterface $form_state) { $row_limits = array(100, 1000, 10000, 100000, 1000000); $form['dblog_row_limit'] = array( '#type' => 'select', diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 4ee1dddfeab..9aa349ab98d 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -70,7 +70,7 @@ function editor_element_info() { /** * Implements hook_form_FORM_ID_alter(). */ -function editor_form_filter_admin_overview_alter(&$form, $form_state) { +function editor_form_filter_admin_overview_alter(&$form, FormStateInterface $form_state) { // @todo Cleanup column injection: http://drupal.org/node/1876718 // Splice in the column for "Text editor" into the header. $position = array_search('name', $form['formats']['#header']) + 1; diff --git a/core/modules/entity/src/Entity/EntityFormDisplay.php b/core/modules/entity/src/Entity/EntityFormDisplay.php index 6457e236602..cbaa689604f 100644 --- a/core/modules/entity/src/Entity/EntityFormDisplay.php +++ b/core/modules/entity/src/Entity/EntityFormDisplay.php @@ -176,7 +176,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn * * @see \Drupal\entity\Entity\EntityFormDisplay::buildForm() */ - public function processForm($element, $form_state, $form) { + public function processForm($element, FormStateInterface $form_state, $form) { // Assign the weights configured in the form display. foreach ($this->getComponents() as $name => $options) { if (isset($element[$name])) { diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index 6d4139b4f68..75ab68c6cf9 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -106,7 +106,7 @@ function entity_reference_field_storage_config_update(FieldStorageConfigInterfac * * @see entity_reference_field_instance_settings_form() */ -function _entity_reference_field_instance_settings_ajax_process($form, $form_state) { +function _entity_reference_field_instance_settings_ajax_process($form, FormStateInterface $form_state) { _entity_reference_field_instance_settings_ajax_process_element($form, $form); return $form; } @@ -158,7 +158,7 @@ function _entity_reference_element_validate_filter(&$element, FormStateInterface * * @see entity_reference_field_instance_settings_form() */ -function entity_reference_settings_ajax($form, $form_state) { +function entity_reference_settings_ajax($form, FormStateInterface $form_state) { $trigger = $form_state['triggering_element']; return NestedArray::getValue($form, $trigger['#ajax']['element']); } diff --git a/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module b/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module index 5ac0d1c8245..8726b18b5dc 100644 --- a/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module +++ b/core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module @@ -1,9 +1,11 @@ 'textfield', '#title' => t('3rd party widget settings form'), @@ -23,7 +25,7 @@ function field_third_party_test_field_widget_settings_summary_alter(&$summary, $ /** * Implements hook_field_formatter_third_party_settings_form(). */ -function field_third_party_test_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, $form, $form_state) { +function field_third_party_test_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) { $element['field_test_field_formatter_third_party_settings_form'] = array( '#type' => 'textfield', '#title' => t('3rd party formatter settings form'), diff --git a/core/modules/field_ui/field_ui.api.php b/core/modules/field_ui/field_ui.api.php index b67d89b17b0..4e44c3a33f1 100644 --- a/core/modules/field_ui/field_ui.api.php +++ b/core/modules/field_ui/field_ui.api.php @@ -29,7 +29,7 @@ * * @see \Drupal\field_ui\DisplayOverView. */ -function hook_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, $form, $form_state) { +function hook_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, $form, \Drupal\Core\Form\FormStateInterface $form_state) { $element = array(); // Add a 'my_setting' checkbox to the settings form for 'foo_formatter' field // formatters. @@ -62,7 +62,7 @@ function hook_field_formatter_third_party_settings_form(\Drupal\Core\Field\Forma * * @see \Drupal\field_ui\FormDisplayOverView. */ -function hook_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $form_mode, $form, $form_state) { +function hook_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $form_mode, $form, \Drupal\Core\Form\FormStateInterface $form_state) { $element = array(); // Add a 'my_setting' checkbox to the settings form for 'foo_widget' field // widgets. diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 336b5877c64..7179a3acc58 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -149,7 +149,7 @@ function field_ui_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) { * @see node_type_form() * @see field_ui_form_node_type_form_submit() */ -function field_ui_form_node_type_form_alter(&$form, $form_state) { +function field_ui_form_node_type_form_alter(&$form, FormStateInterface $form_state) { // We want to display the button only on add page. if ($form_state['controller']->getEntity()->isNew()) { $form['actions']['save_continue'] = $form['actions']['submit']; diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index 9a03fe41d78..8778f80e7fc 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -279,7 +279,7 @@ class FileWidget extends WidgetBase { * * This method is assigned as a #value_callback in formElement() method. */ - public static function value($element, $input = FALSE, $form_state) { + public static function value($element, $input = FALSE, FormStateInterface $form_state) { if ($input) { // Checkboxes lose their value when empty. // If the display field is present make sure its unchecked value is saved. diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 7f40bf4a350..8b5109652ad 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -711,7 +711,7 @@ function locale_form_language_admin_add_form_alter(&$form, FormStateInterface $f * * Set a batch for a newly-added language. */ -function locale_form_language_admin_add_form_alter_submit($form, $form_state) { +function locale_form_language_admin_add_form_alter_submit($form, FormStateInterface $form_state) { if (\Drupal::config('locale.settings')->get('translation.import_enabled')) { if (empty($form_state['values']['predefined_langcode']) || $form_state['values']['predefined_langcode'] == 'custom') { $langcode = $form_state['values']['langcode']; @@ -751,7 +751,7 @@ function locale_form_language_admin_edit_form_alter(&$form, FormStateInterface $ /** * Form submission handler for language_admin_edit_form(). */ -function locale_form_language_admin_edit_form_alter_submit($form, $form_state) { +function locale_form_language_admin_edit_form_alter_submit($form, FormStateInterface $form_state) { \Drupal::config('locale.settings')->set('translate_english', intval($form_state['values']['locale_translate_english']))->save(); } @@ -770,7 +770,7 @@ function locale_translate_english() { * * Add interface translation directory setting to directories configuration. */ -function locale_form_system_file_system_settings_alter(&$form, $form_state) { +function locale_form_system_file_system_settings_alter(&$form, FormStateInterface $form_state) { $form['translation_path'] = array( '#type' => 'textfield', '#title' => t('Interface translations directory'), @@ -794,7 +794,7 @@ function locale_form_system_file_system_settings_alter(&$form, $form_state) { * changes. Without a translations directory local po files in the directory * should be ignored. The old translation status is no longer valid. */ -function locale_system_file_system_settings_submit(&$form, $form_state) { +function locale_system_file_system_settings_submit(&$form, FormStateInterface $form_state) { if ($form['translation_path']['#default_value'] != $form_state['values']['translation_path']) { locale_translation_clear_status(); } diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index efe5d0fb5c6..03c79c6dae0 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -317,7 +317,7 @@ function menu_ui_node_prepare_form(NodeInterface $node, $operation, FormStateInt * * @see menu_ui_node_submit() */ -function menu_ui_form_node_form_alter(&$form, $form_state) { +function menu_ui_form_node_form_alter(&$form, FormStateInterface $form_state) { // Generate a list of possible parents (not including this link or descendants). // @todo This must be handled in a #process handler. $node = $form_state['controller']->getEntity(); @@ -407,7 +407,7 @@ function menu_ui_form_node_form_alter(&$form, $form_state) { * * @see menu_ui_form_node_form_alter() */ -function menu_ui_node_submit(EntityInterface $node, $form, $form_state) { +function menu_ui_node_submit(EntityInterface $node, $form, FormStateInterface $form_state) { if (!empty($form_state['values']['menu'])) { $definition = $form_state['values']['menu']; if (empty($definition['enabled'])) { @@ -441,7 +441,7 @@ function menu_ui_node_submit(EntityInterface $node, $form, $form_state) { * @see NodeTypeForm::form(). * @see menu_ui_form_node_type_form_submit(). */ -function menu_ui_form_node_type_form_alter(&$form, $form_state) { +function menu_ui_form_node_type_form_alter(&$form, FormStateInterface $form_state) { /** @var \Drupal\Core\Menu\MenuParentFormSelectorInterface $menu_parent_selector */ $menu_parent_selector = \Drupal::service('menu.parent_form_selector'); $menu_options = menu_ui_get_menus(); @@ -493,7 +493,7 @@ function menu_ui_form_node_type_form_alter(&$form, $form_state) { * * @see menu_ui_form_node_type_form_alter(). */ -function menu_ui_form_node_type_form_submit(&$form, $form_state) { +function menu_ui_form_node_type_form_submit(&$form, FormStateInterface $form_state) { $type = $form_state['controller']->getEntity(); \Drupal::config('menu.entity.node.' . $type->id()) ->set('available_menus', array_values(array_filter($form_state['values']['menu_options']))) diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php index 45e34b82f25..d595d160fd8 100644 --- a/core/modules/node/src/Plugin/Search/NodeSearch.php +++ b/core/modules/node/src/Plugin/Search/NodeSearch.php @@ -480,7 +480,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter /* * {@inheritdoc} */ - public function buildSearchUrlQuery($form_state) { + public function buildSearchUrlQuery(FormStateInterface $form_state) { // Read keyword and advanced search information from the form values, // and put these into the GET parameters. $keys = trim($form_state['values']['keys']); diff --git a/core/modules/path/path.module b/core/modules/path/path.module index 8721d5e9ac8..7c4877253c2 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Field\FieldDefinition; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; /** @@ -54,7 +55,7 @@ function path_permission() { /** * Implements hook_form_BASE_FORM_ID_alter() for node_form(). */ -function path_form_node_form_alter(&$form, $form_state) { +function path_form_node_form_alter(&$form, FormStateInterface $form_state) { $node = $form_state['controller']->getEntity(); if ($node->hasField('path') && $node->get('path')->access('edit')) { $form['path_settings'] = array( diff --git a/core/modules/search/src/Plugin/SearchInterface.php b/core/modules/search/src/Plugin/SearchInterface.php index 34c9d4f6408..6eabf18b8ed 100644 --- a/core/modules/search/src/Plugin/SearchInterface.php +++ b/core/modules/search/src/Plugin/SearchInterface.php @@ -120,6 +120,6 @@ interface SearchInterface extends PluginInspectionInterface { * * @see SearchInterface::searchFormAlter() */ - public function buildSearchUrlQuery($form_state); + public function buildSearchUrlQuery(FormStateInterface $form_state); } diff --git a/core/modules/search/src/Plugin/SearchPluginBase.php b/core/modules/search/src/Plugin/SearchPluginBase.php index 9a553ccee30..bf208dcb7fb 100644 --- a/core/modules/search/src/Plugin/SearchPluginBase.php +++ b/core/modules/search/src/Plugin/SearchPluginBase.php @@ -112,7 +112,7 @@ abstract class SearchPluginBase extends PluginBase implements ContainerFactoryPl /* * {@inheritdoc} */ - public function buildSearchUrlQuery($form_state) { + public function buildSearchUrlQuery(FormStateInterface $form_state) { // Grab the keywords entered in the form and put them as 'keys' in the GET. $keys = trim($form_state['values']['keys']); $query = array('keys' => $keys); diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php index b12c4d2dda5..c8fe3018835 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -415,7 +415,7 @@ class ModulesListForm extends FormBase { * @return array * An array of modules to install and their dependencies. */ - protected function buildModuleList($form_state) { + protected function buildModuleList(FormStateInterface $form_state) { $packages = $form_state['values']['modules']; // Build a list of modules to install. 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 8f8719a7152..bc97fe6942c 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 @@ -12,7 +12,7 @@ use Drupal\Core\Form\FormStateInterface; /** * Ajax form callback: Selects 'after'. */ -function ajax_forms_test_advanced_commands_after_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_after_callback($form, FormStateInterface $form_state) { $selector = '#after_div'; $response = new AjaxResponse(); @@ -23,7 +23,7 @@ function ajax_forms_test_advanced_commands_after_callback($form, $form_state) { /** * Ajax form callback: Selects 'alert'. */ -function ajax_forms_test_advanced_commands_alert_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_alert_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new Ajax\AlertCommand('Alert')); return $response; @@ -32,7 +32,7 @@ function ajax_forms_test_advanced_commands_alert_callback($form, $form_state) { /** * Ajax form callback: Selects 'append'. */ -function ajax_forms_test_advanced_commands_append_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_append_callback($form, FormStateInterface $form_state) { $selector = '#append_div'; $response = new AjaxResponse(); $response->addCommand(new Ajax\AppendCommand($selector, "Appended text")); @@ -42,7 +42,7 @@ function ajax_forms_test_advanced_commands_append_callback($form, $form_state) { /** * Ajax form callback: Selects 'before'. */ -function ajax_forms_test_advanced_commands_before_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_before_callback($form, FormStateInterface $form_state) { $selector = '#before_div'; $response = new AjaxResponse(); $response->addCommand(new Ajax\BeforeCommand($selector, "Before text")); @@ -52,7 +52,7 @@ function ajax_forms_test_advanced_commands_before_callback($form, $form_state) { /** * Ajax form callback: Selects 'changed'. */ -function ajax_forms_test_advanced_commands_changed_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_changed_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new Ajax\ChangedCommand('#changed_div')); return $response; @@ -61,7 +61,7 @@ function ajax_forms_test_advanced_commands_changed_callback($form, $form_state) /** * Ajax form callback: Selects 'changed' with asterisk marking inner div. */ -function ajax_forms_test_advanced_commands_changed_asterisk_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_changed_asterisk_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new Ajax\ChangedCommand('#changed_div', '#changed_div_mark_this')); return $response; @@ -70,7 +70,7 @@ function ajax_forms_test_advanced_commands_changed_asterisk_callback($form, $for /** * Ajax form callback: Selects 'css'. */ -function ajax_forms_test_advanced_commands_css_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_css_callback($form, FormStateInterface $form_state) { $selector = '#css_div'; $color = 'blue'; @@ -82,7 +82,7 @@ function ajax_forms_test_advanced_commands_css_callback($form, $form_state) { /** * Ajax form callback: Selects 'data'. */ -function ajax_forms_test_advanced_commands_data_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_data_callback($form, FormStateInterface $form_state) { $selector = '#data_div'; $response = new AjaxResponse(); $response->addCommand(new Ajax\DataCommand($selector, 'testkey', 'testvalue')); @@ -92,7 +92,7 @@ function ajax_forms_test_advanced_commands_data_callback($form, $form_state) { /** * Ajax form callback: Selects 'invoke'. */ -function ajax_forms_test_advanced_commands_invoke_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_invoke_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new Ajax\InvokeCommand('#invoke_div', 'addClass', array('error'))); return $response; @@ -101,7 +101,7 @@ function ajax_forms_test_advanced_commands_invoke_callback($form, $form_state) { /** * Ajax form callback: Selects 'html'. */ -function ajax_forms_test_advanced_commands_html_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_html_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new Ajax\HtmlCommand('#html_div', 'replacement text')); return $response; @@ -110,7 +110,7 @@ function ajax_forms_test_advanced_commands_html_callback($form, $form_state) { /** * Ajax form callback: Selects 'insert'. */ -function ajax_forms_test_advanced_commands_insert_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_insert_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new Ajax\InsertCommand('#insert_div', 'insert replacement text')); return $response; @@ -119,7 +119,7 @@ function ajax_forms_test_advanced_commands_insert_callback($form, $form_state) { /** * Ajax form callback: Selects 'prepend'. */ -function ajax_forms_test_advanced_commands_prepend_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_prepend_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new Ajax\PrependCommand('#prepend_div', "prepended text")); return $response; @@ -128,7 +128,7 @@ function ajax_forms_test_advanced_commands_prepend_callback($form, $form_state) /** * Ajax form callback: Selects 'remove'. */ -function ajax_forms_test_advanced_commands_remove_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_remove_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new Ajax\RemoveCommand('#remove_text')); return $response; @@ -137,7 +137,7 @@ function ajax_forms_test_advanced_commands_remove_callback($form, $form_state) { /** * Ajax form callback: Selects 'restripe'. */ -function ajax_forms_test_advanced_commands_restripe_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_restripe_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new Ajax\RestripeCommand('#restripe_table')); return $response; @@ -146,7 +146,7 @@ function ajax_forms_test_advanced_commands_restripe_callback($form, $form_state) /** * Ajax form callback: Selects 'settings'. */ -function ajax_forms_test_advanced_commands_settings_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_settings_callback($form, FormStateInterface $form_state) { $setting['ajax_forms_test']['foo'] = 42; $response = new AjaxResponse(); $response->addCommand(new Ajax\SettingsCommand($setting)); @@ -156,7 +156,7 @@ function ajax_forms_test_advanced_commands_settings_callback($form, $form_state) /** * Ajax callback for 'add_css'. */ -function ajax_forms_test_advanced_commands_add_css_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_add_css_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new Ajax\AddCssCommand('my/file.css')); return $response; @@ -165,7 +165,7 @@ function ajax_forms_test_advanced_commands_add_css_callback($form, $form_state) /** * Ajax callback for 'settings' but with setting overrides. */ -function ajax_forms_test_advanced_commands_settings_with_merging_callback($form, $form_state) { +function ajax_forms_test_advanced_commands_settings_with_merging_callback($form, FormStateInterface $form_state) { $attached = array( '#attached' => array( 'js' => array( @@ -189,7 +189,7 @@ function ajax_forms_test_advanced_commands_settings_with_merging_callback($form, /** * Ajax form callback: Selects the 'drivertext' element of the validation form. */ -function ajax_forms_test_validation_form_callback($form, $form_state) { +function ajax_forms_test_validation_form_callback($form, FormStateInterface $form_state) { drupal_set_message("ajax_forms_test_validation_form_callback invoked"); drupal_set_message(t("Callback: drivertext=%drivertext, spare_required_field=%spare_required_field", array('%drivertext' => $form_state['values']['drivertext'], '%spare_required_field' => $form_state['values']['spare_required_field']))); return '
ajax_forms_test_validation_form_callback at ' . date('c') . '
'; @@ -198,7 +198,7 @@ function ajax_forms_test_validation_form_callback($form, $form_state) { /** * Ajax form callback: Selects the 'drivernumber' element of the validation form. */ -function ajax_forms_test_validation_number_form_callback($form, $form_state) { +function ajax_forms_test_validation_number_form_callback($form, FormStateInterface $form_state) { drupal_set_message("ajax_forms_test_validation_number_form_callback invoked"); drupal_set_message(t("Callback: drivernumber=%drivernumber, spare_required_field=%spare_required_field", array('%drivernumber' => $form_state['values']['drivernumber'], '%spare_required_field' => $form_state['values']['spare_required_field']))); return '
ajax_forms_test_validation_number_form_callback at ' . date('c') . '
'; diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php b/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php index 03f990248c1..e9830973385 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php +++ b/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php @@ -10,6 +10,7 @@ namespace Drupal\ajax_forms_test; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\DataCommand; use Drupal\Core\Ajax\HtmlCommand; +use Drupal\Core\Form\FormStateInterface; /** * Simple object for testing methods as Ajax callbacks. @@ -19,7 +20,7 @@ class Callbacks { /** * Ajax callback triggered by select. */ - function selectCallback($form, $form_state) { + function selectCallback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new HtmlCommand('#ajax_selected_color', $form_state['values']['select'])); $response->addCommand(new DataCommand('#ajax_selected_color', 'form_state_value_select', $form_state['values']['select'])); @@ -29,7 +30,7 @@ class Callbacks { /** * Ajax callback triggered by checkbox. */ - function checkboxCallback($form, $form_state) { + function checkboxCallback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new HtmlCommand('#ajax_checkbox_value', (int) $form_state['values']['checkbox'])); $response->addCommand(new DataCommand('#ajax_checkbox_value', 'form_state_value_select', (int) $form_state['values']['checkbox'])); 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 c5186e2e712..f618c92cce3 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 @@ -8,6 +8,7 @@ namespace Drupal\form_test\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; /** * Provides a base class for tableselect forms. @@ -27,7 +28,7 @@ abstract class FormTestTableSelectFormBase extends FormBase { * @return array * A form with a tableselect element and a submit button. */ - function tableselectFormBuilder($form, $form_state, $element_properties) { + function tableselectFormBuilder($form, FormStateInterface $form_state, $element_properties) { list($header, $options) = _form_test_tableselect_get_data(); $form['tableselect'] = $element_properties; diff --git a/core/modules/update/update.module b/core/modules/update/update.module index ec3e1b4e105..0ce90b49856 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -258,7 +258,7 @@ function update_themes_disabled($themes) { * * @see _update_cache_clear() */ -function update_form_system_modules_alter(&$form, $form_state) { +function update_form_system_modules_alter(&$form, FormStateInterface $form_state) { $form['#submit'][] = 'update_storage_clear_submit'; } diff --git a/core/modules/views/src/Form/ViewsForm.php b/core/modules/views/src/Form/ViewsForm.php index ac88a11ac0c..2273f9009b0 100644 --- a/core/modules/views/src/Form/ViewsForm.php +++ b/core/modules/views/src/Form/ViewsForm.php @@ -169,7 +169,7 @@ class ViewsForm implements FormInterface, ContainerInjectionInterface { * @return \Drupal\Core\Form\FormInterface * The form object to use. */ - protected function getFormObject($form_state) { + protected function getFormObject(FormStateInterface $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/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php index 3c55b1a1a32..4a6d31e4015 100644 --- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php @@ -484,7 +484,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { * it back into $element['#default_value'] so that the form will be rendered * with the correct value selected. */ - public static function getSelected($form_state, $parents, $default_value, $element) { + public static function getSelected(FormStateInterface $form_state, $parents, $default_value, $element) { // For now, don't trust this to work on anything but a #select element. if (!isset($element['#type']) || $element['#type'] != 'select' || !isset($element['#options'])) { return $default_value; @@ -674,7 +674,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { * An array whose keys are the names of each display and whose values are * arrays of options for that display. */ - protected function buildDisplayOptions($form, $form_state) { + protected function buildDisplayOptions($form, FormStateInterface $form_state) { // Display: Master $display_options['default'] = $this->defaultDisplayOptions(); $display_options['default'] += array( @@ -705,7 +705,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { /** * Alters the full array of display options before they are added to the view. */ - protected function alterDisplayOptions(&$display_options, $form, $form_state) { + protected function alterDisplayOptions(&$display_options, $form, FormStateInterface $form_state) { foreach ($display_options as $display_type => $options) { // Allow style plugins to hook in and provide some settings. $style_plugin = Views::pluginManager('style')->createInstance($options['style']['type']); @@ -716,7 +716,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { /** * Adds the array of display options to the view, with appropriate overrides. */ - protected function addDisplays(View $view, $display_options, $form, $form_state) { + protected function addDisplays(View $view, $display_options, $form, FormStateInterface $form_state) { // Initialize and store the view executable to get the display plugin // instances. $executable = $view->getExecutable(); @@ -830,7 +830,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { * An array of filter arrays keyed by ID. A sort array contains the options * accepted by a filter handler. */ - protected function defaultDisplayFilters($form, $form_state) { + protected function defaultDisplayFilters($form, FormStateInterface $form_state) { $filters = array(); // Add any filters provided by the plugin. @@ -915,7 +915,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { * An array of sort arrays keyed by ID. A sort array contains the options * accepted by a sort handler. */ - protected function defaultDisplaySorts($form, $form_state) { + protected function defaultDisplaySorts($form, FormStateInterface $form_state) { $sorts = array(); // Add any sorts provided by the plugin. @@ -941,7 +941,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { * An array of sort arrays keyed by ID. A sort array contains the options * accepted by a sort handler. */ - protected function defaultDisplaySortsUser($form, $form_state) { + protected function defaultDisplaySortsUser($form, FormStateInterface $form_state) { $sorts = array(); // Don't add a sort if there is no form value or the user set the sort to @@ -1056,7 +1056,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { * @return array * Returns an array of display options. */ - protected function pageFeedDisplayOptions($form, $form_state) { + protected function pageFeedDisplayOptions($form, FormStateInterface $form_state) { $display_options = array(); $display_options['pager']['type'] = 'some'; $display_options['style'] = array('type' => 'rss'); diff --git a/core/modules/views_ui/admin.inc b/core/modules/views_ui/admin.inc index 504e93cfc56..fd9b1b1787a 100644 --- a/core/modules/views_ui/admin.inc +++ b/core/modules/views_ui/admin.inc @@ -193,7 +193,7 @@ function views_ui_add_ajax_wrapper($element, FormStateInterface $form_state) { * @return * The part of the form that has changed. */ -function views_ui_ajax_update_form($form, $form_state) { +function views_ui_ajax_update_form($form, FormStateInterface $form_state) { // The region that needs to be updated was stored in a property of the // triggering element by views_ui_add_ajax_trigger(), so all we have to do is // retrieve that here. @@ -325,7 +325,7 @@ function views_ui_standard_display_dropdown(&$form, FormStateInterface $form_sta * Create the menu path for one of our standard AJAX forms based upon known * information about the form. */ -function views_ui_build_form_path($form_state) { +function views_ui_build_form_path(FormStateInterface $form_state) { $ajax = empty($form_state['ajax']) ? 'nojs' : 'ajax'; $name = $form_state['view']->id(); $path = "admin/structure/views/$ajax/$form_state[form_key]/$name/$form_state[display_id]"; diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index faa7507a3ec..8909c139826 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -399,7 +399,7 @@ class ViewUI implements ViewStorageInterface { /** * Return the was_defaulted, is_defaulted and revert state of a form. */ - public function getOverrideValues($form, $form_state) { + public function getOverrideValues($form, FormStateInterface $form_state) { // Make sure the dropdown exists in the first place. if (isset($form_state['values']['override']['dropdown'])) { // #default_value is used to determine whether it was the default value or not. diff --git a/core/profiles/minimal/minimal.profile b/core/profiles/minimal/minimal.profile index ed291da4d91..4f6570a21a4 100644 --- a/core/profiles/minimal/minimal.profile +++ b/core/profiles/minimal/minimal.profile @@ -4,12 +4,14 @@ * Enables modules and site configuration for a minimal site installation. */ +use Drupal\Core\Form\FormStateInterface; + /** * Implements hook_form_FORM_ID_alter() for install_configure_form(). * * Allows the profile to alter the site configuration form. */ -function minimal_form_install_configure_form_alter(&$form, $form_state) { +function minimal_form_install_configure_form_alter(&$form, FormStateInterface $form_state) { // Pre-populate the site name with the server name. $form['site_information']['site_name']['#default_value'] = \Drupal::request()->server->get('SERVER_NAME'); } diff --git a/core/profiles/standard/standard.profile b/core/profiles/standard/standard.profile index 209107d1953..4af64566e47 100644 --- a/core/profiles/standard/standard.profile +++ b/core/profiles/standard/standard.profile @@ -4,12 +4,14 @@ * Enables modules and site configuration for a standard site installation. */ +use Drupal\Core\Form\FormStateInterface; + /** * Implements hook_form_FORM_ID_alter() for install_configure_form(). * * Allows the profile to alter the site configuration form. */ -function standard_form_install_configure_form_alter(&$form, $form_state) { +function standard_form_install_configure_form_alter(&$form, FormStateInterface $form_state) { // Pre-populate the site name with the server name. $form['site_information']['site_name']['#default_value'] = \Drupal::request()->server->get('SERVER_NAME'); }