vendor/symfony/framework-bundle/DependencyInjection/Compiler/TemplatingPass.php line 43

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
  11. use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
  12. use Symfony\Component\DependencyInjection\Alias;
  13. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  14. use Symfony\Component\DependencyInjection\ContainerBuilder;
  15. use Symfony\Component\DependencyInjection\Reference;
  16. use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
  17. /**
  18.  * @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
  19.  */
  20. class TemplatingPass implements CompilerPassInterface
  21. {
  22.     public function process(ContainerBuilder $container)
  23.     {
  24.         if ($container->hasDefinition('templating')) {
  25.             return;
  26.         }
  27.         if ($container->hasAlias('templating')) {
  28.             $container->setAlias(ComponentEngineInterface::class, new Alias('templating'false));
  29.             $container->setAlias(FrameworkBundleEngineInterface::class, new Alias('templating'false));
  30.         }
  31.         if ($container->hasDefinition('templating.engine.php')) {
  32.             $refs = [];
  33.             $helpers = [];
  34.             foreach ($container->findTaggedServiceIds('templating.helper'true) as $id => $attributes) {
  35.                 if (!$container->getDefinition($id)->isDeprecated()) {
  36.                     @trigger_error('The "templating.helper" tag is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.'E_USER_DEPRECATED);
  37.                 }
  38.                 if (isset($attributes[0]['alias'])) {
  39.                     $helpers[$attributes[0]['alias']] = $id;
  40.                     $refs[$id] = new Reference($id);
  41.                 }
  42.             }
  43.             if (\count($helpers) > 0) {
  44.                 $definition $container->getDefinition('templating.engine.php');
  45.                 $definition->addMethodCall('setHelpers', [$helpers]);
  46.                 if ($container->hasDefinition('templating.engine.php.helpers_locator')) {
  47.                     $container->getDefinition('templating.engine.php.helpers_locator')->replaceArgument(0$refs);
  48.                 }
  49.             }
  50.         }
  51.     }
  52. }