Hi there,

sorry for crossposting this but there is no response on the user 
mailinglist and I really need to sort this out.

I am struggling now for quite some time with the problem of adding a custom 
loader to Twig in Symfony2.

According to 
http://symfony.com/doc/current/reference/configuration/framework.html#templating
 there 
is a loaders configuration option. But this option seems to be ignored.

While digging in the source I found that the option is used for the 
"templating.loader" parameter. But this parameter is only used in the php 
Engine not in the twig engine: 
in Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension 
you can find:

if (!empty($config['loaders'])) {
    $loaders = array_map(function($loader) { return new Reference($loader); 
}, $config['loaders']);

    // Use a delegation unless only a single loader was registered
    if (1 === count($loaders)) {
        $container->setAlias('templating.loader', (string) reset($loaders));
    } else {
        
$container->getDefinition('templating.loader.chain')->addArgument($loaders);
        $container->setAlias('templating.loader', 
'templating.loader.chain');
    }
}

but:

<service id="templating.engine.php" class="%templating.engine.php.class%" 
public="false">
            <argument type="service" id="templating.name_parser" />
            <argument type="service" id="service_container" />
            <argument type="service" id="templating.loader" /> <= only used 
in templating_php.xml, not in templating.xml

The Twig Engine in Twig Bundle does not use this at all. Here we can find:
<service id="twig" class="%twig.class%">
            <argument type="service" id="twig.loader" />

And twig.loader is hard wired 
to Symfony\Bundle\TwigBundle\Loader\FilesystemLoader

Am I missing something obvious? How can I use the 
Symfony\Component\Templating\Loader\ChainLoader when using twig?

Greetings,

Roman

-- 
-- 
If you want to report a vulnerability issue on Symfony, please read the 
procedure on http://symfony.com/security

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to symfony-devs@googlegroups.com
To unsubscribe from this group, send email to
symfony-devs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en


Reply via email to