From e8d6588e145772bcdac30894cc7788a83613f193 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org> Date: Tue, 14 Oct 2014 13:54:17 +0100 Subject: [PATCH] Issue #2355001 by ashutoshsngh, dinarcon, er.pushpinderrana: Remove form.inc form_builder(). --- core/includes/common.inc | 3 ++- core/includes/form.inc | 15 ++------------- core/lib/Drupal/Core/Form/FormState.php | 4 ++-- .../Drupal/Core/Render/Element/RenderElement.php | 2 +- core/modules/file/file.module | 6 +++--- core/modules/filter/src/Element/TextFormat.php | 6 +++--- .../system/src/Tests/Common/RenderWebTest.php | 3 ++- core/modules/views_ui/admin.inc | 10 +++++----- core/modules/views_ui/src/ViewEditForm.php | 3 ++- 9 files changed, 22 insertions(+), 30 deletions(-) diff --git a/core/includes/common.inc b/core/includes/common.inc index 24f2fd64abe4..dd4037346dfa 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2541,7 +2541,8 @@ function drupal_prepare_page($page) { * the defaults for this type of element, defined in hook_element_info(), * are merged into the array. #defaults_loaded is set by functions that * process render arrays and call element_info() before passing the array to - * drupal_render(), such as form_builder() in the Form API. + * drupal_render(), such as \Drupal::formBuilder()->doBuildForm() in the + * Form API. * - If this element has an array of #pre_render functions defined, they are * called sequentially to modify the element before rendering. After all the * #pre_render functions have been called, #printed is checked a second time diff --git a/core/includes/form.inc b/core/includes/form.inc index e21b84eb4bbe..d5eaa54fc99f 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -84,18 +84,6 @@ function form_execute_handlers($type, &$form, FormStateInterface $form_state) { } } -/** - * Builds and processes all elements in the structured form array. - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use \Drupal::formBuilder()->doBuildForm(). - * - * @see \Drupal\Core\Form\FormBuilderInterface::doBuildForm(). - */ -function form_builder($form_id, &$element, FormStateInterface $form_state) { - return \Drupal::formBuilder()->doBuildForm($form_id, $element, $form_state); -} - /** * Removes internal Form API elements and buttons from submitted form values. * @@ -520,7 +508,8 @@ function template_preprocess_form_element(&$variables) { $element = &$variables['element']; // This function is invoked as theme wrapper, but the rendered form element - // may not necessarily have been processed by form_builder(). + // may not necessarily have been processed by + // \Drupal::formBuilder()->doBuildForm(). $element += array( '#title_display' => 'before', ); diff --git a/core/lib/Drupal/Core/Form/FormState.php b/core/lib/Drupal/Core/Form/FormState.php index 5ca9757a87bc..b204d7707b74 100644 --- a/core/lib/Drupal/Core/Form/FormState.php +++ b/core/lib/Drupal/Core/Form/FormState.php @@ -1147,8 +1147,8 @@ public function cleanValues() { ->unsetValue('op'); // Remove button values. - // form_builder() collects all button elements in a form. We remove the button - // value separately for each button element. + // \Drupal::formBuilder()->doBuildForm() collects all button elements in a + // form. We remove the button value separately for each button element. foreach ($this->getButtons() as $button) { // Remove this button's value from the submitted form values by finding // the value corresponding to this button. diff --git a/core/lib/Drupal/Core/Render/Element/RenderElement.php b/core/lib/Drupal/Core/Render/Element/RenderElement.php index 38e09fc2574c..d9888c0c435c 100644 --- a/core/lib/Drupal/Core/Render/Element/RenderElement.php +++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php @@ -35,7 +35,7 @@ public static function setAttributes(&$element, $class = array()) { } // This function is invoked from form element theme functions, but the // rendered form element may not necessarily have been processed by - // form_builder(). + // \Drupal::formBuilder()->doBuildForm(). if (!empty($element['#required'])) { $element['#attributes']['class'][] = 'required'; $element['#attributes']['required'] = 'required'; diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 61aa1bc6d7a6..77c3279b8816 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -1493,9 +1493,9 @@ function template_preprocess_file_managed_file(&$variables) { * Upload controls are hidden when a file is already uploaded. Remove controls * are hidden when there is no file attached. Controls are hidden here instead * of in file_managed_file_process(), because #access for these buttons depends - * on the managed_file element's #value. See the documentation of form_builder() - * for more detailed information about the relationship between #process, - * #value, and #access. + * on the managed_file element's #value. See the documentation of + * \Drupal::formBuilder()->doBuildForm() for more detailed information about the + * relationship between #process, #value, and #access. * * Because #access is set here, it affects display only and does not prevent * JavaScript or other untrusted code from submitting the form as though access diff --git a/core/modules/filter/src/Element/TextFormat.php b/core/modules/filter/src/Element/TextFormat.php index 277a77669c6e..000984a1dd62 100644 --- a/core/modules/filter/src/Element/TextFormat.php +++ b/core/modules/filter/src/Element/TextFormat.php @@ -76,12 +76,12 @@ public static function processFormat(&$element, FormStateInterface $form_state, // Ensure that children appear as subkeys of this element. $element['#tree'] = TRUE; $blacklist = array( - // Make form_builder() regenerate child properties. + // Make \Drupal::formBuilder()->doBuildForm() regenerate child properties. '#parents', '#id', '#name', - // Do not copy this #process function to prevent form_builder() from - // recursing infinitely. + // Do not copy this #process function to prevent + // \Drupal::formBuilder()->doBuildForm() from recursing infinitely. '#process', // Description is handled by theme_text_format_wrapper(). '#description', diff --git a/core/modules/system/src/Tests/Common/RenderWebTest.php b/core/modules/system/src/Tests/Common/RenderWebTest.php index 05a9cbe75433..1eb06697fad1 100644 --- a/core/modules/system/src/Tests/Common/RenderWebTest.php +++ b/core/modules/system/src/Tests/Common/RenderWebTest.php @@ -26,7 +26,8 @@ class RenderWebTest extends WebTestBase { public static $modules = array('common_test'); /** - * Tests rendering form elements without passing through form_builder(). + * Tests rendering form elements without passing through + * \Drupal::formBuilder()->doBuildForm(). */ function testDrupalRenderFormElements() { // Define a series of form elements. diff --git a/core/modules/views_ui/admin.inc b/core/modules/views_ui/admin.inc index b8b758d05b91..735662575559 100644 --- a/core/modules/views_ui/admin.inc +++ b/core/modules/views_ui/admin.inc @@ -137,11 +137,11 @@ function views_ui_add_limited_validation($element, FormStateInterface $form_stat $element['#limit_validation_errors'] = array($ajax_triggering_element['#parents']); // If we are in the process of a form submission and this is the button that - // was clicked, the form API workflow in form_builder() will have already - // copied it to $form_state->getTriggeringElement() before our #process - // function is run. So we need to make the same modifications in $form_state - // as we did to the element itself, to ensure that #limit_validation_errors - // will actually be set in the correct place. + // was clicked, the form API workflow in \Drupal::formBuilder()->doBuildForm() + // will have already copied it to $form_state->getTriggeringElement() before + // our #process function is run. So we need to make the same modifications in + // $form_state as we did to the element itself, to ensure that + // #limit_validation_errors will actually be set in the correct place. $clicked_button = &$form_state->getTriggeringElement(); if ($clicked_button && $clicked_button['#name'] == $element['#name'] && $clicked_button['#value'] == $element['#value']) { $clicked_button['#limit_validation_errors'] = $element['#limit_validation_errors']; diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index ea3ba889aaa3..57e9753a96e4 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -1156,7 +1156,8 @@ public function getFormBucket(ViewUI $view, $type, $display) { } /** - * Recursively adds microweights to a render array, similar to what form_builder() does for forms. + * Recursively adds microweights to a render array, similar to what + * \Drupal::formBuilder()->doBuildForm() does for forms. * * @todo Submit a core patch to fix drupal_render() to do this, so that all * render arrays automatically preserve array insertion order, as forms do. -- GitLab