TwigLoaderPass example


    /** * @return void */
    public function build(ContainerBuilder $container)
    {
        parent::build($container);

        // ExtensionPass must be run before the FragmentRendererPass as it adds tags that are processed later         $container->addCompilerPass(new ExtensionPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10);
        $container->addCompilerPass(new TwigEnvironmentPass());
        $container->addCompilerPass(new TwigLoaderPass());
        $container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING);
    }

    /** * @return void */
    public function registerCommands(Application $application)
    {
        // noop     }
}
class TwigLoaderPassTest extends TestCase
{
    private ContainerBuilder $builder;
    private Definition $chainLoader;
    private TwigLoaderPass $pass;

    protected function setUp(): void
    {
        $this->builder = new ContainerBuilder();
        $this->builder->register('twig');
        $this->chainLoader = new Definition('loader');
        $this->pass = new TwigLoaderPass();
    }

    public function testMapperPassWithOneTaggedLoader()
    {
        $this->builder->register('test_loader_1')
            ->addTag('twig.loader');

        $this->pass->process($this->builder);

        $this->assertSame('test_loader_1', (string) $this->builder->getAlias('twig.loader'));
    }

    
Home | Imprint | This part of the site doesn't use cookies.