Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -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;
@ -207,7 +207,7 @@ function template_preprocess_fieldset(&$variables) {
$variables['legend']['attributes'] = new Attribute();
// Add 'visually-hidden' class to legend span.
if ($variables['title_display'] == 'invisible') {
$variables['legend_span']['attributes'] = new Attribute(array('class' => 'visually-hidden'));
$variables['legend_span']['attributes'] = new Attribute(['class' => ['visually-hidden']]);
}
else {
$variables['legend_span']['attributes'] = new Attribute();
@ -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,10 +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(),
);
'#wrapper_attributes' => [],
'#label_attributes' => [],
];
$variables['attributes'] = $element['#wrapper_attributes'];
// Add element #id for #type 'item'.
@ -477,8 +478,9 @@ 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'];
}
@ -566,7 +568,7 @@ function template_preprocess_form_element_label(&$variables) {
* Note: if the batch 'title', 'init_message', 'progress_message', or
* 'error_message' could contain any user input, it is the responsibility of
* the code calling batch_set() to sanitize them first with a function like
* \Drupal\Component\Utility\SafeMarkup::checkPlain() or
* \Drupal\Component\Utility\Html::escape() or
* \Drupal\Component\Utility\Xss::filter(). Furthermore, if the batch operation
* returns any user input in the 'results' or 'message' keys of $context, it
* must also sanitize them first.
@ -594,8 +596,8 @@ function template_preprocess_form_element_label(&$variables) {
* $nodes = \Drupal::entityTypeManager()->getStorage('node')
* ->loadByProperties(['uid' => $uid, 'type' => $type]);
* $node = reset($nodes);
* $context['results'][] = $node->id() . ' : ' . SafeMarkup::checkPlain($node->label());
* $context['message'] = SafeMarkup::checkPlain($node->label());
* $context['results'][] = $node->id() . ' : ' . Html::escape($node->label());
* $context['message'] = Html::escape($node->label());
* }
*
* // A more advanced example is a multi-step operation that loads all rows,
@ -614,10 +616,10 @@ function template_preprocess_form_element_label(&$variables) {
* ->range(0, $limit)
* ->execute();
* foreach ($result as $row) {
* $context['results'][] = $row->id . ' : ' . SafeMarkup::checkPlain($row->title);
* $context['results'][] = $row->id . ' : ' . Html::escape($row->title);
* $context['sandbox']['progress']++;
* $context['sandbox']['current_id'] = $row->id;
* $context['message'] = SafeMarkup::checkPlain($row->title);
* $context['message'] = Html::escape($row->title);
* }
* if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
* $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
@ -691,7 +693,7 @@ function template_preprocess_form_element_label(&$variables) {
* 'finished' functions, for instance if they don't reside in the main
* .module file. The path should be relative to base_path(), and thus should
* be built using drupal_get_path().
* - css: Array of paths to CSS files to be used on the progress page.
* - library: An array of batch-specific CSS and JS libraries.
* - url_options: options passed to the \Drupal\Core\Url object when
* constructing redirect URLs for the batch.
* - progressive: A Boolean that indicates whether or not the batch needs to
@ -715,27 +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.'),
'css' => array(),
);
];
$batch_set = $init + $batch_definition + $defaults;
// Tweak init_message to avoid the bottom of the page flickering down after
@ -759,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);
}
}
@ -781,6 +782,9 @@ function batch_set($batch_definition) {
* \Symfony\Component\HttpFoundation\RedirectResponse, which will be used
* automatically by the standard batch processing pipeline (and which takes
* precedence over this parameter).
* User will be redirected to the page that started the batch if this argument
* is omitted and no redirect response was returned by the 'finished'
* callback. Any query arguments will be automatically persisted.
* @param \Drupal\Core\Url $url
* (optional - should only be used for separate scripts like update.php)
* URL of the batch processing page.
@ -796,15 +800,15 @@ 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'),
'source_url' => Url::fromRouteMatch(\Drupal::routeMatch()),
'source_url' => Url::fromRouteMatch(\Drupal::routeMatch())->mergeOptions(['query' => \Drupal::request()->query->all()]),
'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
@ -835,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.
@ -882,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;
}
@ -903,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();
@ -933,7 +937,7 @@ function _batch_queue($batch_set) {
static $queues;
if (!isset($queues)) {
$queues = array();
$queues = [];
}
if (isset($batch_set['queue'])) {