Commit 52e3eec6 authored by xjm's avatar xjm

Issue #2776975 by joelpittet, dawehner, tim.plunkett, xjm, pfrenssen: March 3,...

Issue #2776975 by joelpittet, dawehner, tim.plunkett, xjm, pfrenssen: March 3, 2017: Convert core to array syntax coding standards for Drupal 8.3.x RC phase
parent 3aba956a

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -116,10 +116,10 @@ function authorize_access_allowed(Request $request) {
drupal_set_message($results['page_message']['message'], $results['page_message']['type']);
}
$content['authorize_report'] = array(
$content['authorize_report'] = [
'#theme' => 'authorize_report',
'#messages' => $results['messages'],
);
];
if (is_array($results['tasks'])) {
$links = $results['tasks'];
......@@ -148,11 +148,11 @@ function authorize_access_allowed(Request $request) {
];
}
$content['next_steps'] = array(
$content['next_steps'] = [
'#theme' => 'item_list',
'#items' => $links,
'#title' => t('Next steps'),
);
];
}
// If a batch is running, let it run.
elseif ($request->query->has('batch')) {
......@@ -189,9 +189,9 @@ function authorize_access_allowed(Request $request) {
}
$bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
$response = $bare_html_page_renderer->renderBarePage($content, $page_title, 'maintenance_page', array(
$response = $bare_html_page_renderer->renderBarePage($content, $page_title, 'maintenance_page', [
'#show_messages' => $show_messages,
));
]);
if (!$is_allowed) {
$response->setStatusCode(403);
}
......
......@@ -2103,39 +2103,39 @@ function hook_mail_alter(&$message) {
function hook_mail($key, &$message, $params) {
$account = $params['account'];
$context = $params['context'];
$variables = array(
$variables = [
'%site_name' => \Drupal::config('system.site')->get('name'),
'%username' => $account->getDisplayName(),
);
];
if ($context['hook'] == 'taxonomy') {
$entity = $params['entity'];
$vocabulary = Vocabulary::load($entity->id());
$variables += array(
$variables += [
'%term_name' => $entity->name,
'%term_description' => $entity->description,
'%term_id' => $entity->id(),
'%vocabulary_name' => $vocabulary->label(),
'%vocabulary_description' => $vocabulary->getDescription(),
'%vocabulary_id' => $vocabulary->id(),
);
];
}
// Node-based variable translation is only available if we have a node.
if (isset($params['node'])) {
/** @var \Drupal\node\NodeInterface $node */
$node = $params['node'];
$variables += array(
$variables += [
'%uid' => $node->getOwnerId(),
'%url' => $node->url('canonical', array('absolute' => TRUE)),
'%url' => $node->url('canonical', ['absolute' => TRUE]),
'%node_type' => node_get_type_label($node),
'%title' => $node->getTitle(),
'%teaser' => $node->teaser,
'%body' => $node->body,
);
];
}
$subject = strtr($context['subject'], $variables);
$body = strtr($context['message'], $variables);
$message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
$message['subject'] .= str_replace(["\r", "\n"], '', $subject);
$message['body'][] = MailFormatHelper::htmlToText($body);
}
......
......@@ -50,7 +50,7 @@ function _batch_page(Request $request) {
// Register database update for the end of processing.
drupal_register_shutdown_function('_batch_shutdown');
$build = array();
$build = [];
// Add batch-specific libraries.
foreach ($batch['sets'] as $batch_set) {
......@@ -94,7 +94,7 @@ function _batch_do() {
// Perform actual processing.
list($percentage, $message, $label) = _batch_process();
return new JsonResponse(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message, 'label' => $label));
return new JsonResponse(['status' => TRUE, 'percentage' => $percentage, 'message' => $message, 'label' => $label]);
}
/**
......@@ -130,9 +130,9 @@ function _batch_progress_page() {
// it. While this causes invalid HTML, the same would be true if we didn't,
// as content is not allowed to appear after </html> anyway.
$bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
$response = $bare_html_page_renderer->renderBarePage(['#markup' => $fallback], $current_set['title'], 'maintenance_page', array(
$response = $bare_html_page_renderer->renderBarePage(['#markup' => $fallback], $current_set['title'], 'maintenance_page', [
'#show_messages' => FALSE,
));
]);
// Just use the content of the response.
$fallback = $response->getContent();
......@@ -159,26 +159,26 @@ function _batch_progress_page() {
$url = $batch['url']->toString(TRUE)->getGeneratedUrl();
$build = array(
$build = [
'#theme' => 'progress_bar',
'#percent' => $percentage,
'#message' => array('#markup' => $message),
'#message' => ['#markup' => $message],
'#label' => $label,
'#attached' => array(
'html_head' => array(
array(
array(
'#attached' => [
'html_head' => [
[
[
// Redirect through a 'Refresh' meta tag if JavaScript is disabled.
'#tag' => 'meta',
'#noscript' => TRUE,
'#attributes' => array(
'#attributes' => [
'http-equiv' => 'Refresh',
'content' => '0; URL=' . $url,
),
),
],
],
'batch_progress_meta_refresh',
),
),
],
],
// Adds JavaScript code and settings for clients where JavaScript is enabled.
'drupalSettings' => [
'batch' => [
......@@ -187,11 +187,11 @@ function _batch_progress_page() {
'uri' => $url,
],
],
'library' => array(
'library' => [
'core/drupal.batch',
),
),
);
],
],
];
return $build;
}
......@@ -243,13 +243,13 @@ function _batch_process() {
list($callback, $args) = $item->data;
// Build the 'context' array and execute the function call.
$batch_context = array(
$batch_context = [
'sandbox' => &$current_set['sandbox'],
'results' => &$current_set['results'],
'finished' => &$finished,
'message' => &$task_message,
);
call_user_func_array($callback, array_merge($args, array(&$batch_context)));
];
call_user_func_array($callback, array_merge($args, [&$batch_context]));
if ($finished >= 1) {
// Make sure this step is not counted twice when computing $current.
......@@ -257,7 +257,7 @@ function _batch_process() {
// Remove the processed operation and clear the sandbox.
$queue->deleteItem($item);
$current_set['count']--;
$current_set['sandbox'] = array();
$current_set['sandbox'] = [];
}
}
......@@ -312,7 +312,7 @@ function _batch_process() {
$current = $total - $remaining + $finished;
$percentage = _batch_api_percentage($total, $current);
$elapsed = isset($current_set['elapsed']) ? $current_set['elapsed'] : 0;
$values = array(
$values = [
'@remaining' => $remaining,
'@total' => $total,
'@current' => floor($current),
......@@ -320,13 +320,13 @@ function _batch_process() {
'@elapsed' => \Drupal::service('date.formatter')->formatInterval($elapsed / 1000),
// If possible, estimate remaining processing time.
'@estimate' => ($current > 0) ? \Drupal::service('date.formatter')->formatInterval(($elapsed * ($total - $current) / $current) / 1000) : '-',
);
];
$message = strtr($progress_message, $values);
if (!empty($task_message)) {
$label = $task_message;
}
return array($percentage, $message, $label);
return [$percentage, $message, $label];
}
else {
// If we are not in progressive mode, the entire batch has been processed.
......@@ -385,7 +385,7 @@ function _batch_next_set() {
// We use our stored copies of $form and $form_state to account for
// possible alterations by previous form submit handlers.
$complete_form = &$batch['form_state']->getCompleteForm();
call_user_func_array($callback, array(&$complete_form, &$batch['form_state']));
call_user_func_array($callback, [&$complete_form, &$batch['form_state']]);
}
return TRUE;
}
......@@ -411,7 +411,7 @@ function _batch_finished() {
if (is_callable($batch_set['finished'])) {
$queue = _batch_queue($batch_set);
$operations = $queue->getAllItems();
$batch_set_result = call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000)));
$batch_set_result = call_user_func_array($batch_set['finished'], [$batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000)]);
// If a batch 'finished' callback requested a redirect after the batch
// is complete, save that for later use. If more than one batch set
// returned a redirect, the last one is used.
......
......@@ -197,7 +197,7 @@ function config_get_config_directory($type) {
function drupal_get_filename($type, $name, $filename = NULL) {