public function TwigPhpStorageCache::generateKey

public TwigPhpStorageCache::generateKey($name, $className)

Generates a cache key for the given template class name.

Parameters

string $name The template name:

string $className The template class name:

Return value

string

Overrides Twig_CacheInterface::generateKey

File

core/lib/Drupal/Core/Template/TwigPhpStorageCache.php, line 69

Class

TwigPhpStorageCache
Provides an alternate cache storage for Twig using PhpStorage.

Namespace

Drupal\Core\Template

Code

public function generateKey($name, $className) {
  $hash = hash('sha256', $className);

  if (strpos($name, '{# inline_template_start #}') === 0) {
    // $name is an inline template, and can have characters that are not valid
    // for a filename. $hash is unique for each inline template so we just use
    // the generic name 'inline-template' here.
    $name = 'inline-template';
  }
  else {
    $name = basename($name);
  }

  // The first part is what is invalidated.
  return $this->templateCacheFilenamePrefix . '_' . $name . '_' . $hash;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Template!TwigPhpStorageCache.php/function/TwigPhpStorageCache::generateKey/8.1.x