Issue #3158289 by alexpott, barboza: Deprecate hook_init for theme engines
(cherry picked from commit 3ab6129942
)
merge-requests/1400/head
parent
b4a6273ebd
commit
9e3837a258
|
@ -140,11 +140,18 @@ class ThemeInitialization implements ThemeInitializationInterface {
|
||||||
include_once $this->root . '/' . $active_theme->getOwner();
|
include_once $this->root . '/' . $active_theme->getOwner();
|
||||||
|
|
||||||
if (function_exists($theme_engine . '_init')) {
|
if (function_exists($theme_engine . '_init')) {
|
||||||
|
@trigger_error('THEME_ENGINE_init() is deprecated in drupal:9.3.0 and removed in drupal:10.0.0. There is no replacement. See https://www.drupal.org/node/3246978', E_USER_DEPRECATED);
|
||||||
foreach ($active_theme->getBaseThemeExtensions() as $base) {
|
foreach ($active_theme->getBaseThemeExtensions() as $base) {
|
||||||
call_user_func($theme_engine . '_init', $base);
|
call_user_func($theme_engine . '_init', $base);
|
||||||
}
|
}
|
||||||
call_user_func($theme_engine . '_init', $active_theme->getExtension());
|
call_user_func($theme_engine . '_init', $active_theme->getExtension());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
foreach ($active_theme->getBaseThemeExtensions() as $base) {
|
||||||
|
$base->load();
|
||||||
|
}
|
||||||
|
$active_theme->getExtension()->load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// include non-engine theme files
|
// include non-engine theme files
|
||||||
|
|
|
@ -30,8 +30,15 @@ class EngineNyanCatTest extends BrowserTestBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures a theme's template is overridable based on the 'template' filename.
|
* Ensures a theme's template is overridable based on the 'template' filename.
|
||||||
|
*
|
||||||
|
* @group legacy
|
||||||
|
*
|
||||||
|
* @todo https://www.drupal.org/project/drupal/issues/3246981 Remove
|
||||||
|
* nyan_cat_init() and the legacy group and expected deprecation from this
|
||||||
|
* test.
|
||||||
*/
|
*/
|
||||||
public function testTemplateOverride() {
|
public function testTemplateOverride() {
|
||||||
|
$this->expectDeprecation('THEME_ENGINE_init() is deprecated in drupal:9.3.0 and removed in drupal:10.0.0. There is no replacement. See https://www.drupal.org/node/3246978');
|
||||||
$this->config('system.theme')
|
$this->config('system.theme')
|
||||||
->set('default', 'test_theme_nyan_cat_engine')
|
->set('default', 'test_theme_nyan_cat_engine')
|
||||||
->save();
|
->save();
|
||||||
|
|
|
@ -26,16 +26,6 @@ function twig_extension() {
|
||||||
return '.html.twig';
|
return '.html.twig';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Includes .theme file from themes.
|
|
||||||
*
|
|
||||||
* @param \Drupal\Core\Extension\Extension $theme
|
|
||||||
* The theme extension object.
|
|
||||||
*/
|
|
||||||
function twig_init(Extension $theme) {
|
|
||||||
$theme->load();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_render_template().
|
* Implements hook_render_template().
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue