Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -20,6 +20,7 @@ use Drupal\Core\Template\Attribute;
use Drupal\Core\Theme\ThemeSettings;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\SafeString;
/**
* @defgroup content_flags Content markers
@ -115,7 +116,7 @@ function drupal_theme_rebuild() {
*/
function drupal_find_theme_functions($cache, $prefixes) {
$implementations = [];
$grouped_functions = drupal_group_functions_by_prefix();
$grouped_functions = \Drupal::service('theme.registry')->getPrefixGroupedUserFunctions();
foreach ($cache as $hook => $info) {
foreach ($prefixes as $prefix) {
@ -161,25 +162,6 @@ function drupal_find_theme_functions($cache, $prefixes) {
return $implementations;
}
/**
* Group all user functions by word before first underscore.
*
* @return array
* Functions grouped by the first prefix.
*/
function drupal_group_functions_by_prefix() {
$functions = get_defined_functions();
$grouped_functions = [];
// Splitting user defined functions into groups by the first prefix.
foreach ($functions['user'] as $function) {
list($first_prefix,) = explode('_', $function, 2);
$grouped_functions[$first_prefix][] = $function;
}
return $grouped_functions;
}
/**
* Allows themes and/or theme engines to easily discover overridden templates.
*
@ -507,8 +489,8 @@ function template_preprocess_datetime_wrapper(&$variables) {
}
$variables['required'] = FALSE;
// For required datetime fields a 'form-required' class is appended to the
// label attributes.
// For required datetime fields 'form-required' & 'js-form-required' classes
// are appended to the label attributes.
if (!empty($element['#required'])) {
$variables['required'] = TRUE;
}
@ -594,7 +576,6 @@ function template_preprocess_links(&$variables) {
);
// Convert the attributes array into an Attribute object.
$heading['attributes'] = new Attribute($heading['attributes']);
$heading['text'] = SafeMarkup::checkPlain($heading['text']);
}
$variables['links'] = array();
@ -1158,9 +1139,6 @@ function template_preprocess_maintenance_task_list(&$variables) {
* details.
*/
function template_preprocess(&$variables, $hook, $info) {
// Tell all templates where they are located.
$variables['directory'] = \Drupal::theme()->getActiveTheme()->getPath();
// Merge in variables that don't depend on hook and don't change during a
// single page request.
// Use the advanced drupal_static() pattern, since this is called very often.
@ -1203,6 +1181,9 @@ function _template_preprocess_default_variables() {
// Give modules a chance to alter the default template variables.
\Drupal::moduleHandler()->alter('template_preprocess_default_variables', $variables);
// Tell all templates where they are located.
$variables['directory'] = \Drupal::theme()->getActiveTheme()->getPath();
return $variables;
}
@ -1255,9 +1236,14 @@ function template_preprocess_html(&$variables) {
$site_config = \Drupal::config('system.site');
// Construct page title.
if (isset($variables['page']['#title']) && is_array($variables['page']['#title'])) {
// Do an early render if the title is a render array.
$variables['page']['#title'] = (string) \Drupal::service('renderer')->render($variables['page']['#title']);
}
if (!empty($variables['page']['#title'])) {
$head_title = array(
'title' => trim(strip_tags($variables['page']['#title'])),
// Marking the title as safe since it has had the tags stripped.
'title' => SafeString::create(trim(strip_tags($variables['page']['#title']))),
'name' => $site_config->get('name'),
);
}
@ -1295,7 +1281,7 @@ function template_preprocess_html(&$variables) {
'@token' => $token,
]);
$variables[$type]['#markup'] = $placeholder;
$variables[$type]['#attached']['html_response_placeholders'][$type] = $placeholder;
$variables[$type]['#attached']['html_response_attachment_placeholders'][$type] = $placeholder;
}
}
@ -1325,7 +1311,7 @@ function template_preprocess_page(&$variables) {
$variables['front_page'] = \Drupal::url('<front>');
$variables['language'] = $language_interface;
$variables['logo'] = theme_get_setting('logo.url');
$variables['site_name'] = (theme_get_setting('features.name') ? SafeMarkup::checkPlain($site_config->get('name')) : '');
$variables['site_name'] = (theme_get_setting('features.name') ? $site_config->get('name') : '');
$variables['site_slogan']['#markup'] = (theme_get_setting('features.slogan') ? $site_config->get('slogan') : '');
// An exception might be thrown.
@ -1338,14 +1324,6 @@ function template_preprocess_page(&$variables) {
$variables['is_front'] = FALSE;
$variables['db_is_active'] = FALSE;
}
if (!defined('MAINTENANCE_MODE')) {
$variables['action_links'] = menu_get_local_actions();
$variables['tabs'] = menu_local_tabs();
}
else {
$variables['action_links'] = array();
$variables['tabs'] = array();
}
if ($node = \Drupal::routeMatch()->getParameter('node')) {
$variables['node'] = $node;
@ -1490,8 +1468,6 @@ function template_preprocess_region(&$variables) {
* - element: A render element representing the field.
* - attributes: A string containing the attributes for the wrapping div.
* - title_attributes: A string containing the attributes for the title.
* - content_attributes: A string containing the attributes for the content's
* div.
*/
function template_preprocess_field(&$variables, $hook) {
$element = $variables['element'];
@ -1506,13 +1482,24 @@ function template_preprocess_field(&$variables, $hook) {
// Always set the field label - allow themes to decide whether to display it.
// In addition the label should be rendered but hidden to support screen
// readers.
$variables['label'] = SafeMarkup::checkPlain($element['#title']);
$variables['label'] = $element['#title'];
// @todo Check for is_object() required due to pseudo field used in
// quickedit_test_entity_view_alter(). Remove this check after this is fixed
// in https://www.drupal.org/node/2550225.
$variables['multiple'] = is_object($element['#items']) ? $element['#items']->getFieldDefinition()->getFieldStorageDefinition()->isMultiple() : FALSE;
static $default_attributes;
if (!isset($default_attributes)) {
$default_attributes = new Attribute;
}
// Merge attributes when a single-value field has a hidden label.
if ($element['#label_display'] == 'hidden' && !$variables['multiple'] && is_object($element['#items'][0])) {
$variables['attributes'] = NestedArray::mergeDeep($variables['attributes'], (array) $element['#items'][0]->_attributes);
}
// We want other preprocess functions and the theme implementation to have
// fast access to the field item render arrays. The item render array keys
// (deltas) should always be numerically indexed starting from 0, and looping
@ -1556,6 +1543,7 @@ function template_preprocess_field_multiple_value_form(&$variables) {
$order_class = $element['#field_name'] . '-delta-order';
$header_attributes = new Attribute(array('class' => array('label')));
if (!empty($element['#required'])) {
$header_attributes['class'][] = 'js-form-required';
$header_attributes['class'][] = 'form-required';
}
$header = array(
@ -1746,17 +1734,10 @@ function drupal_common_theme() {
'maintenance_task_list' => array(
'variables' => array('items' => NULL, 'active' => NULL, 'variant' => NULL),
),
'authorize_message' => array(
'variables' => array('message' => NULL, 'success' => TRUE),
'function' => 'theme_authorize_message',
'path' => 'core/includes',
'file' => 'theme.maintenance.inc',
),
'authorize_report' => array(
'variables' => array('messages' => array()),
'function' => 'theme_authorize_report',
'path' => 'core/includes',
'file' => 'theme.maintenance.inc',
'variables' => ['messages' => [], 'attributes' => []],
'includes' => ['core/includes/theme.maintenance.inc'],
'template' => 'authorize-report',
),
// From pager.inc.
'pager' => array(