Issue #2313823 by tim.plunkett, martin107: Use FormStateInterface for all typehints.

8.0.x
Alex Pott 2014-08-04 12:21:15 +01:00
parent 4f5d858269
commit 5f4bbab95c
32 changed files with 86 additions and 77 deletions

View File

@ -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'];

View File

@ -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

View File

@ -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']) {

View File

@ -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.

View File

@ -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;
}

View File

@ -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

View File

@ -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.

View File

@ -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',

View File

@ -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;

View File

@ -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])) {

View File

@ -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']);
}

View File

@ -1,9 +1,11 @@
<?php
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_field_widget_third_party_settings_form().
*/
function field_third_party_test_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $form_mode, $form, $form_state) {
function field_third_party_test_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) {
$element['field_test_widget_third_party_settings_form'] = array(
'#type' => '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'),

View File

@ -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.

View File

@ -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'];

View File

@ -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.

View File

@ -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();
}

View File

@ -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'])))

View File

@ -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']);

View File

@ -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(

View File

@ -120,6 +120,6 @@ interface SearchInterface extends PluginInspectionInterface {
*
* @see SearchInterface::searchFormAlter()
*/
public function buildSearchUrlQuery($form_state);
public function buildSearchUrlQuery(FormStateInterface $form_state);
}

View File

@ -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);

View File

@ -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.

View File

@ -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 '<div id="message_area">ajax_forms_test_validation_form_callback at ' . date('c') . '</div>';
@ -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 '<div id="message_area_number">ajax_forms_test_validation_number_form_callback at ' . date('c') . '</div>';

View File

@ -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']));

View File

@ -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;

View File

@ -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';
}

View File

@ -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);

View File

@ -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');

View File

@ -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]";

View File

@ -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.

View File

@ -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');
}

View File

@ -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');
}