TemplatingPass.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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\Component\DependencyInjection\Compiler\CompilerPassInterface;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. class TemplatingPass implements CompilerPassInterface
  14. {
  15. public function process(ContainerBuilder $container)
  16. {
  17. if ($container->hasDefinition('templating')) {
  18. return;
  19. }
  20. if ($container->hasDefinition('templating.engine.php')) {
  21. $helpers = array();
  22. foreach ($container->findTaggedServiceIds('templating.helper') as $id => $attributes) {
  23. if (isset($attributes[0]['alias'])) {
  24. $helpers[$attributes[0]['alias']] = $id;
  25. }
  26. }
  27. if (\count($helpers) > 0) {
  28. $definition = $container->getDefinition('templating.engine.php');
  29. $definition->addMethodCall('setHelpers', array($helpers));
  30. }
  31. }
  32. }
  33. }