merged branch everzet/twig-paths (PR #4649)
Commits -------dbeff69
[TwigBundle] added support for custom loader paths Discussion ---------- [TwigBundle] added support for custom loader paths Before this commit, there was no ability to specify custom search paths for Twig loader. Lets say we have twig templates outside bundles directories (parts of the domain logic, not application) - we want to be able to load them. This commit adds `loader_paths` parameter to twig config, which is used to set custom paths to the loader. --------------------------------------------------------------------------- by travisbot at 2012-06-25T09:50:44Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1699654) (mergeddbeff697
into03c8d4d2
). --------------------------------------------------------------------------- by vicb at 2012-06-26T06:14:30Z You also need to support xml in the configuration and update the xsd file. edit: adding some DI unit tests is probably a good idea. --------------------------------------------------------------------------- by everzet at 2012-06-26T08:49:20Z @vicb agree, was just a fast stabbing ;) --------------------------------------------------------------------------- by fabpot at 2012-06-28T14:06:02Z I'm +1. Can you "finish" the PR? --------------------------------------------------------------------------- by fabpot at 2012-07-02T13:23:33Z @everzet If you don't have time, I can do the remaining work.
This commit is contained in:
commit
8f267ada09
@ -124,6 +124,9 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('strict_variables')->end()
|
||||
->scalarNode('auto_reload')->end()
|
||||
->scalarNode('optimizations')->end()
|
||||
->arrayNode('loader_paths')
|
||||
->prototype('variable')->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
|
@ -60,6 +60,12 @@ class TwigExtension extends Extension
|
||||
$reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
|
||||
$container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
|
||||
|
||||
if (!empty($config['loader_paths'])) {
|
||||
foreach ($config['loader_paths'] as $path) {
|
||||
$container->getDefinition('twig.loader')->addMethodCall('addPath', array($path));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($config['globals'])) {
|
||||
$def = $container->getDefinition('twig');
|
||||
foreach ($config['globals'] as $key => $global) {
|
||||
|
Reference in New Issue
Block a user