[TwigBundle] added a new paths setting to allow configuration of more paths for the filesystem loader (refs #4649)
This commit is contained in:
parent
8f267ada09
commit
39e821c1eb
@ -4,6 +4,7 @@ CHANGELOG
|
|||||||
2.1.0
|
2.1.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
* added a new setting ("paths") to configure more paths for the Twig filesystem loader
|
||||||
* added contextual escaping based on the template file name (disabled if you explicitly pass an autoescape option)
|
* added contextual escaping based on the template file name (disabled if you explicitly pass an autoescape option)
|
||||||
* added a command that extracts translation messages from templates
|
* added a command that extracts translation messages from templates
|
||||||
* added the real template name when an error occurs in a Twig template
|
* added the real template name when an error occurs in a Twig template
|
||||||
|
@ -115,6 +115,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
private function addTwigOptions(ArrayNodeDefinition $rootNode)
|
private function addTwigOptions(ArrayNodeDefinition $rootNode)
|
||||||
{
|
{
|
||||||
$rootNode
|
$rootNode
|
||||||
|
->fixXmlConfig('path')
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('autoescape')->end()
|
->scalarNode('autoescape')->end()
|
||||||
->scalarNode('base_template_class')->example('Twig_Template')->end()
|
->scalarNode('base_template_class')->example('Twig_Template')->end()
|
||||||
@ -124,7 +125,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->scalarNode('strict_variables')->end()
|
->scalarNode('strict_variables')->end()
|
||||||
->scalarNode('auto_reload')->end()
|
->scalarNode('auto_reload')->end()
|
||||||
->scalarNode('optimizations')->end()
|
->scalarNode('optimizations')->end()
|
||||||
->arrayNode('loader_paths')
|
->arrayNode('paths')
|
||||||
->prototype('variable')->end()
|
->prototype('variable')->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
@ -60,8 +60,8 @@ class TwigExtension extends Extension
|
|||||||
$reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
|
$reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
|
||||||
$container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
|
$container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
|
||||||
|
|
||||||
if (!empty($config['loader_paths'])) {
|
if (!empty($config['paths'])) {
|
||||||
foreach ($config['loader_paths'] as $path) {
|
foreach ($config['paths'] as $path) {
|
||||||
$container->getDefinition('twig.loader')->addMethodCall('addPath', array($path));
|
$container->getDefinition('twig.loader')->addMethodCall('addPath', array($path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
|
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
|
||||||
<xsd:element name="global" type="global" minOccurs="0" maxOccurs="unbounded" />
|
<xsd:element name="global" type="global" minOccurs="0" maxOccurs="unbounded" />
|
||||||
|
<xsd:element name="path" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
|
|
||||||
<xsd:attribute name="auto-reload" type="xsd:string" />
|
<xsd:attribute name="auto-reload" type="xsd:string" />
|
||||||
|
@ -18,4 +18,5 @@ $container->loadFromExtension('twig', array(
|
|||||||
'charset' => 'ISO-8859-1',
|
'charset' => 'ISO-8859-1',
|
||||||
'debug' => true,
|
'debug' => true,
|
||||||
'strict_variables' => true,
|
'strict_variables' => true,
|
||||||
|
'paths' => array('path1', 'path2'),
|
||||||
));
|
));
|
||||||
|
@ -12,5 +12,7 @@
|
|||||||
</twig:form>
|
</twig:form>
|
||||||
<twig:global key="foo" id="bar" type="service" />
|
<twig:global key="foo" id="bar" type="service" />
|
||||||
<twig:global key="pi">3.14</twig:global>
|
<twig:global key="pi">3.14</twig:global>
|
||||||
|
<twig:path>path1</twig:path>
|
||||||
|
<twig:path>path2</twig:path>
|
||||||
</twig:config>
|
</twig:config>
|
||||||
</container>
|
</container>
|
||||||
|
@ -13,3 +13,4 @@ twig:
|
|||||||
charset: ISO-8859-1
|
charset: ISO-8859-1
|
||||||
debug: true
|
debug: true
|
||||||
strict_variables: true
|
strict_variables: true
|
||||||
|
paths: [path1, path2]
|
||||||
|
Reference in New Issue
Block a user