Commit 7a91c2e8 authored by webchick's avatar webchick

Issue #2121175 by Codenator, tim.plunkett, cosmicdreams, jayeshanandani,...

Issue #2121175 by Codenator, tim.plunkett, cosmicdreams, jayeshanandani, grom358, ianthomas_uk, Xano: Remove usage of drupal_get_form().
parent 204ecf18
......@@ -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);
}
}
......
......@@ -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) {
......
......@@ -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(
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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();
......
......@@ -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);
}
/**
......
......@@ -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);
}
}
......@@ -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());
}
/**
......
......@@ -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');
}
}
......
......@@ -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');
}
}
......@@ -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;
......
......@@ -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');
}
}
......@@ -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);
......
......@@ -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);
}
}
......@@ -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;
......
......@@ -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
......
......@@ -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');
}
}
......@@ -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');
}
}
......@@ -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');
}
}
......@@ -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');
}
}
......@@ -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);
}
}
......@@ -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']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment