Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -80,6 +80,13 @@ class ActiveTheme {
|
|||
*/
|
||||
protected $regions;
|
||||
|
||||
/**
|
||||
* The libraries or library assets overridden by the theme.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $librariesOverride;
|
||||
|
||||
/**
|
||||
* Constructs an ActiveTheme object.
|
||||
*
|
||||
|
@ -96,6 +103,8 @@ class ActiveTheme {
|
|||
'extension' => 'html.twig',
|
||||
'base_themes' => [],
|
||||
'regions' => [],
|
||||
'libraries_override' => [],
|
||||
'libraries_extend' => [],
|
||||
];
|
||||
|
||||
$this->name = $values['name'];
|
||||
|
@ -107,6 +116,8 @@ class ActiveTheme {
|
|||
$this->extension = $values['extension'];
|
||||
$this->baseThemes = $values['base_themes'];
|
||||
$this->regions = $values['regions'];
|
||||
$this->librariesOverride = $values['libraries_override'];
|
||||
$this->librariesExtend = $values['libraries_extend'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,6 +180,8 @@ class ActiveTheme {
|
|||
* Returns the removed stylesheets by the theme.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
|
||||
*/
|
||||
public function getStyleSheetsRemove() {
|
||||
return $this->styleSheetsRemove;
|
||||
|
@ -198,4 +211,24 @@ class ActiveTheme {
|
|||
return array_keys($this->regions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the libraries or library assets overridden by the active theme.
|
||||
*
|
||||
* @return array
|
||||
* The list of libraries overrides.
|
||||
*/
|
||||
public function getLibrariesOverride() {
|
||||
return $this->librariesOverride;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the libraries extended by the active theme.
|
||||
*
|
||||
* @return array
|
||||
* The list of libraries-extend definitions.
|
||||
*/
|
||||
public function getLibrariesExtend() {
|
||||
return $this->librariesExtend;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -472,12 +472,14 @@ class Registry implements DestructableInterface {
|
|||
// A template file is the default implementation for a theme hook, but
|
||||
// if the theme hook specifies a function callback instead, check to
|
||||
// ensure the function actually exists.
|
||||
if (isset($info['function']) && !function_exists($info['function'])) {
|
||||
throw new \BadFunctionCallException(sprintf(
|
||||
'Theme hook "%s" refers to a theme function callback that does not exist: "%s"',
|
||||
$hook,
|
||||
$info['function']
|
||||
));
|
||||
if (isset($info['function'])) {
|
||||
if (!function_exists($info['function'])) {
|
||||
throw new \BadFunctionCallException(sprintf(
|
||||
'Theme hook "%s" refers to a theme function callback that does not exist: "%s"',
|
||||
$hook,
|
||||
$info['function']
|
||||
));
|
||||
}
|
||||
}
|
||||
// Provide a default naming convention for 'template' based on the
|
||||
// hook used. If the template does not exist, the theme engine used
|
||||
|
|
|
@ -161,27 +161,56 @@ class ThemeInitialization implements ThemeInitializationInterface {
|
|||
$values['path'] = $theme_path;
|
||||
$values['name'] = $theme->getName();
|
||||
|
||||
// Prepare stylesheets from this theme as well as all ancestor themes.
|
||||
// We work it this way so that we can have child themes remove CSS files
|
||||
// easily from parent.
|
||||
$values['stylesheets_remove'] = array();
|
||||
// @todo Remove in Drupal 9.0.x.
|
||||
$values['stylesheets_remove'] = $this->prepareStylesheetsRemove($theme, $base_themes);
|
||||
|
||||
// Grab stylesheets from base theme.
|
||||
// Prepare libraries overrides from this theme and ancestor themes. This
|
||||
// allows child themes to easily remove CSS files from base themes and
|
||||
// modules.
|
||||
$values['libraries_override'] = [];
|
||||
|
||||
// Get libraries overrides declared by base themes.
|
||||
foreach ($base_themes as $base) {
|
||||
$base_theme_path = $base->getPath();
|
||||
if (!empty($base->info['stylesheets-remove'])) {
|
||||
foreach ($base->info['stylesheets-remove'] as $css_file) {
|
||||
$css_file = $this->resolveStyleSheetPlaceholders($css_file);
|
||||
$values['stylesheets_remove'][$css_file] = $css_file;
|
||||
if (!empty($base->info['libraries-override'])) {
|
||||
foreach ($base->info['libraries-override'] as $library => $override) {
|
||||
$values['libraries_override'][$base->getPath()][$library] = $override;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add stylesheets used by this theme.
|
||||
if (!empty($theme->info['stylesheets-remove'])) {
|
||||
foreach ($theme->info['stylesheets-remove'] as $css_file) {
|
||||
$css_file = $this->resolveStyleSheetPlaceholders($css_file);
|
||||
$values['stylesheets_remove'][$css_file] = $css_file;
|
||||
// Add libraries overrides declared by this theme.
|
||||
if (!empty($theme->info['libraries-override'])) {
|
||||
foreach ($theme->info['libraries-override'] as $library => $override) {
|
||||
$values['libraries_override'][$theme->getPath()][$library] = $override;
|
||||
}
|
||||
}
|
||||
|
||||
// Get libraries extensions declared by base themes.
|
||||
foreach ($base_themes as $base) {
|
||||
if (!empty($base->info['libraries-extend'])) {
|
||||
foreach ($base->info['libraries-extend'] as $library => $extend) {
|
||||
if (isset($values['libraries_extend'][$library])) {
|
||||
// Merge if libraries-extend has already been defined for this
|
||||
// library.
|
||||
$values['libraries_extend'][$library] = array_merge($values['libraries_extend'][$library], $extend);
|
||||
}
|
||||
else {
|
||||
$values['libraries_extend'][$library] = $extend;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add libraries extensions declared by this theme.
|
||||
if (!empty($theme->info['libraries-extend'])) {
|
||||
foreach ($theme->info['libraries-extend'] as $library => $extend) {
|
||||
if (isset($values['libraries_extend'][$library])) {
|
||||
// Merge if libraries-extend has already been defined for this
|
||||
// library.
|
||||
$values['libraries_extend'][$library] = array_merge($values['libraries_extend'][$library], $extend);
|
||||
}
|
||||
else {
|
||||
$values['libraries_extend'][$library] = $extend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,6 +270,8 @@ class ThemeInitialization implements ThemeInitializationInterface {
|
|||
*
|
||||
* @return string
|
||||
* CSS file where placeholders are replaced.
|
||||
*
|
||||
* @todo Remove in Drupal 9.0.x.
|
||||
*/
|
||||
protected function resolveStyleSheetPlaceholders($css_file) {
|
||||
$token_candidate = explode('/', $css_file)[0];
|
||||
|
@ -256,4 +287,44 @@ class ThemeInitialization implements ThemeInitializationInterface {
|
|||
return str_replace($token_candidate, $extensions[$token]->getPath(), $css_file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares stylesheets-remove specified in the *.info.yml file.
|
||||
*
|
||||
* @param \Drupal\Core\Extension\Extension $theme
|
||||
* The theme extension object.
|
||||
* @param \Drupal\Core\Extension\Extension[] $base_themes
|
||||
* An array of base themes.
|
||||
*
|
||||
* @return string[]
|
||||
* The list of stylesheets-remove specified in the *.info.yml file.
|
||||
*
|
||||
* @todo Remove in Drupal 9.0.x.
|
||||
*/
|
||||
protected function prepareStylesheetsRemove(Extension $theme, $base_themes) {
|
||||
// Prepare stylesheets from this theme as well as all ancestor themes.
|
||||
// We work it this way so that we can have child themes remove CSS files
|
||||
// easily from parent.
|
||||
$stylesheets_remove = array();
|
||||
// Grab stylesheets from base theme.
|
||||
foreach ($base_themes as $base) {
|
||||
$base_theme_path = $base->getPath();
|
||||
if (!empty($base->info['stylesheets-remove'])) {
|
||||
foreach ($base->info['stylesheets-remove'] as $css_file) {
|
||||
$css_file = $this->resolveStyleSheetPlaceholders($css_file);
|
||||
$stylesheets_remove[$css_file] = $css_file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add stylesheets used by this theme.
|
||||
if (!empty($theme->info['stylesheets-remove'])) {
|
||||
foreach ($theme->info['stylesheets-remove'] as $css_file) {
|
||||
$css_file = $this->resolveStyleSheetPlaceholders($css_file);
|
||||
$stylesheets_remove[$css_file] = $css_file;
|
||||
}
|
||||
}
|
||||
return $stylesheets_remove;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
namespace Drupal\Core\Theme;
|
||||
|
||||
use Drupal\Component\Utility\SafeStringInterface;
|
||||
use Drupal\Core\Render\SafeString;
|
||||
use Drupal\Component\Render\MarkupInterface;
|
||||
use Drupal\Core\Render\Markup;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\Core\Routing\StackedRouteMatchInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
@ -319,7 +319,7 @@ class ThemeManager implements ThemeManagerInterface {
|
|||
// Theme functions do not render via the theme engine, so the output is
|
||||
// not autoescaped. However, we can only presume that the theme function
|
||||
// has been written correctly and that the markup is safe.
|
||||
$output = SafeString::create($info['function']($variables));
|
||||
$output = Markup::create($info['function']($variables));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -389,7 +389,7 @@ class ThemeManager implements ThemeManagerInterface {
|
|||
$output = $render_function($template_file, $variables);
|
||||
}
|
||||
|
||||
return ($output instanceof SafeStringInterface) ? $output : (string) $output;
|
||||
return ($output instanceof MarkupInterface) ? $output : (string) $output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,8 +26,8 @@ interface ThemeManagerInterface {
|
|||
* @param array $variables
|
||||
* An associative array of theme variables.
|
||||
*
|
||||
* @return string|\Drupal\Component\Utility\SafeStringInterface
|
||||
* The rendered output, or a SafeString object.
|
||||
* @return string|\Drupal\Component\Render\MarkupInterface
|
||||
* The rendered output, or a Markup object.
|
||||
*/
|
||||
public function render($hook, array $variables);
|
||||
|
||||
|
|
Reference in a new issue