[Twig] made code compatible with Twig 1.5
This commit is contained in:
parent
bebdd07f41
commit
adea589a3d
@ -89,15 +89,24 @@ class TransNode extends \Twig_Node
|
|||||||
return array($body, $vars);
|
return array($body, $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
$current = array();
|
|
||||||
foreach ($vars as $name => $var) {
|
|
||||||
$current[$name] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);
|
preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);
|
||||||
foreach ($matches[1] as $var) {
|
|
||||||
if (!isset($current['%'.$var.'%'])) {
|
if (version_compare(\Twig_Environment::VERSION, '1.5', '>=')) {
|
||||||
$vars->setNode('%'.$var.'%', new \Twig_Node_Expression_Name($var, $body->getLine()));
|
foreach ($matches[1] as $var) {
|
||||||
|
$key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine());
|
||||||
|
if (!$vars->hasElement($key)) {
|
||||||
|
$vars->addElement(new \Twig_Node_Expression_Name($var, $body->getLine()), $key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$current = array();
|
||||||
|
foreach ($vars as $name => $var) {
|
||||||
|
$current[$name] = true;
|
||||||
|
}
|
||||||
|
foreach ($matches[1] as $var) {
|
||||||
|
if (!isset($current['%'.$var.'%'])) {
|
||||||
|
$vars->setNode('%'.$var.'%', new \Twig_Node_Expression_Name($var, $body->getLine()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user