summaryrefslogtreecommitdiffstatshomepage
path: root/core/includes/form.inc
diff options
context:
space:
mode:
Diffstat (limited to 'core/includes/form.inc')
-rw-r--r--core/includes/form.inc70
1 files changed, 35 insertions, 35 deletions
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 2e2d2be98f3..05f2a9e1fce 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -29,8 +29,8 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
*/
function template_preprocess_select(&$variables) {
$element = $variables['element'];
- Element::setAttributes($element, array('id', 'name', 'size'));
- RenderElement::setAttributes($element, array('form-select'));
+ Element::setAttributes($element, ['id', 'name', 'size']);
+ RenderElement::setAttributes($element, ['form-select']);
$variables['attributes'] = $element['#attributes'];
$variables['options'] = form_select_options($element);
@@ -161,7 +161,7 @@ function form_select_options($element, $choices = NULL) {
* empty if no elements were found. FALSE if optgroups were found.
*/
function form_get_options($element, $key) {
- $keys = array();
+ $keys = [];
foreach ($element['#options'] as $index => $choice) {
if (is_array($choice)) {
return FALSE;
@@ -191,9 +191,9 @@ function form_get_options($element, $key) {
*/
function template_preprocess_fieldset(&$variables) {
$element = $variables['element'];
- Element::setAttributes($element, array('id'));
+ Element::setAttributes($element, ['id']);
RenderElement::setAttributes($element);
- $variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : array();
+ $variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : [];
$variables['prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : NULL;
$variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL;
$variables['title_display'] = isset($element['#title_display']) ? $element['#title_display'] : NULL;
@@ -273,7 +273,7 @@ function template_preprocess_details(&$variables) {
*/
function template_preprocess_radios(&$variables) {
$element = $variables['element'];
- $variables['attributes'] = array();
+ $variables['attributes'] = [];
if (isset($element['#id'])) {
$variables['attributes']['id'] = $element['#id'];
}
@@ -295,7 +295,7 @@ function template_preprocess_radios(&$variables) {
*/
function template_preprocess_checkboxes(&$variables) {
$element = $variables['element'];
- $variables['attributes'] = array();
+ $variables['attributes'] = [];
if (isset($element['#id'])) {
$variables['attributes']['id'] = $element['#id'];
}
@@ -354,7 +354,7 @@ function template_preprocess_form(&$variables) {
if (isset($element['#action'])) {
$element['#attributes']['action'] = UrlHelper::stripDangerousProtocols($element['#action']);
}
- Element::setAttributes($element, array('method', 'id'));
+ Element::setAttributes($element, ['method', 'id']);
if (empty($element['#attributes']['accept-charset'])) {
$element['#attributes']['accept-charset'] = "UTF-8";
}
@@ -375,8 +375,8 @@ function template_preprocess_form(&$variables) {
*/
function template_preprocess_textarea(&$variables) {
$element = $variables['element'];
- Element::setAttributes($element, array('id', 'name', 'rows', 'cols', 'placeholder'));
- RenderElement::setAttributes($element, array('form-textarea'));
+ Element::setAttributes($element, ['id', 'name', 'rows', 'cols', 'placeholder']);
+ RenderElement::setAttributes($element, ['form-textarea']);
$variables['wrapper_attributes'] = new Attribute();
$variables['attributes'] = new Attribute($element['#attributes']);
$variables['value'] = $element['#value'];
@@ -429,11 +429,11 @@ function template_preprocess_form_element(&$variables) {
// This function is invoked as theme wrapper, but the rendered form element
// may not necessarily have been processed by
// \Drupal::formBuilder()->doBuildForm().
- $element += array(
+ $element += [
'#title_display' => 'before',
- '#wrapper_attributes' => array(),
- '#label_attributes' => array(),
- );
+ '#wrapper_attributes' => [],
+ '#label_attributes' => [],
+ ];
$variables['attributes'] = $element['#wrapper_attributes'];
// Add element #id for #type 'item'.
@@ -478,8 +478,8 @@ function template_preprocess_form_element(&$variables) {
// Add label_display and label variables to template.
$variables['label_display'] = $element['#title_display'];
- $variables['label'] = array('#theme' => 'form_element_label');
- $variables['label'] += array_intersect_key($element, array_flip(array('#id', '#required', '#title', '#title_display')));
+ $variables['label'] = ['#theme' => 'form_element_label'];
+ $variables['label'] += array_intersect_key($element, array_flip(['#id', '#required', '#title', '#title_display']));
$variables['label']['#attributes'] = $element['#label_attributes'];
$variables['children'] = $element['#children'];
@@ -717,26 +717,26 @@ function batch_set($batch_definition) {
// Initialize the batch if needed.
if (empty($batch)) {
- $batch = array(
- 'sets' => array(),
+ $batch = [
+ 'sets' => [],
'has_form_submits' => FALSE,
- );
+ ];
}
// Base and default properties for the batch set.
- $init = array(
- 'sandbox' => array(),
- 'results' => array(),
+ $init = [
+ 'sandbox' => [],
+ 'results' => [],
'success' => FALSE,
'start' => 0,
'elapsed' => 0,
- );
- $defaults = array(
+ ];
+ $defaults = [
'title' => t('Processing'),
'init_message' => t('Initializing.'),
'progress_message' => t('Completed @current of @total.'),
'error_message' => t('An error has occurred.'),
- );
+ ];
$batch_set = $init + $batch_definition + $defaults;
// Tweak init_message to avoid the bottom of the page flickering down after
@@ -760,7 +760,7 @@ function batch_set($batch_definition) {
$index = $batch['current_set'] + 1;
$slice1 = array_slice($batch['sets'], 0, $index);
$slice2 = array_slice($batch['sets'], $index);
- $batch['sets'] = array_merge($slice1, array($batch_set), $slice2);
+ $batch['sets'] = array_merge($slice1, [$batch_set], $slice2);
_batch_populate_queue($batch, $index);
}
}
@@ -800,7 +800,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
if (isset($batch)) {
// Add process information
- $process_info = array(
+ $process_info = [
'current_set' => 0,
'progressive' => TRUE,
'url' => isset($url) ? $url : Url::fromRoute('system.batch_page.html'),
@@ -808,7 +808,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
'batch_redirect' => $redirect,
'theme' => \Drupal::theme()->getActiveTheme()->getName(),
'redirect_callback' => $redirect_callback,
- );
+ ];
$batch += $process_info;
// The batch is now completely built. Allow other modules to make changes
@@ -839,7 +839,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
$query_options['op'] = 'finished';
$error_url->setOption('query', $query_options);
- $batch['error_message'] = t('Please continue to <a href=":error_url">the error page</a>', array(':error_url' => $error_url->toString(TRUE)->getGeneratedUrl()));
+ $batch['error_message'] = t('Please continue to <a href=":error_url">the error page</a>', [':error_url' => $error_url->toString(TRUE)->getGeneratedUrl()]);
// Clear the way for the redirection to the batch processing page, by
// saving and unsetting the 'destination', if there is any.
@@ -886,7 +886,7 @@ function &batch_get() {
// that are part of the Batch API and need to reset the batch information may
// call batch_get() and manipulate the result by reference. Functions that are
// not part of the Batch API can also do this, but shouldn't.
- static $batch = array();
+ static $batch = [];
return $batch;
}
@@ -907,12 +907,12 @@ function _batch_populate_queue(&$batch, $set_id) {
$batch_set = &$batch['sets'][$set_id];
if (isset($batch_set['operations'])) {
- $batch_set += array(
- 'queue' => array(
+ $batch_set += [
+ 'queue' => [
'name' => 'drupal_batch:' . $batch['id'] . ':' . $set_id,
'class' => $batch['progressive'] ? 'Drupal\Core\Queue\Batch' : 'Drupal\Core\Queue\BatchMemory',
- ),
- );
+ ],
+ ];
$queue = _batch_queue($batch_set);
$queue->createQueue();
@@ -937,7 +937,7 @@ function _batch_queue($batch_set) {
static $queues;
if (!isset($queues)) {
- $queues = array();
+ $queues = [];
}
if (isset($batch_set['queue'])) {