class TwigExtensionPass in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php \Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass
Adds the twig_extension_hash parameter to the container.
twig_extension_hash is a hash of all extension mtimes for Twig template invalidation.
Hierarchy
- class \Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass implements CompilerPassInterface
Expanded class hierarchy of TwigExtensionPass
1 file declares its use of TwigExtensionPass
- CoreServiceProvider.php in core/
lib/ Drupal/ Core/ CoreServiceProvider.php - Contains \Drupal\Core\CoreServiceProvider.
File
- core/
lib/ Drupal/ Core/ DependencyInjection/ Compiler/ TwigExtensionPass.php, line 19 - Contains \Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass.
Namespace
Drupal\Core\DependencyInjection\CompilerView source
class TwigExtensionPass implements CompilerPassInterface {
/**
* {@inheritdoc}
*/
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 mtime for every time we change an existing file.
$twig_extension_hash .= $class_name . filemtime($reflection
->getFileName());
}
$container
->setParameter('twig_extension_hash', hash('crc32b', $twig_extension_hash));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TwigExtensionPass:: |
public | function |
You can modify the container here before it is dumped to PHP code. Overrides CompilerPassInterface:: |