From 7a91c2e8ed44533c7eeb9da8789c4a97efd335a2 Mon Sep 17 00:00:00 2001
From: webchick <webchick@24967.no-reply.drupal.org>
Date: Mon, 31 Mar 2014 10:26:19 -0700
Subject: [PATCH] Issue #2121175 by Codenator, tim.plunkett, cosmicdreams,
 jayeshanandani, grom358, ianthomas_uk, Xano: Remove usage of
 drupal_get_form().

---
 core/authorize.php                            |  2 +-
 core/includes/ajax.inc                        |  2 +-
 core/includes/form.inc                        | 18 ++--
 .../Drupal/Core/Form/FormBuilderInterface.php |  8 +-
 .../lib/Drupal/action/ActionListBuilder.php   |  2 +-
 .../ban/lib/Drupal/ban/Form/BanAdmin.php      |  5 +-
 .../lib/Drupal/block/BlockListBuilder.php     |  2 +-
 .../Form/FileModuleTestForm.php               |  2 +-
 core/modules/language/language.admin.inc      |  2 +-
 .../Form/LanguageElementsTestForm.php         |  4 +-
 .../lib/Drupal/locale/Form/LocaleForm.php     |  4 +-
 core/modules/path/path.admin.inc              |  6 +-
 .../search/Plugin/Block/SearchBlock.php       |  2 +-
 .../Drupal/search/Plugin/SearchInterface.php  |  4 +-
 .../lib/Drupal/shortcut/Form/ShortcutForm.php |  2 +-
 .../Drupal/system/Tests/Form/CheckboxTest.php |  2 +-
 core/modules/system/system.api.php            | 16 ++--
 .../Form/AjaxFormsTestForm.php                |  8 +-
 .../Drupal/batch_test/Form/BatchTestForm.php  |  6 +-
 .../database_test/Form/DatabaseTestForm.php   |  2 +-
 .../Drupal/form_test/Form/FormTestForm.php    | 86 +++++++++----------
 .../lib/Drupal/update/Form/UpdateForm.php     | 14 +--
 .../user/lib/Drupal/user/Form/UserForm.php    |  2 +-
 .../user/Plugin/Block/UserLoginBlock.php      |  2 +-
 24 files changed, 102 insertions(+), 101 deletions(-)

diff --git a/core/authorize.php b/core/authorize.php
index 2ddd7d6262a1..97fbe24df98a 100644
--- a/core/authorize.php
+++ b/core/authorize.php
@@ -139,7 +139,7 @@ function authorize_access_allowed() {
     }
     elseif (!$batch = batch_get()) {
       // We have a batch to process, show the filetransfer form.
-      $elements = drupal_get_form('authorize_filetransfer_form');
+      $elements = \Drupal::formBuilder()->getForm('authorize_filetransfer_form');
       $output = drupal_render($elements);
     }
   }
diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc
index 7a9847261732..7ab2059fc874 100644
--- a/core/includes/ajax.inc
+++ b/core/includes/ajax.inc
@@ -61,7 +61,7 @@
  * @link http://drupal.org/project/examples Examples module @endlink follows:
  * @code
  * function main_page() {
- *   return drupal_get_form('ajax_example_simplest');
+ *   return \Drupal::formBuilder()->getForm('ajax_example_simplest');
  * }
  *
  * function ajax_example_simplest($form, &$form_state) {
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 8f03f772b749..d290b4f44951 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -43,18 +43,18 @@
  * presentation, while simplifying code and reducing the amount of HTML that
  * must be explicitly generated by modules.
  *
- * The primary function used with forms is drupal_get_form(), which is
- * used for forms presented interactively to a user. Forms can also be built and
- * submitted programmatically without any user input using the
+ * The primary function used with forms is \Drupal::formBuilder()->getForm(),
+ * which is used for forms presented interactively to a user. Forms can also be
+ * built and submitted programmatically without any user input using the
  * drupal_form_submit() function.
  *
- * drupal_get_form() handles retrieving, processing, and displaying a rendered
- * HTML form for modules automatically.
+ * \Drupal::formBuilder()->getForm() handles retrieving, processing, and
+ * displaying a rendered HTML form for modules automatically.
  *
- * Here is an example of how to use drupal_get_form() and a form builder
- * function:
+ * Here is an example of how to use \Drupal::formBuilder()->getForm() and a
+ * form builder function:
  * @code
- * $form = drupal_get_form('my_module_example_form');
+ * $form = \Drupal::formBuilder()->getForm('my_module_example_form');
  * ...
  * function my_module_example_form($form, &$form_state) {
  *   $form['submit'] = array(
@@ -74,7 +74,7 @@
  * Or with any number of additional arguments:
  * @code
  * $extra = "extra";
- * $form = drupal_get_form('my_module_example_form', $extra);
+ * $form = \Drupal::formBuilder()->getForm('my_module_example_form', $extra);
  * ...
  * function my_module_example_form($form, &$form_state, $extra) {
  *   $form['submit'] = array(
diff --git a/core/lib/Drupal/Core/Form/FormBuilderInterface.php b/core/lib/Drupal/Core/Form/FormBuilderInterface.php
index 0e318bbb7e30..04ebcca476c5 100644
--- a/core/lib/Drupal/Core/Form/FormBuilderInterface.php
+++ b/core/lib/Drupal/Core/Form/FormBuilderInterface.php
@@ -41,10 +41,10 @@ public function getFormId($form_arg, &$form_state);
    *   - The name of a function that builds the form.
    * @param ...
    *   Any additional arguments are passed on to the functions called by
-   *   drupal_get_form(), including the unique form constructor function. For
-   *   example, the node_edit form requires that a node object is passed in here
-   *   when it is called. These are available to implementations of
-   *   hook_form_alter() and hook_form_FORM_ID_alter() as the array
+   *   \Drupal::formBuilder()->getForm(), including the unique form constructor
+   *   function. For example, the node_edit form requires that a node object is
+   *   passed in here when it is called. These are available to implementations
+   *   of hook_form_alter() and hook_form_FORM_ID_alter() as the array
    *   $form_state['build_info']['args'].
    *
    * @return array
diff --git a/core/modules/action/lib/Drupal/action/ActionListBuilder.php b/core/modules/action/lib/Drupal/action/ActionListBuilder.php
index 76c4f2f6bb98..446cc9753181 100644
--- a/core/modules/action/lib/Drupal/action/ActionListBuilder.php
+++ b/core/modules/action/lib/Drupal/action/ActionListBuilder.php
@@ -118,7 +118,7 @@ public function render() {
     if (!$this->hasConfigurableActions) {
       unset($build['action_table']['#header']['operations']);
     }
-    $build['action_admin_manage_form'] = drupal_get_form('Drupal\action\Form\ActionAdminManageForm');
+    $build['action_admin_manage_form'] = \Drupal::formBuilder()->getForm('Drupal\action\Form\ActionAdminManageForm');
     return $build;
   }
 
diff --git a/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php b/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php
index bc83c5410266..b6e4c56c19df 100644
--- a/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php
+++ b/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php
@@ -50,8 +50,9 @@ public function getFormId() {
    * {@inheritdoc}
    *
    * @param string $default_ip
-   *   (optional) IP address to be passed on to drupal_get_form() for use as the
-   *   default value of the IP address form field.
+   *   (optional) IP address to be passed on to
+   *   \Drupal::formBuilder()->getForm() for use as the default value of the IP
+   *   address form field.
    */
   public function buildForm(array $form, array &$form_state, $default_ip = '') {
     $rows = array();
diff --git a/core/modules/block/lib/Drupal/block/BlockListBuilder.php b/core/modules/block/lib/Drupal/block/BlockListBuilder.php
index 1b93f8cbfcae..8db9c6ac99c9 100644
--- a/core/modules/block/lib/Drupal/block/BlockListBuilder.php
+++ b/core/modules/block/lib/Drupal/block/BlockListBuilder.php
@@ -119,7 +119,7 @@ public function render($theme = NULL, Request $request = NULL) {
     // If no theme was specified, use the current theme.
     $this->theme = $theme ?: $GLOBALS['theme_key'];
 
-    return drupal_get_form($this);
+    return \Drupal::formBuilder()->getForm($this);
   }
 
   /**
diff --git a/core/modules/file/tests/file_module_test/lib/Drupal/file_module_test/Form/FileModuleTestForm.php b/core/modules/file/tests/file_module_test/lib/Drupal/file_module_test/Form/FileModuleTestForm.php
index fdd3cdbcb866..cdfd4742be56 100644
--- a/core/modules/file/tests/file_module_test/lib/Drupal/file_module_test/Form/FileModuleTestForm.php
+++ b/core/modules/file/tests/file_module_test/lib/Drupal/file_module_test/Form/FileModuleTestForm.php
@@ -16,7 +16,7 @@ class FileModuleTestForm {
    * @todo Remove file_module_test_form().
    */
   public function managedFileTest($tree, $extended, $multiple, $default_fids) {
-    return drupal_get_form('file_module_test_form', $tree, $extended, $multiple, $default_fids);
+    return \Drupal::formBuilder()->getForm('file_module_test_form', $tree, $extended, $multiple, $default_fids);
   }
 
 }
diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc
index b506136ac891..c7dbb8dc2682 100644
--- a/core/modules/language/language.admin.inc
+++ b/core/modules/language/language.admin.inc
@@ -157,7 +157,7 @@ function theme_language_negotiation_configure_browser_form_table($variables) {
  *   Use \Drupal\language\Controller\LanguageController::contentSettings().
  */
 function language_content_settings_page() {
-  return drupal_get_form('language_content_settings_form', language_entity_supported());
+  return \Drupal::formBuilder()->getForm('language_content_settings_form', language_entity_supported());
 }
 
 /**
diff --git a/core/modules/language/tests/language_elements_test/lib/Drupal/language_elements_test/Form/LanguageElementsTestForm.php b/core/modules/language/tests/language_elements_test/lib/Drupal/language_elements_test/Form/LanguageElementsTestForm.php
index 15dd084d4f70..010b472e005e 100644
--- a/core/modules/language/tests/language_elements_test/lib/Drupal/language_elements_test/Form/LanguageElementsTestForm.php
+++ b/core/modules/language/tests/language_elements_test/lib/Drupal/language_elements_test/Form/LanguageElementsTestForm.php
@@ -18,7 +18,7 @@ class LanguageElementsTestForm {
    * @todo Remove language_elements_configuration_element().
    */
   public function configFormElement() {
-    return drupal_get_form('language_elements_configuration_element');
+    return \Drupal::formBuilder()->getForm('language_elements_configuration_element');
   }
 
   /**
@@ -27,7 +27,7 @@ public function configFormElement() {
    * @todo Remove language_element_tests_configuration_element_test().
    */
   public function configFormElementTest() {
-    return drupal_get_form('language_elements_configuration_element_test');
+    return \Drupal::formBuilder()->getForm('language_elements_configuration_element_test');
   }
 
 }
diff --git a/core/modules/locale/lib/Drupal/locale/Form/LocaleForm.php b/core/modules/locale/lib/Drupal/locale/Form/LocaleForm.php
index aaa0bfac7a03..41857d09bfa2 100644
--- a/core/modules/locale/lib/Drupal/locale/Form/LocaleForm.php
+++ b/core/modules/locale/lib/Drupal/locale/Form/LocaleForm.php
@@ -18,7 +18,7 @@ class LocaleForm {
    */
   public function import() {
     module_load_include('bulk.inc', 'locale');
-    return drupal_get_form('locale_translate_import_form');
+    return \Drupal::formBuilder()->getForm('locale_translate_import_form');
   }
 
   /**
@@ -28,7 +28,7 @@ public function import() {
    */
   public function status() {
     module_load_include('pages.inc', 'locale');
-    return drupal_get_form('locale_translation_status_form');
+    return \Drupal::formBuilder()->getForm('locale_translation_status_form');
   }
 
 }
diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc
index d22fe66d49c6..76bc1dc74ac8 100644
--- a/core/modules/path/path.admin.inc
+++ b/core/modules/path/path.admin.inc
@@ -19,7 +19,7 @@
  */
 function path_admin_overview($keys = NULL) {
   // Add the filter form above the overview table.
-  $build['path_admin_filter_form'] = drupal_get_form('path_admin_filter_form', $keys);
+  $build['path_admin_filter_form'] = \Drupal::formBuilder()->getForm('path_admin_filter_form', $keys);
   // Enable language column if language.module is enabled or if we have any
   // alias with a language.
   $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => Language::LANGCODE_NOT_SPECIFIED))->fetchField();
@@ -116,11 +116,11 @@ function path_admin_overview($keys = NULL) {
  */
 function path_admin_edit($path = array()) {
   if ($path) {
-    $output = drupal_get_form('path_admin_form', $path);
+    $output = \Drupal::formBuilder()->getForm('path_admin_form', $path);
     $output['#title'] = String::checkPlain($path['alias']);
   }
   else {
-    $output = drupal_get_form('path_admin_form');
+    $output = \Drupal::formBuilder()->getForm('path_admin_form');
   }
 
   return $output;
diff --git a/core/modules/search/lib/Drupal/search/Plugin/Block/SearchBlock.php b/core/modules/search/lib/Drupal/search/Plugin/Block/SearchBlock.php
index aa33cbfa8373..c2e3e512c8ce 100644
--- a/core/modules/search/lib/Drupal/search/Plugin/Block/SearchBlock.php
+++ b/core/modules/search/lib/Drupal/search/Plugin/Block/SearchBlock.php
@@ -34,7 +34,7 @@ public function access(AccountInterface $account) {
    * {@inheritdoc}
    */
   public function build() {
-    return drupal_get_form('Drupal\search\Form\SearchBlockForm');
+    return \Drupal::formBuilder()->getForm('Drupal\search\Form\SearchBlockForm');
   }
 
 }
diff --git a/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php b/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php
index 2ff0ad70c577..1f3f2c1ce600 100644
--- a/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php
+++ b/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php
@@ -93,8 +93,8 @@ public function buildResults();
    *   Nested array of form elements that comprise the form.
    * @param array $form_state
    *   A keyed array containing the current state of the form. The arguments
-   *   that drupal_get_form() was originally called with are available in the
-   *   array $form_state['build_info']['args'].
+   *   that \Drupal::formBuilder()->getForm() was originally called with are
+   *   available in the array $form_state['build_info']['args'].
    */
   public function searchFormAlter(array &$form, array &$form_state);
 
diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutForm.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutForm.php
index 9c2cf5e03510..4f556b7e33ec 100644
--- a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutForm.php
+++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutForm.php
@@ -21,7 +21,7 @@ class ShortcutForm {
    */
   public function overview(UserInterface $user) {
     module_load_include('admin.inc', 'shortcut');
-    return drupal_get_form('shortcut_set_switch', $user);
+    return \Drupal::formBuilder()->getForm('shortcut_set_switch', $user);
   }
 
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/CheckboxTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/CheckboxTest.php
index 228c57621266..f15b3d1f5276 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/CheckboxTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/CheckboxTest.php
@@ -37,7 +37,7 @@ function testFormCheckbox() {
       // #return_value, with the exception of integer 0, which is not supported.
       // @see form_process_checkbox().
       foreach (array('0', '', 1, '1', 'foobar', '1foobar') as $return_value) {
-        $form_array = drupal_get_form('form_test_checkbox_type_juggling', $default_value, $return_value);
+        $form_array = \Drupal::formBuilder()->getForm('form_test_checkbox_type_juggling', $default_value, $return_value);
         $form = drupal_render($form_array);
         if ($default_value === TRUE) {
           $checked = TRUE;
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index 4c95a00d2988..b995551e9cda 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -699,8 +699,8 @@ function hook_page_alter(&$page) {
  *   Nested array of form elements that comprise the form.
  * @param $form_state
  *   A keyed array containing the current state of the form. The arguments
- *   that drupal_get_form() was originally called with are available in the
- *   array $form_state['build_info']['args'].
+ *   that \Drupal::formBuilder()->getForm() was originally called with are
+ *   available in the array $form_state['build_info']['args'].
  * @param $form_id
  *   String representing the name of the form itself. Typically this is the
  *   name of the function that generated the form.
@@ -738,8 +738,8 @@ function hook_form_alter(&$form, &$form_state, $form_id) {
  *   Nested array of form elements that comprise the form.
  * @param $form_state
  *   A keyed array containing the current state of the form. The arguments
- *   that drupal_get_form() was originally called with are available in the
- *   array $form_state['build_info']['args'].
+ *   that \Drupal::formBuilder()->getForm() was originally called with are
+ *   available in the array $form_state['build_info']['args'].
  * @param $form_id
  *   String representing the name of the form itself. Typically this is the
  *   name of the function that generated the form.
@@ -765,10 +765,10 @@ function hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
 /**
  * Provide a form-specific alteration for shared ('base') forms.
  *
- * By default, when drupal_get_form() is called, Drupal looks for a function
- * with the same name as the form ID, and uses that function to build the form.
- * In contrast, base forms allow multiple form IDs to be mapped to a single base
- * (also called 'factory') form function.
+ * By default, when \Drupal::formBuilder()->getForm() is called, Drupal looks
+ * for a function with the same name as the form ID, and uses that function to
+ * build the form. In contrast, base forms allow multiple form IDs to be mapped
+ * to a single base (also called 'factory') form function.
  *
  * Modules can implement hook_form_BASE_FORM_ID_alter() to modify a specific
  * base form, rather than implementing hook_form_alter() and checking for
diff --git a/core/modules/system/tests/modules/ajax_forms_test/lib/Drupal/ajax_forms_test/Form/AjaxFormsTestForm.php b/core/modules/system/tests/modules/ajax_forms_test/lib/Drupal/ajax_forms_test/Form/AjaxFormsTestForm.php
index 3a231ee9a8e8..01f9e93eb6bc 100644
--- a/core/modules/system/tests/modules/ajax_forms_test/lib/Drupal/ajax_forms_test/Form/AjaxFormsTestForm.php
+++ b/core/modules/system/tests/modules/ajax_forms_test/lib/Drupal/ajax_forms_test/Form/AjaxFormsTestForm.php
@@ -16,28 +16,28 @@ class AjaxFormsTestForm {
    * @todo Remove ajax_forms_test_simple_form().
    */
   public function getForm() {
-    return drupal_get_form('ajax_forms_test_simple_form');
+    return \Drupal::formBuilder()->getForm('ajax_forms_test_simple_form');
   }
 
   /**
    * @todo Remove ajax_forms_test_ajax_commands_form().
    */
   public function commandsForm() {
-    return drupal_get_form('ajax_forms_test_ajax_commands_form');
+    return \Drupal::formBuilder()->getForm('ajax_forms_test_ajax_commands_form');
   }
 
   /**
    * @todo Remove ajax_forms_test_validation_form().
    */
   public function validationForm() {
-    return drupal_get_form('ajax_forms_test_validation_form');
+    return \Drupal::formBuilder()->getForm('ajax_forms_test_validation_form');
   }
 
   /**
    * @todo Remove ajax_forms_test_lazy_load_form().
    */
   public function lazyLoadForm() {
-    return drupal_get_form('ajax_forms_test_lazy_load_form');
+    return \Drupal::formBuilder()->getForm('ajax_forms_test_lazy_load_form');
   }
 
 }
diff --git a/core/modules/system/tests/modules/batch_test/lib/Drupal/batch_test/Form/BatchTestForm.php b/core/modules/system/tests/modules/batch_test/lib/Drupal/batch_test/Form/BatchTestForm.php
index af9dbc95771a..fd015ff872d2 100644
--- a/core/modules/system/tests/modules/batch_test/lib/Drupal/batch_test/Form/BatchTestForm.php
+++ b/core/modules/system/tests/modules/batch_test/lib/Drupal/batch_test/Form/BatchTestForm.php
@@ -16,21 +16,21 @@ class BatchTestForm {
    * @todo Remove batch_test_simple_form().
    */
   public function testForm() {
-    return drupal_get_form('batch_test_simple_form');
+    return \Drupal::formBuilder()->getForm('batch_test_simple_form');
   }
 
   /**
    * @todo Remove batch_test_multistep_form().
    */
   public function testMultistepForm() {
-    return drupal_get_form('batch_test_multistep_form');
+    return \Drupal::formBuilder()->getForm('batch_test_multistep_form');
   }
 
   /**
    * @todo Remove batch_test_chained_form().
    */
   public function testChainedForm() {
-    return drupal_get_form('batch_test_chained_form');
+    return \Drupal::formBuilder()->getForm('batch_test_chained_form');
   }
 
 }
diff --git a/core/modules/system/tests/modules/database_test/lib/Drupal/database_test/Form/DatabaseTestForm.php b/core/modules/system/tests/modules/database_test/lib/Drupal/database_test/Form/DatabaseTestForm.php
index 4ec7f5007a3f..2923faf872c1 100644
--- a/core/modules/system/tests/modules/database_test/lib/Drupal/database_test/Form/DatabaseTestForm.php
+++ b/core/modules/system/tests/modules/database_test/lib/Drupal/database_test/Form/DatabaseTestForm.php
@@ -16,7 +16,7 @@ class DatabaseTestForm {
    * @todo Remove database_test_theme_tablesort().
    */
   public function testTablesortDefaultSort() {
-    return drupal_get_form('database_test_theme_tablesort');
+    return \Drupal::formBuilder()->getForm('database_test_theme_tablesort');
   }
 
 }
diff --git a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Form/FormTestForm.php b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Form/FormTestForm.php
index 7b139322d7de..aaacf4050fcf 100644
--- a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Form/FormTestForm.php
+++ b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Form/FormTestForm.php
@@ -18,7 +18,7 @@ class FormTestForm {
    * @todo Remove form_test_alter_form().
    */
   public function alterForm() {
-    return drupal_get_form('form_test_alter_form');
+    return \Drupal::formBuilder()->getForm('form_test_alter_form');
   }
 
   /**
@@ -27,7 +27,7 @@ public function alterForm() {
    * @todo Remove form_test_validate_form().
    */
   public function validateForm() {
-    return drupal_get_form('form_test_validate_form');
+    return \Drupal::formBuilder()->getForm('form_test_validate_form');
   }
 
   /**
@@ -36,7 +36,7 @@ public function validateForm() {
    * @todo Remove form_test_validate_required_form().
    */
   public function validateRequiredForm() {
-    return drupal_get_form('form_test_validate_required_form');
+    return \Drupal::formBuilder()->getForm('form_test_validate_required_form');
   }
 
   /**
@@ -45,7 +45,7 @@ public function validateRequiredForm() {
    * @todo Remove form_test_validate_required_form_no_title().
    */
   public function validateRequiredFormNoTitle() {
-    return drupal_get_form('form_test_validate_required_form_no_title');
+    return \Drupal::formBuilder()->getForm('form_test_validate_required_form_no_title');
   }
 
   /**
@@ -54,7 +54,7 @@ public function validateRequiredFormNoTitle() {
    * @todo Remove form_test_limit_validation_errors_form().
    */
   public function validateFormWithErrorSuppression() {
-    return drupal_get_form('form_test_limit_validation_errors_form');
+    return \Drupal::formBuilder()->getForm('form_test_limit_validation_errors_form');
   }
 
   /**
@@ -63,7 +63,7 @@ public function validateFormWithErrorSuppression() {
    * @todo Remove form_test_pattern_form().
    */
   public function validatePattern() {
-    return drupal_get_form('form_test_pattern_form');
+    return \Drupal::formBuilder()->getForm('form_test_pattern_form');
   }
 
   /**
@@ -72,7 +72,7 @@ public function validatePattern() {
    * @todo Remove _form_test_tableselect_multiple_true_form().
    */
   public function testTableSelectCheckboxes() {
-    return drupal_get_form('_form_test_tableselect_multiple_true_form');
+    return \Drupal::formBuilder()->getForm('_form_test_tableselect_multiple_true_form');
   }
 
   /**
@@ -81,7 +81,7 @@ public function testTableSelectCheckboxes() {
    * @todo Remove _form_test_tableselect_multiple_false_form().
    */
   public function testTableSelectRadios() {
-    return drupal_get_form('_form_test_tableselect_multiple_false_form');
+    return \Drupal::formBuilder()->getForm('_form_test_tableselect_multiple_false_form');
   }
 
   /**
@@ -90,7 +90,7 @@ public function testTableSelectRadios() {
    * @todo Remove _form_test_tableselect_colspan_form().
    */
   public function testTableSelectColspan() {
-    return drupal_get_form('_form_test_tableselect_colspan_form');
+    return \Drupal::formBuilder()->getForm('_form_test_tableselect_colspan_form');
   }
 
   /**
@@ -99,7 +99,7 @@ public function testTableSelectColspan() {
    * @todo Remove _form_test_tableselect_empty_form().
    */
   public function testTableSelectEmptyText() {
-    return drupal_get_form('_form_test_tableselect_empty_form');
+    return \Drupal::formBuilder()->getForm('_form_test_tableselect_empty_form');
   }
 
   /**
@@ -108,7 +108,7 @@ public function testTableSelectEmptyText() {
    * @todo Remove _form_test_tableselect_js_select_form().
    */
   public function testTableSelectJS($test_action) {
-    return drupal_get_form('_form_test_tableselect_js_select_form', $test_action);
+    return \Drupal::formBuilder()->getForm('_form_test_tableselect_js_select_form', $test_action);
   }
 
   /**
@@ -117,7 +117,7 @@ public function testTableSelectJS($test_action) {
    * @todo Remove _form_test_vertical_tabs_form().
    */
   public function testVerticalTabs() {
-    return drupal_get_form('_form_test_vertical_tabs_form');
+    return \Drupal::formBuilder()->getForm('_form_test_vertical_tabs_form');
   }
 
   /**
@@ -126,7 +126,7 @@ public function testVerticalTabs() {
    * @todo Remove form_test_storage_form().
    */
   public function testStorage() {
-    return drupal_get_form('form_test_storage_form');
+    return \Drupal::formBuilder()->getForm('form_test_storage_form');
   }
 
   /**
@@ -135,7 +135,7 @@ public function testStorage() {
    * @todo Remove form_test_form_state_values_clean_form().
    */
   public function testFormStateClean() {
-    return drupal_get_form('form_test_form_state_values_clean_form');
+    return \Drupal::formBuilder()->getForm('form_test_form_state_values_clean_form');
   }
 
   /**
@@ -144,7 +144,7 @@ public function testFormStateClean() {
    * @todo Remove form_test_form_state_values_clean_advanced_form().
    */
   public function testFormStateCleanAdvanced() {
-    return drupal_get_form('form_test_form_state_values_clean_advanced_form');
+    return \Drupal::formBuilder()->getForm('form_test_form_state_values_clean_advanced_form');
   }
 
   /**
@@ -153,7 +153,7 @@ public function testFormStateCleanAdvanced() {
    * @todo Remove _form_test_checkbox().
    */
   public function testCheckbox() {
-    return drupal_get_form('_form_test_checkbox');
+    return \Drupal::formBuilder()->getForm('_form_test_checkbox');
   }
 
   /**
@@ -162,7 +162,7 @@ public function testCheckbox() {
    * @todo Remove form_test_select().
    */
   public function testSelect() {
-    return drupal_get_form('form_test_select');
+    return \Drupal::formBuilder()->getForm('form_test_select');
   }
 
   /**
@@ -171,7 +171,7 @@ public function testSelect() {
    * @todo Remove form_test_empty_select().
    */
   public function testEmptySelect() {
-    return drupal_get_form('form_test_empty_select');
+    return \Drupal::formBuilder()->getForm('form_test_empty_select');
   }
 
   /**
@@ -180,7 +180,7 @@ public function testEmptySelect() {
    * @todo Remove form_test_language_select().
    */
   public function testLanguageSelect() {
-    return drupal_get_form('form_test_language_select');
+    return \Drupal::formBuilder()->getForm('form_test_language_select');
   }
 
   /**
@@ -189,7 +189,7 @@ public function testLanguageSelect() {
    * @todo Remove form_test_placeholder_test().
    */
   public function testPlaceholder() {
-    return drupal_get_form('form_test_placeholder_test');
+    return \Drupal::formBuilder()->getForm('form_test_placeholder_test');
   }
 
   /**
@@ -198,7 +198,7 @@ public function testPlaceholder() {
    * @todo Remove form_test_number().
    */
   public function testNumber() {
-    return drupal_get_form('form_test_number');
+    return \Drupal::formBuilder()->getForm('form_test_number');
   }
 
   /**
@@ -207,7 +207,7 @@ public function testNumber() {
    * @todo Remove form_test_number().
    */
   public function testNumberRange() {
-    return drupal_get_form('form_test_number', 'range');
+    return \Drupal::formBuilder()->getForm('form_test_number', 'range');
   }
 
   /**
@@ -216,7 +216,7 @@ public function testNumberRange() {
    * @todo Remove form_test_range().
    */
   public function testRange() {
-    return drupal_get_form('form_test_range');
+    return \Drupal::formBuilder()->getForm('form_test_range');
   }
 
   /**
@@ -225,7 +225,7 @@ public function testRange() {
    * @todo Remove form_test_range_invalid().
    */
   public function testRangeInvalid() {
-    return drupal_get_form('form_test_range_invalid');
+    return \Drupal::formBuilder()->getForm('form_test_range_invalid');
   }
 
   /**
@@ -234,7 +234,7 @@ public function testRangeInvalid() {
    * @todo Remove form_test_color().
    */
   public function testColor() {
-    return drupal_get_form('form_test_color');
+    return \Drupal::formBuilder()->getForm('form_test_color');
   }
 
   /**
@@ -243,7 +243,7 @@ public function testColor() {
    * @todo Remove form_test_checkboxes_radios().
    */
   public function testCheckboxesRadios($customize) {
-    return drupal_get_form('form_test_checkboxes_radios', $customize);
+    return \Drupal::formBuilder()->getForm('form_test_checkboxes_radios', $customize);
   }
 
   /**
@@ -252,7 +252,7 @@ public function testCheckboxesRadios($customize) {
    * @todo Remove form_test_email().
    */
   public function testEmail() {
-    return drupal_get_form('form_test_email');
+    return \Drupal::formBuilder()->getForm('form_test_email');
   }
 
   /**
@@ -261,7 +261,7 @@ public function testEmail() {
    * @todo Remove form_test_url().
    */
   public function testUrl() {
-    return drupal_get_form('form_test_url');
+    return \Drupal::formBuilder()->getForm('form_test_url');
   }
 
   /**
@@ -270,7 +270,7 @@ public function testUrl() {
    * @todo Remove _form_test_disabled_elements().
    */
   public function testDisabledElements() {
-    return drupal_get_form('_form_test_disabled_elements');
+    return \Drupal::formBuilder()->getForm('_form_test_disabled_elements');
   }
 
   /**
@@ -279,7 +279,7 @@ public function testDisabledElements() {
    * @todo Remove _form_test_input_forgery().
    */
   public function testInputForgery() {
-    return drupal_get_form('_form_test_input_forgery');
+    return \Drupal::formBuilder()->getForm('_form_test_input_forgery');
   }
 
   /**
@@ -288,7 +288,7 @@ public function testInputForgery() {
    * @todo Remove form_test_form_rebuild_preserve_values_form().
    */
   public function testRebuildPreservation() {
-    return drupal_get_form('form_test_form_rebuild_preserve_values_form');
+    return \Drupal::formBuilder()->getForm('form_test_form_rebuild_preserve_values_form');
   }
 
   /**
@@ -297,7 +297,7 @@ public function testRebuildPreservation() {
    * @todo Remove form_test_redirect().
    */
   public function testRedirect() {
-    return drupal_get_form('form_test_redirect');
+    return \Drupal::formBuilder()->getForm('form_test_redirect');
   }
 
   /**
@@ -306,7 +306,7 @@ public function testRedirect() {
    * @todo Remove form_label_test_form().
    */
   public function testLabel() {
-    return drupal_get_form('form_label_test_form');
+    return \Drupal::formBuilder()->getForm('form_label_test_form');
   }
 
   /**
@@ -315,7 +315,7 @@ public function testLabel() {
    * @todo Remove form_test_state_persist().
    */
   public function testStatePersistence() {
-    return drupal_get_form('form_test_state_persist');
+    return \Drupal::formBuilder()->getForm('form_test_state_persist');
   }
 
   /**
@@ -324,7 +324,7 @@ public function testStatePersistence() {
    * @todo Remove form_test_clicked_button().
    */
   public function testClickedButton($first, $second, $third) {
-    return drupal_get_form('form_test_clicked_button', $first, $second, $third);
+    return \Drupal::formBuilder()->getForm('form_test_clicked_button', $first, $second, $third);
   }
 
   /**
@@ -333,7 +333,7 @@ public function testClickedButton($first, $second, $third) {
    * @todo Remove form_test_checkboxes_zero().
    */
   public function testCheckboxesZero($json) {
-    return drupal_get_form('form_test_checkboxes_zero', $json);
+    return \Drupal::formBuilder()->getForm('form_test_checkboxes_zero', $json);
   }
 
   /**
@@ -342,7 +342,7 @@ public function testCheckboxesZero($json) {
    * @todo Remove form_test_required_attribute().
    */
   public function testRequired() {
-    return drupal_get_form('form_test_required_attribute');
+    return \Drupal::formBuilder()->getForm('form_test_required_attribute');
   }
 
   /**
@@ -351,7 +351,7 @@ public function testRequired() {
    * @todo Remove form_test_button_class().
    */
   public function testButtonClass() {
-    return drupal_get_form('form_test_button_class');
+    return \Drupal::formBuilder()->getForm('form_test_button_class');
   }
 
   /**
@@ -360,7 +360,7 @@ public function testButtonClass() {
    * @todo Remove form_test_group_details().
    */
   public function testGroupDetails() {
-    return drupal_get_form('form_test_group_details');
+    return \Drupal::formBuilder()->getForm('form_test_group_details');
   }
 
   /**
@@ -369,7 +369,7 @@ public function testGroupDetails() {
    * @todo Remove form_test_group_container().
    */
   public function testGroupContainer() {
-    return drupal_get_form('form_test_group_container');
+    return \Drupal::formBuilder()->getForm('form_test_group_container');
   }
 
   /**
@@ -378,7 +378,7 @@ public function testGroupContainer() {
    * @todo Remove form_test_group_fieldset().
    */
   public function testGroupFieldset() {
-    return drupal_get_form('form_test_group_fieldset');
+    return \Drupal::formBuilder()->getForm('form_test_group_fieldset');
   }
 
   /**
@@ -387,7 +387,7 @@ public function testGroupFieldset() {
    * @todo Remove form_test_group_vertical_tabs().
    */
   public function testGroupVerticalTabs() {
-    return drupal_get_form('form_test_group_vertical_tabs');
+    return \Drupal::formBuilder()->getForm('form_test_group_vertical_tabs');
   }
 
   /**
@@ -396,7 +396,7 @@ public function testGroupVerticalTabs() {
    * @todo Remove form_test_form_state_database().
    */
   public function testFormStateDatabase() {
-    return drupal_get_form('form_test_form_state_database');
+    return \Drupal::formBuilder()->getForm('form_test_form_state_database');
   }
 
 }
diff --git a/core/modules/update/lib/Drupal/update/Form/UpdateForm.php b/core/modules/update/lib/Drupal/update/Form/UpdateForm.php
index b9046339f4fd..8f416c1cdcdc 100644
--- a/core/modules/update/lib/Drupal/update/Form/UpdateForm.php
+++ b/core/modules/update/lib/Drupal/update/Form/UpdateForm.php
@@ -18,7 +18,7 @@ class UpdateForm {
    */
   public function reportInstall() {
     module_load_include('manager.inc', 'update');
-    return drupal_get_form('update_manager_install_form', 'report');
+    return \Drupal::formBuilder()->getForm('update_manager_install_form', 'report');
   }
 
   /**
@@ -28,7 +28,7 @@ public function reportInstall() {
    */
   public function reportUpdate() {
     module_load_include('manager.inc', 'update');
-    return drupal_get_form('update_manager_update_form', 'report');
+    return \Drupal::formBuilder()->getForm('update_manager_update_form', 'report');
   }
 
   /**
@@ -38,7 +38,7 @@ public function reportUpdate() {
    */
   public function moduleInstall() {
     module_load_include('manager.inc', 'update');
-    return drupal_get_form('update_manager_install_form', 'module');
+    return \Drupal::formBuilder()->getForm('update_manager_install_form', 'module');
   }
 
   /**
@@ -48,7 +48,7 @@ public function moduleInstall() {
    */
   public function moduleUpdate() {
     module_load_include('manager.inc', 'update');
-    return drupal_get_form('update_manager_update_form', 'module');
+    return \Drupal::formBuilder()->getForm('update_manager_update_form', 'module');
   }
 
   /**
@@ -58,7 +58,7 @@ public function moduleUpdate() {
    */
   public function themeInstall() {
     module_load_include('manager.inc', 'update');
-    return drupal_get_form('update_manager_install_form', 'theme');
+    return \Drupal::formBuilder()->getForm('update_manager_install_form', 'theme');
   }
 
   /**
@@ -68,7 +68,7 @@ public function themeInstall() {
    */
   public function themeUpdate() {
     module_load_include('manager.inc', 'update');
-    return drupal_get_form('update_manager_update_form', 'theme');
+    return \Drupal::formBuilder()->getForm('update_manager_update_form', 'theme');
   }
 
   /**
@@ -78,7 +78,7 @@ public function themeUpdate() {
    */
   public function confirmUpdates() {
     module_load_include('manager.inc', 'update');
-    return drupal_get_form('update_manager_update_ready_form');
+    return \Drupal::formBuilder()->getForm('update_manager_update_ready_form');
   }
 
 }
diff --git a/core/modules/user/lib/Drupal/user/Form/UserForm.php b/core/modules/user/lib/Drupal/user/Form/UserForm.php
index 49c8c7666613..919cb1eae67c 100644
--- a/core/modules/user/lib/Drupal/user/Form/UserForm.php
+++ b/core/modules/user/lib/Drupal/user/Form/UserForm.php
@@ -18,7 +18,7 @@ class UserForm {
    */
   public function resetPass($uid, $timestamp, $hash, $operation) {
     module_load_include('pages.inc', 'user');
-    return drupal_get_form('user_pass_reset', $uid, $timestamp, $hash, $operation);
+    return \Drupal::formBuilder()->getForm('user_pass_reset', $uid, $timestamp, $hash, $operation);
   }
 
 }
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php b/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php
index c087889a96aa..b2cff4c2a9a0 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php
@@ -32,7 +32,7 @@ public function access(AccountInterface $account) {
    * {@inheritdoc}
    */
   public function build() {
-    $form = drupal_get_form('Drupal\user\Form\UserLoginForm');
+    $form = \Drupal::formBuilder()->getForm('Drupal\user\Form\UserLoginForm');
     unset($form['name']['#attributes']['autofocus']);
     unset($form['name']['#description']);
     unset($form['pass']['#description']);
-- 
GitLab