diff --git a/core/modules/system/src/Tests/Theme/EnginePhpTemplateTest.php b/core/modules/system/src/Tests/Theme/EngineNyanCatTest.php similarity index 62% rename from core/modules/system/src/Tests/Theme/EnginePhpTemplateTest.php rename to core/modules/system/src/Tests/Theme/EngineNyanCatTest.php index 37ab343966a55cd2bb0f436b8a1647f0bcb1e86a..bfaa1bb0d0fa9b783134c1edfca478f678b638f2 100644 --- a/core/modules/system/src/Tests/Theme/EnginePhpTemplateTest.php +++ b/core/modules/system/src/Tests/Theme/EngineNyanCatTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\system\Tests\Theme\EnginePhpTemplateTest. + * Contains \Drupal\system\Tests\Theme\EngineNyanCatTest. */ namespace Drupal\system\Tests\Theme; @@ -10,11 +10,11 @@ use Drupal\simpletest\WebTestBase; /** - * Tests theme functions with PHPTemplate. + * Tests the multi theme engine support. * * @group Theme */ -class EnginePhpTemplateTest extends WebTestBase { +class EngineNyanCatTest extends WebTestBase { /** * Modules to enable. @@ -25,7 +25,7 @@ class EnginePhpTemplateTest extends WebTestBase { protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(array('test_theme_phptemplate')); + \Drupal::service('theme_handler')->install(array('test_theme_nyan_cat_engine')); } /** @@ -33,10 +33,10 @@ protected function setUp() { */ function testTemplateOverride() { $this->config('system.theme') - ->set('default', 'test_theme_phptemplate') + ->set('default', 'test_theme_nyan_cat_engine') ->save(); $this->drupalGet('theme-test/template-test'); - $this->assertText('Success: Template overridden with PHPTemplate theme.', 'Template overridden by PHPTemplate file.'); + $this->assertText('Success: Template overridden with Nyan Cat theme. All of them', 'Template overridden by Nyan Cat file.'); } } diff --git a/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine b/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine new file mode 100644 index 0000000000000000000000000000000000000000..a1da728c2e918f9217e73aa2f9a51ce420d21806 --- /dev/null +++ b/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine @@ -0,0 +1,52 @@ +load(); +} + +/** + * Implements hook_theme(). + */ +function nyan_cat_theme($existing, $type, $theme, $path) { + $templates = drupal_find_theme_functions($existing, array($theme)); + $templates += drupal_find_theme_templates($existing, '.nyan-cat.html', $path); + return $templates; +} + +/** + * Implements hook_extension(). + */ +function nyan_cat_extension() { + return '.nyan-cat.html'; +} + +/** + * Implements hook_render_template(). + * + * @param string $template_file + * The filename of the template to render. + * @param mixed[] $variables + * A keyed array of variables that will appear in the output. + * + * @return string + * The output generated by the template. + */ +function nyan_cat_render_template($template_file, $variables) { + $output = str_replace('div', 'nyancat', file_get_contents(\Drupal::root() . '/' . $template_file)); + foreach ($variables as $key => $variable) { + if (strpos($output, '9' . $key) !== FALSE) { + $output = str_replace('9' . $key, theme_render_and_autoescape($variable), $output); + } + } + return $output; +} diff --git a/core/themes/engines/phptemplate/phptemplate.info.yml b/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.info.yml similarity index 76% rename from core/themes/engines/phptemplate/phptemplate.info.yml rename to core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.info.yml index 2bea7a07c69bb56fb86b33aa08dd6659e4802051..342191c6e2552ad92a066e0b0c1d9b98798699e1 100644 --- a/core/themes/engines/phptemplate/phptemplate.info.yml +++ b/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.info.yml @@ -1,5 +1,5 @@ type: theme_engine -name: PHPTemplate +name: Nyan cat core: 8.x version: VERSION package: Core diff --git a/core/modules/system/tests/themes/test_theme_nyan_cat_engine/test_theme_nyan_cat_engine.info.yml b/core/modules/system/tests/themes/test_theme_nyan_cat_engine/test_theme_nyan_cat_engine.info.yml new file mode 100644 index 0000000000000000000000000000000000000000..a911bd05714b35a0d0fa8f60024b495b8cf60144 --- /dev/null +++ b/core/modules/system/tests/themes/test_theme_nyan_cat_engine/test_theme_nyan_cat_engine.info.yml @@ -0,0 +1,6 @@ +name: 'Test theme for Nyan Cat engine' +type: theme +description: 'Theme for testing the theme system with the Nyan Cat theme engine' +version: VERSION +core: 8.x +engine: nyan_cat diff --git a/core/modules/system/tests/themes/test_theme_nyan_cat_engine/test_theme_nyan_cat_engine.theme b/core/modules/system/tests/themes/test_theme_nyan_cat_engine/test_theme_nyan_cat_engine.theme new file mode 100644 index 0000000000000000000000000000000000000000..5b69a12b557814e1f90ab1f38c8abf67358f412d --- /dev/null +++ b/core/modules/system/tests/themes/test_theme_nyan_cat_engine/test_theme_nyan_cat_engine.theme @@ -0,0 +1,8 @@ + -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 deleted file mode 100644 index da076b1f80a9d1f0459d1d9177efc5ea70f5db69..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.info.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: 'Test theme PHPTemplate' -type: theme -description: 'Theme for testing the theme system with the PHPTemplate engine' -version: VERSION -core: 8.x -engine: phptemplate 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 deleted file mode 100644 index b3d9bbc7f3711e882119cd6b3af051245d859d04..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.theme +++ /dev/null @@ -1 +0,0 @@ - - diff --git a/core/themes/engines/phptemplate/phptemplate.engine b/core/themes/engines/phptemplate/phptemplate.engine deleted file mode 100644 index 232f78d343ef02e53a86ca835dffc0e36ca0f80a..0000000000000000000000000000000000000000 --- a/core/themes/engines/phptemplate/phptemplate.engine +++ /dev/null @@ -1,58 +0,0 @@ -load(); -} - -/** - * Implements hook_theme(). - */ -function phptemplate_theme($existing, $type, $theme, $path) { - $templates = drupal_find_theme_functions($existing, array($theme)); - $templates += drupal_find_theme_templates($existing, '.tpl.php', $path); - return $templates; -} - -/** - * Implements hook_extension(). - */ -function phptemplate_extension() { - return '.tpl.php'; -} - -/** - * Implements hook_render_template(). - * - * Renders a system default template, which is essentially a PHP template. - * - * @param $template_file - * The filename of the template to render. - * @param $variables - * A keyed array of variables that will appear in the output. - * - * @return - * The output generated by the template. - */ -function phptemplate_render_template($template_file, $variables) { - // Extract the variables to a local namespace - extract($variables, EXTR_SKIP); - - // Start output buffering - ob_start(); - - // Include the template file - include \Drupal::root() . '/' . $template_file; - - // End buffering and return its contents - return ob_get_clean(); -}