Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php \Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass::process()
  2. 9 core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php \Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass::process()

File

core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php, line 20

Class

TwigExtensionPass
Adds the twig_extension_hash parameter to the container.

Namespace

Drupal\Core\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  $twig_extension_hash = '';
  foreach (array_keys($container
    ->findTaggedServiceIds('twig.extension')) as $service_id) {
    $class_name = $container
      ->getDefinition($service_id)
      ->getClass();
    $reflection = new \ReflectionClass($class_name);

    // We use the class names as hash in order to invalidate on new extensions
    // and crc32 for every time we change an existing file.
    $twig_extension_hash .= $class_name . hash_file('crc32', $reflection
      ->getFileName());
  }
  $container
    ->setParameter('twig_extension_hash', Crypt::hashBase64($twig_extension_hash));
}