diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 6fc242b..e89cb8f 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -268,6 +268,10 @@ function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callb } } + // Always include Twig so that PHPTemplate themes do not have to convert all + // core and contrib templates in order to use the PHPTemplate engine. + include_once DRUPAL_ROOT . '/core/themes/engines/twig/twig.engine'; + if (isset($registry_callback)) { _theme_registry_callback($registry_callback, array($theme, $base_theme, $theme_engine)); } @@ -1086,10 +1090,8 @@ function theme($hook, $variables = array()) { } } else { - // Include Twig, the default theme engine. - include_once DRUPAL_ROOT . '/core/themes/engines/twig/twig.engine'; $render_function = 'twig_render_template'; - $extension = twig_extension(); + $extension = '.html.twig'; // The theme engine may use a different extension and a different renderer. global $theme_engine; diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php index 0a1ab10..135a435 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php @@ -31,7 +31,7 @@ public static function getInfo() { function setUp() { parent::setUp(); - theme_enable(array('test_theme_twig')); + theme_enable(array('test_theme')); } /** @@ -39,7 +39,7 @@ function setUp() { */ function testTemplateOverride() { config('system.theme') - ->set('default', 'test_theme_twig') + ->set('default', 'test_theme') ->save(); $this->drupalGet('theme-test/template-test'); $this->assertText('Success: Template overridden.', t('Template overridden by defined \'template\' filename.')); @@ -50,7 +50,7 @@ function testTemplateOverride() { */ function testTwigVariableDataTypes() { config('system.theme') - ->set('default', 'test_theme_twig') + ->set('default', 'test_theme') ->save(); $this->drupalGet('twig-theme-test/php-variables'); foreach (_test_theme_twig_php_values() as $type => $value) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php index 0bcd1a6..38e183b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php @@ -34,8 +34,8 @@ public static function getInfo() { */ function testTwigDebugMarkup() { $extension = twig_extension(); - theme_enable(array('test_theme_twig')); - config('system.theme')->set('default', 'test_theme_twig')->save(); + theme_enable(array('test_theme')); + config('system.theme')->set('default', 'test_theme')->save(); // Enable debug, rebuild the service container, and clear all caches. $this->settingsSet('twig_debug', TRUE); $this->rebuildContainer(); @@ -47,7 +47,7 @@ function testTwigDebugMarkup() { _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module)); } // Create array of Twig templates. - $templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme_twig')); + $templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme')); $templates += drupal_find_theme_templates($cache, $extension, drupal_get_path('module', 'node')); // Create a node and test different features of the debug markup. diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php index 2e84924..f50f110 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php @@ -77,9 +77,9 @@ function testTwigDebugOverride() { */ function testTwigCacheOverride() { $extension = twig_extension(); - theme_enable(array('test_theme_twig')); + theme_enable(array('test_theme')); config('system.theme') - ->set('default', 'test_theme_twig') + ->set('default', 'test_theme') ->save(); $cache = array(); @@ -89,7 +89,7 @@ function testTwigCacheOverride() { } // Load array of Twig templates. - $templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme_twig')); + $templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme')); // Get the template filename and the cache filename for // theme_test.template_test.html.twig. diff --git a/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.html.twig b/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.html.twig new file mode 100644 index 0000000..cde8faa --- /dev/null +++ b/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.html.twig @@ -0,0 +1,2 @@ + +Fail: Template not overridden. diff --git a/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.tpl.php b/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.tpl.php deleted file mode 100644 index cde8faa..0000000 --- a/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.tpl.php +++ /dev/null @@ -1,2 +0,0 @@ - -Fail: Template not overridden. diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index 137fdfc..e72334c 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -27,7 +27,7 @@ function theme_test_system_theme_info() { $themes['test_theme'] = drupal_get_path('module', 'system') . '/tests/themes/test_theme/test_theme.info.yml'; $themes['test_basetheme'] = drupal_get_path('module', 'system') . '/tests/themes/test_basetheme/test_basetheme.info.yml'; $themes['test_subtheme'] = drupal_get_path('module', 'system') . '/tests/themes/test_subtheme/test_subtheme.info.yml'; - $themes['test_theme_twig'] = drupal_get_path('module', 'system') . '/tests/themes/test_theme_twig/test_theme_twig.info.yml'; + $themes['test_theme_phptemplate'] = drupal_get_path('module', 'system') . '/tests/themes/test_theme_phptemplate/test_theme_phptemplate.info.yml'; return $themes; } diff --git a/core/modules/system/tests/themes/test_theme/node--1.html.twig b/core/modules/system/tests/themes/test_theme/node--1.html.twig new file mode 100644 index 0000000..046c02e --- /dev/null +++ b/core/modules/system/tests/themes/test_theme/node--1.html.twig @@ -0,0 +1,4 @@ +{# + // node--1.html.twig - Dummy file for finding the template +#} +Node Content Dummy diff --git a/core/modules/system/tests/themes/test_theme/node--1.tpl.php b/core/modules/system/tests/themes/test_theme/node--1.tpl.php deleted file mode 100644 index 81974ce..0000000 --- a/core/modules/system/tests/themes/test_theme/node--1.tpl.php +++ /dev/null @@ -1,4 +0,0 @@ - -Node Content Dummy diff --git a/core/modules/system/tests/themes/test_theme/test_theme.theme b/core/modules/system/tests/themes/test_theme/test_theme.theme index 8275818..62b5abf 100644 --- a/core/modules/system/tests/themes/test_theme/test_theme.theme +++ b/core/modules/system/tests/themes/test_theme/test_theme.theme @@ -1,6 +1,18 @@ -Success: Template overridden. diff --git a/core/modules/system/tests/themes/test_theme_phptemplate/node--1.tpl.php b/core/modules/system/tests/themes/test_theme_phptemplate/node--1.tpl.php new file mode 100644 index 0000000..81974ce --- /dev/null +++ b/core/modules/system/tests/themes/test_theme_phptemplate/node--1.tpl.php @@ -0,0 +1,4 @@ + +Node Content Dummy diff --git a/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.info.yml b/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.info.yml new file mode 100644 index 0000000..fa975b9 --- /dev/null +++ b/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.info.yml @@ -0,0 +1,6 @@ +name: 'Test theme PHPTemplate' +type: theme +description: 'Theme for testing the theme system with the PHPTemplate engine' +core: 8.x +engine: phptemplate +hidden: true diff --git a/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.theme b/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.theme new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.theme @@ -0,0 +1 @@ + +Success: Template overridden. diff --git a/core/modules/system/tests/themes/test_theme_twig/node--1.html.twig b/core/modules/system/tests/themes/test_theme_twig/node--1.html.twig deleted file mode 100644 index 046c02e..0000000 --- a/core/modules/system/tests/themes/test_theme_twig/node--1.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -{# - // node--1.html.twig - Dummy file for finding the template -#} -Node Content Dummy diff --git a/core/modules/system/tests/themes/test_theme_twig/template.php b/core/modules/system/tests/themes/test_theme_twig/template.php deleted file mode 100644 index a4abe2d..0000000 --- a/core/modules/system/tests/themes/test_theme_twig/template.php +++ /dev/null @@ -1,2 +0,0 @@ -