CoreExtension.php 973B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Muzich\CoreBundle\DependencyInjection;
  3. use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  4. use Symfony\Component\DependencyInjection\ContainerBuilder;
  5. use Symfony\Component\DependencyInjection\Definition;
  6. class CoreExtension extends Extension
  7. {
  8. public function load(array $config, ContainerBuilder $container) {
  9. $definition = new Definition('Muzich\CoreBundle\Extension\MyTwigExtension');
  10. // this is the most important part. Later in the startup process TwigBundle
  11. // searches through the container and registres all services taged as twig.extension.
  12. $definition->addTag('twig.extension');
  13. $container->setDefinition('my_twig_extension', $definition);
  14. }
  15. /**
  16. * Was necessary in previous Symfony2 PR releases.
  17. * Symfony2 calls `load` method automatically now.
  18. *
  19. * public function getAlias() {
  20. * return 'hello'; // that's how we'll call this extension in configuration files
  21. * }
  22. */
  23. }