class NyanCatThemeEngine

NYAN NYAN NYAN!

If you don't understand yet what nyan cat is, look at https://www.youtube.com/watch?v=IAISUDbjXj0

Hierarchy

Expanded class hierarchy of NyanCatThemeEngine

1 string reference to 'NyanCatThemeEngine'
nyan_cat.services.yml in core/modules/system/tests/modules/nyan_cat/nyan_cat.services.yml
core/modules/system/tests/modules/nyan_cat/nyan_cat.services.yml
1 service uses NyanCatThemeEngine
theme_engine.nyan_cat in core/modules/system/tests/modules/nyan_cat/nyan_cat.services.yml
Drupal\nyan_cat\NyanCatThemeEngine

File

core/modules/system/tests/modules/nyan_cat/src/NyanCatThemeEngine.php, line 19

Namespace

Drupal\nyan_cat
View source
class NyanCatThemeEngine implements ThemeEngineInterface {
  
  /**
   * {@inheritdoc}
   */
  public function theme(array $existing, string $type, string $theme, string $path) : ?array {
    return drupal_find_theme_templates($existing, '.nyan-cat.html', $path);
  }
  
  /**
   * {@inheritdoc}
   */
  public function renderTemplate(string $template_file, array $variables) : string|MarkupInterface {
    $output = str_replace('div', 'nyancat', file_get_contents(\Drupal::root() . '/' . $template_file . '.nyan-cat.html'));
    foreach ($variables as $key => $variable) {
      if (str_contains($output, '9' . $key)) {
        $output = str_replace('9' . $key, Html::escape($variable), $output);
      }
    }
    return $output;
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
NyanCatThemeEngine::renderTemplate public function Renders a template. Overrides ThemeEngineInterface::renderTemplate
NyanCatThemeEngine::theme public function Registers templates that belong to the theme engine. Overrides ThemeEngineInterface::theme

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.