Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TwigExtensionPass.php

class TwigExtensionPass

Adds the twig_extension_hash parameter to the container.

Parameter twig_extension_hash is a crc32 hash of all extensions for Twig template invalidation.

Hierarchy

  • class \Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface

Expanded class hierarchy of TwigExtensionPass

1 file declares its use of TwigExtensionPass
CoreServiceProvider.php in core/lib/Drupal/Core/CoreServiceProvider.php

File

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

Namespace

Drupal\Core\DependencyInjection\Compiler
View source
class TwigExtensionPass implements CompilerPassInterface {
    
    /**
     * {@inheritdoc}
     */
    public function process(ContainerBuilder $container) : void {
        $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));
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
TwigExtensionPass::process public function You can modify the container here before it is dumped to PHP code. Overrides CompilerPassInterface::process

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal