[TwigBundle] converted flash tag to a function
This commit is contained in:
parent
3f492cae40
commit
13bcf7cdac
@ -75,6 +75,7 @@ class TemplatingExtension extends \Twig_Extension
|
||||
'url' => new \Twig_Function_Method($this, 'getUrl'),
|
||||
'path' => new \Twig_Function_Method($this, 'getPath'),
|
||||
'asset' => new \Twig_Function_Method($this, 'getAssetUrl'),
|
||||
'flash' => new \Twig_Function_Method($this, 'getFlash'),
|
||||
);
|
||||
}
|
||||
|
||||
@ -93,6 +94,11 @@ class TemplatingExtension extends \Twig_Extension
|
||||
return $this->container->get('templating.helper.assets')->getUrl($location);
|
||||
}
|
||||
|
||||
public function getFlash($name)
|
||||
{
|
||||
return $this->container->get('templating.helper.session')->getFlash($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the token parser instance to add to the existing list.
|
||||
*
|
||||
@ -116,9 +122,6 @@ class TemplatingExtension extends \Twig_Extension
|
||||
// {% render 'BlogBundle:Post:list' with { 'limit': 2 }, { 'alt': 'BlogBundle:Post:error' } %}
|
||||
new RenderTokenParser(),
|
||||
|
||||
// {% flash 'notice' %}
|
||||
new HelperTokenParser('flash', '<name>', 'templating.helper.session', 'getFlash'),
|
||||
|
||||
// {% include 'sometemplate.php' with { 'something' : 'something2' } %}
|
||||
new IncludeTokenParser(),
|
||||
);
|
||||
|
Reference in New Issue
Block a user