Loading core/core.api.php +16 −16 Original line number Diff line number Diff line Loading @@ -537,16 +537,16 @@ * Example: * @code * // A cache item with nodes, users, and some custom module data. * $tags = array( * $tags = [ * 'my_custom_tag', * 'node:1', * 'node:3', * 'user:7', * ); * ]; * \Drupal::cache()->set($cid, $data, CacheBackendInterface::CACHE_PERMANENT, $tags); * * // Invalidate all cache items with certain tags. * \Drupal\Core\Cache\Cache::invalidateTags(array('user:1')); * \Drupal\Core\Cache\Cache::invalidateTags(['user:1']); * @endcode * * Drupal is a content management system, so naturally you want changes to your Loading Loading @@ -1712,14 +1712,14 @@ * * public function buildForm(array $form, FormStateInterface $form_state) { * // Create a $form API array. * $form['phone_number'] = array( * $form['phone_number'] = [ * '#type' => 'tel', * '#title' => $this->t('Your phone number'), * ); * $form['save'] = array( * ]; * $form['save'] = [ * '#type' => 'submit', * '#value' => $this->t('Save'), * ); * ]; * return $form; * } * Loading Loading @@ -1753,11 +1753,11 @@ * $form = \Drupal::formBuilder()->getForm('Drupal\my_module\Form\ExampleForm', $extra); * ... * public function buildForm(array $form, FormStateInterface $form_state, $extra = NULL) * $form['phone_number'] = array( * $form['phone_number'] = [ * '#type' => 'tel', * '#title' => $this->t('Your phone number'), * '#value' => $extra, * ); * ]; * return $form; * } * @endcode Loading Loading @@ -2340,14 +2340,14 @@ function hook_validation_constraint_alter(array &$definitions) { * Ajax response. This is done in the text field form array element * in \Drupal\config_translation\FormElement\DateFormat::getFormElement(): * @code * '#ajax' => array( * '#ajax' => [ * 'callback' => 'Drupal\config_translation\FormElement\DateFormat::ajaxSample', * 'event' => 'keyup', * 'progress' => array( * 'progress' => [ * 'type' => 'throbber', * 'message' => NULL, * ), * ), * ], * ], * @endcode * * As you can see from this example, the #ajax property for a form element is Loading Loading @@ -2435,7 +2435,7 @@ function hook_validation_constraint_alter(array &$definitions) { * 'wrapper' method and return HTML markup. This is not the case if you return * commands, but if you would like to show status messages, you can add * @code * array('#type' => 'status_messages') * ['#type' => 'status_messages'] * @endcode * to a render array, use \Drupal::service('renderer')->render() to render it, * and add a command to place the messages in an appropriate location. Loading Loading @@ -2596,9 +2596,9 @@ function hook_validation_constraint_alter(array &$definitions) { * @code * public static function getSubscribedEvents() { * // Subscribe to kernel terminate with priority 100. * $events[KernelEvents::TERMINATE][] = array('onTerminate', 100); * $events[KernelEvents::TERMINATE][] = ['onTerminate', 100]; * // Subscribe to kernel request with default priority of 0. * $events[KernelEvents::REQUEST][] = array('onRequest'); * $events[KernelEvents::REQUEST][] = ['onRequest']; * return $events; * } * @endcode Loading core/includes/common.inc +14 −14 Original line number Diff line number Diff line Loading @@ -173,14 +173,14 @@ function base_path() { * into a table. The table must have an ID attribute set and it * may be set as follows: * @code * $table = array( * $table = [ * '#type' => 'table', * '#header' => $header, * '#rows' => $rows, * '#attributes' => array( * '#attributes' => [ * 'id' => 'my-module-table', * ), * ); * ], * ]; * return \Drupal::service('renderer')->render($table); * @endcode * Loading @@ -190,17 +190,17 @@ function base_path() { * In a situation where a single weight column is being sorted in the table, the * classes could be added like this (in the theme function): * @code * $form['my_elements'][$delta]['weight']['#attributes']['class'] = array('my-elements-weight'); * $form['my_elements'][$delta]['weight']['#attributes']['class'] = ['my-elements-weight']; * @endcode * * Each row of the table must also have a class of "draggable" in order to * enable the drag handles: * @code * $row = array(...); * $rows[] = array( * $row = [...]; * $rows[] = [ * 'data' => $row, * 'class' => array('draggable'), * ); * 'class' => ['draggable'], * ]; * @endcode * * When tree relationships are present, the two additional classes Loading @@ -210,18 +210,18 @@ function base_path() { * * Calling drupal_attach_tabledrag() would then be written as such: * @code * drupal_attach_tabledrag('my-module-table', array( * drupal_attach_tabledrag('my-module-table', [ * 'action' => 'order', * 'relationship' => 'sibling', * 'group' => 'my-elements-weight', * ); * ]; * @endcode * * In a more complex case where there are several groups in one column (such as * the block regions on the admin/structure/block page), a separate subgroup * class must also be added to differentiate the groups. * @code * $form['my_elements'][$region][$delta]['weight']['#attributes']['class'] = array('my-elements-weight', 'my-elements-weight-' . $region); * $form['my_elements'][$region][$delta]['weight']['#attributes']['class'] = ['my-elements-weight', 'my-elements-weight-' . $region]; * @endcode * * The 'group' option is still 'my-element-weight', and the additional Loading @@ -231,12 +231,12 @@ function base_path() { * * @code * foreach ($regions as $region) { * drupal_attach_tabledrag('my-module-table', array( * drupal_attach_tabledrag('my-module-table', [ * 'action' => 'order', * 'relationship' => 'sibling', * 'group' => 'my-elements-weight', * 'subgroup' => 'my-elements-weight-' . $region, * )); * ]); * } * @endcode * Loading core/includes/form.inc +13 −13 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ function form_select_options($element, $choices = NULL) { * index is not sufficient, and supporting this would make the * "helper" too complicated and cumbersome to be of any help. * * As usual with functions that can return array() or FALSE, do not * As usual with functions that can return [] or FALSE, do not * forget to use === and !== if needed. * * @param $element Loading Loading @@ -576,15 +576,15 @@ function template_preprocess_form_element_label(&$variables) { * * Example: * @code * $batch = array( * $batch = [ * 'title' => t('Exporting'), * 'operations' => array( * array('my_function_1', array($account->id(), 'story')), * array('my_function_2', array()), * ), * 'operations' => [ * ['my_function_1', [$account->id(), 'story']], * ['my_function_2', []], * ], * 'finished' => 'my_finished_callback', * 'file' => 'path_to_file_containing_my_functions', * ); * ]; * batch_set($batch); * // Only needed if not inside a form _submit handler. * // Setting redirect in batch_process. Loading Loading @@ -638,7 +638,7 @@ function template_preprocess_form_element_label(&$variables) { * } * $limit = 5; * $result = \Drupal::database()->select('example') * ->fields('example', array('id')) * ->fields('example', ['id']) * ->condition('id', $context['sandbox']['current_id'], '>') * ->orderBy('id') * ->range(0, $limit) Loading Loading @@ -671,7 +671,7 @@ function template_preprocess_form_element_label(&$variables) { * \Drupal::messenger()->addMessage($message); * // Providing data for the redirected page is done through the session. * foreach ($results as $result) { * $items[] = t('Loaded node %title.', array('%title' => $result)); * $items[] = t('Loaded node %title.', ['%title' => $result)]; * } * $session = \Drupal::getRequest()->getSession(); * $session->set('my_batch_results', $items); Loading Loading @@ -702,10 +702,10 @@ function template_preprocess_form_element_label(&$variables) { * callback_batch_operation() and an array of parameter. * Example: * @code * array( * array('callback_batch_operation_1', array($arg1)), * array('callback_batch_operation_2', array($arg2_1, $arg2_2)), * ) * [ * ['callback_batch_operation_1', [$arg1)], * ['callback_batch_operation_2', [$arg2_1, $arg2_2]], * ] * @endcode * - title: A safe, translated string to use as the title for the progress * page. Defaults to t('Processing'). Loading core/includes/install.inc +2 −2 Original line number Diff line number Diff line Loading @@ -255,10 +255,10 @@ function drupal_get_database_types() { * are dumped up to a stdClass object. The object can have value, required * and comment properties. * @code * $settings['settings']['config_sync_directory'] = (object) array( * $settings['settings']['config_sync_directory'] = (object) [ * 'value' => 'config_hash/sync', * 'required' => TRUE, * ); * ]; * @endcode * gets dumped as: * @code Loading core/includes/theme.inc +22 −22 Original line number Diff line number Diff line Loading @@ -863,16 +863,16 @@ function template_preprocess_image(&$variables) { * - Any HTML attributes, such as "colspan", to apply to the table cell. * Here's an example for $rows: * @code * $rows = array( * $rows = [ * // Simple row * array( * [ * 'Cell 1', 'Cell 2', 'Cell 3' * ), * ], * // Row with attributes on the row and some of its cells. * array( * 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => array('funky') * ), * ); * [ * 'data' => ['Cell 1', ['data' => 'Cell 2', 'colspan' => 2]], 'class' => ['funky'] * ], * ]; * @endcode * - footer: An array of table rows which will be printed within a <tfoot> * tag, in the same format as the rows element (see above). Loading @@ -888,23 +888,23 @@ function template_preprocess_image(&$variables) { * associative array of HTML attributes. * Here's an example for $colgroup: * @code * $colgroup = array( * $colgroup = [ * // <colgroup> with one <col> element. * array( * array( * 'class' => array('funky'), // Attribute for the <col> element. * ), * ), * [ * [ * 'class' => ['funky'], // Attribute for the <col> element. * ], * ], * // <colgroup> with attributes and inner <col> elements. * array( * 'data' => array( * array( * 'class' => array('funky'), // Attribute for the <col> element. * ), * ), * 'class' => array('jazzy'), // Attribute for the <colgroup> element. * ), * ); * [ * 'data' => [ * [ * 'class' => ['funky'], // Attribute for the <col> element. * ], * ], * 'class' => ['jazzy'], // Attribute for the <colgroup> element. * ], * ]; * @endcode * These optional tags are used to group and set properties on columns * within a table. For example, one may easily group three columns and Loading Loading
core/core.api.php +16 −16 Original line number Diff line number Diff line Loading @@ -537,16 +537,16 @@ * Example: * @code * // A cache item with nodes, users, and some custom module data. * $tags = array( * $tags = [ * 'my_custom_tag', * 'node:1', * 'node:3', * 'user:7', * ); * ]; * \Drupal::cache()->set($cid, $data, CacheBackendInterface::CACHE_PERMANENT, $tags); * * // Invalidate all cache items with certain tags. * \Drupal\Core\Cache\Cache::invalidateTags(array('user:1')); * \Drupal\Core\Cache\Cache::invalidateTags(['user:1']); * @endcode * * Drupal is a content management system, so naturally you want changes to your Loading Loading @@ -1712,14 +1712,14 @@ * * public function buildForm(array $form, FormStateInterface $form_state) { * // Create a $form API array. * $form['phone_number'] = array( * $form['phone_number'] = [ * '#type' => 'tel', * '#title' => $this->t('Your phone number'), * ); * $form['save'] = array( * ]; * $form['save'] = [ * '#type' => 'submit', * '#value' => $this->t('Save'), * ); * ]; * return $form; * } * Loading Loading @@ -1753,11 +1753,11 @@ * $form = \Drupal::formBuilder()->getForm('Drupal\my_module\Form\ExampleForm', $extra); * ... * public function buildForm(array $form, FormStateInterface $form_state, $extra = NULL) * $form['phone_number'] = array( * $form['phone_number'] = [ * '#type' => 'tel', * '#title' => $this->t('Your phone number'), * '#value' => $extra, * ); * ]; * return $form; * } * @endcode Loading Loading @@ -2340,14 +2340,14 @@ function hook_validation_constraint_alter(array &$definitions) { * Ajax response. This is done in the text field form array element * in \Drupal\config_translation\FormElement\DateFormat::getFormElement(): * @code * '#ajax' => array( * '#ajax' => [ * 'callback' => 'Drupal\config_translation\FormElement\DateFormat::ajaxSample', * 'event' => 'keyup', * 'progress' => array( * 'progress' => [ * 'type' => 'throbber', * 'message' => NULL, * ), * ), * ], * ], * @endcode * * As you can see from this example, the #ajax property for a form element is Loading Loading @@ -2435,7 +2435,7 @@ function hook_validation_constraint_alter(array &$definitions) { * 'wrapper' method and return HTML markup. This is not the case if you return * commands, but if you would like to show status messages, you can add * @code * array('#type' => 'status_messages') * ['#type' => 'status_messages'] * @endcode * to a render array, use \Drupal::service('renderer')->render() to render it, * and add a command to place the messages in an appropriate location. Loading Loading @@ -2596,9 +2596,9 @@ function hook_validation_constraint_alter(array &$definitions) { * @code * public static function getSubscribedEvents() { * // Subscribe to kernel terminate with priority 100. * $events[KernelEvents::TERMINATE][] = array('onTerminate', 100); * $events[KernelEvents::TERMINATE][] = ['onTerminate', 100]; * // Subscribe to kernel request with default priority of 0. * $events[KernelEvents::REQUEST][] = array('onRequest'); * $events[KernelEvents::REQUEST][] = ['onRequest']; * return $events; * } * @endcode Loading
core/includes/common.inc +14 −14 Original line number Diff line number Diff line Loading @@ -173,14 +173,14 @@ function base_path() { * into a table. The table must have an ID attribute set and it * may be set as follows: * @code * $table = array( * $table = [ * '#type' => 'table', * '#header' => $header, * '#rows' => $rows, * '#attributes' => array( * '#attributes' => [ * 'id' => 'my-module-table', * ), * ); * ], * ]; * return \Drupal::service('renderer')->render($table); * @endcode * Loading @@ -190,17 +190,17 @@ function base_path() { * In a situation where a single weight column is being sorted in the table, the * classes could be added like this (in the theme function): * @code * $form['my_elements'][$delta]['weight']['#attributes']['class'] = array('my-elements-weight'); * $form['my_elements'][$delta]['weight']['#attributes']['class'] = ['my-elements-weight']; * @endcode * * Each row of the table must also have a class of "draggable" in order to * enable the drag handles: * @code * $row = array(...); * $rows[] = array( * $row = [...]; * $rows[] = [ * 'data' => $row, * 'class' => array('draggable'), * ); * 'class' => ['draggable'], * ]; * @endcode * * When tree relationships are present, the two additional classes Loading @@ -210,18 +210,18 @@ function base_path() { * * Calling drupal_attach_tabledrag() would then be written as such: * @code * drupal_attach_tabledrag('my-module-table', array( * drupal_attach_tabledrag('my-module-table', [ * 'action' => 'order', * 'relationship' => 'sibling', * 'group' => 'my-elements-weight', * ); * ]; * @endcode * * In a more complex case where there are several groups in one column (such as * the block regions on the admin/structure/block page), a separate subgroup * class must also be added to differentiate the groups. * @code * $form['my_elements'][$region][$delta]['weight']['#attributes']['class'] = array('my-elements-weight', 'my-elements-weight-' . $region); * $form['my_elements'][$region][$delta]['weight']['#attributes']['class'] = ['my-elements-weight', 'my-elements-weight-' . $region]; * @endcode * * The 'group' option is still 'my-element-weight', and the additional Loading @@ -231,12 +231,12 @@ function base_path() { * * @code * foreach ($regions as $region) { * drupal_attach_tabledrag('my-module-table', array( * drupal_attach_tabledrag('my-module-table', [ * 'action' => 'order', * 'relationship' => 'sibling', * 'group' => 'my-elements-weight', * 'subgroup' => 'my-elements-weight-' . $region, * )); * ]); * } * @endcode * Loading
core/includes/form.inc +13 −13 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ function form_select_options($element, $choices = NULL) { * index is not sufficient, and supporting this would make the * "helper" too complicated and cumbersome to be of any help. * * As usual with functions that can return array() or FALSE, do not * As usual with functions that can return [] or FALSE, do not * forget to use === and !== if needed. * * @param $element Loading Loading @@ -576,15 +576,15 @@ function template_preprocess_form_element_label(&$variables) { * * Example: * @code * $batch = array( * $batch = [ * 'title' => t('Exporting'), * 'operations' => array( * array('my_function_1', array($account->id(), 'story')), * array('my_function_2', array()), * ), * 'operations' => [ * ['my_function_1', [$account->id(), 'story']], * ['my_function_2', []], * ], * 'finished' => 'my_finished_callback', * 'file' => 'path_to_file_containing_my_functions', * ); * ]; * batch_set($batch); * // Only needed if not inside a form _submit handler. * // Setting redirect in batch_process. Loading Loading @@ -638,7 +638,7 @@ function template_preprocess_form_element_label(&$variables) { * } * $limit = 5; * $result = \Drupal::database()->select('example') * ->fields('example', array('id')) * ->fields('example', ['id']) * ->condition('id', $context['sandbox']['current_id'], '>') * ->orderBy('id') * ->range(0, $limit) Loading Loading @@ -671,7 +671,7 @@ function template_preprocess_form_element_label(&$variables) { * \Drupal::messenger()->addMessage($message); * // Providing data for the redirected page is done through the session. * foreach ($results as $result) { * $items[] = t('Loaded node %title.', array('%title' => $result)); * $items[] = t('Loaded node %title.', ['%title' => $result)]; * } * $session = \Drupal::getRequest()->getSession(); * $session->set('my_batch_results', $items); Loading Loading @@ -702,10 +702,10 @@ function template_preprocess_form_element_label(&$variables) { * callback_batch_operation() and an array of parameter. * Example: * @code * array( * array('callback_batch_operation_1', array($arg1)), * array('callback_batch_operation_2', array($arg2_1, $arg2_2)), * ) * [ * ['callback_batch_operation_1', [$arg1)], * ['callback_batch_operation_2', [$arg2_1, $arg2_2]], * ] * @endcode * - title: A safe, translated string to use as the title for the progress * page. Defaults to t('Processing'). Loading
core/includes/install.inc +2 −2 Original line number Diff line number Diff line Loading @@ -255,10 +255,10 @@ function drupal_get_database_types() { * are dumped up to a stdClass object. The object can have value, required * and comment properties. * @code * $settings['settings']['config_sync_directory'] = (object) array( * $settings['settings']['config_sync_directory'] = (object) [ * 'value' => 'config_hash/sync', * 'required' => TRUE, * ); * ]; * @endcode * gets dumped as: * @code Loading
core/includes/theme.inc +22 −22 Original line number Diff line number Diff line Loading @@ -863,16 +863,16 @@ function template_preprocess_image(&$variables) { * - Any HTML attributes, such as "colspan", to apply to the table cell. * Here's an example for $rows: * @code * $rows = array( * $rows = [ * // Simple row * array( * [ * 'Cell 1', 'Cell 2', 'Cell 3' * ), * ], * // Row with attributes on the row and some of its cells. * array( * 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => array('funky') * ), * ); * [ * 'data' => ['Cell 1', ['data' => 'Cell 2', 'colspan' => 2]], 'class' => ['funky'] * ], * ]; * @endcode * - footer: An array of table rows which will be printed within a <tfoot> * tag, in the same format as the rows element (see above). Loading @@ -888,23 +888,23 @@ function template_preprocess_image(&$variables) { * associative array of HTML attributes. * Here's an example for $colgroup: * @code * $colgroup = array( * $colgroup = [ * // <colgroup> with one <col> element. * array( * array( * 'class' => array('funky'), // Attribute for the <col> element. * ), * ), * [ * [ * 'class' => ['funky'], // Attribute for the <col> element. * ], * ], * // <colgroup> with attributes and inner <col> elements. * array( * 'data' => array( * array( * 'class' => array('funky'), // Attribute for the <col> element. * ), * ), * 'class' => array('jazzy'), // Attribute for the <colgroup> element. * ), * ); * [ * 'data' => [ * [ * 'class' => ['funky'], // Attribute for the <col> element. * ], * ], * 'class' => ['jazzy'], // Attribute for the <colgroup> element. * ], * ]; * @endcode * These optional tags are used to group and set properties on columns * within a table. For example, one may easily group three columns and Loading