public TwigEnvironment::getTemplateClass($name, $index = NULL)
Gets the template class associated with the given string.
Parameters
string $name: The name for which to calculate the template class name.
int $index: The index if it is an embedded template.
Return value
string The template class name.
Overrides Twig_Environment::getTemplateClass
File
- core/lib/Drupal/Core/Template/TwigEnvironment.php, line 79
Class
- TwigEnvironment
- A class that defines a Twig environment for Drupal.
Namespace
Drupal\Core\Template
Code
public function getTemplateClass($name, $index = NULL) { // We override this method to add caching because it gets called multiple // times when the same template is used more than once. For example, a page // rendering 50 nodes without any node template overrides will use the same // node.html.twig for the output of each node and the same compiled class. $cache_index = $name . (NULL === $index ? '' : '_' . $index); if (!isset($this->templateClasses[$cache_index])) { $this->templateClasses[$cache_index] = $this->templateClassPrefix . hash('sha256', $this->loader->getCacheKey($name)) . (NULL === $index ? '' : '_' . $index); } return $this->templateClasses[$cache_index]; }
Please login to continue.