Commit f6bc4a32 by Andrey Grachov

Extensions were added twice

parent efda450a
......@@ -56,7 +56,7 @@ class ViewRenderer extends BaseViewRenderer
public $filters = [];
/**
* @var array Custom extensions.
* Example: `['Twig_Extension_Sandbox', 'Twig_Extension_Text']`
* Example: `['Twig_Extension_Sandbox', new \Twig_Extension_Text()]`
*/
public $extensions = [];
/**
......@@ -84,13 +84,6 @@ class ViewRenderer extends BaseViewRenderer
'charset' => Yii::$app->charset,
], $this->options));
// Adding custom extensions
if (!empty($this->extensions)) {
foreach ($this->extensions as $extension) {
$this->twig->addExtension(new $extension());
}
}
// Adding custom globals (objects or static classes)
if (!empty($this->globals)) {
$this->addGlobals($this->globals);
......@@ -198,7 +191,7 @@ class ViewRenderer extends BaseViewRenderer
public function addExtensions($extensions)
{
foreach ($extensions as $extName) {
$this->twig->addExtension(new $extName());
$this->twig->addExtension(is_object($extName) ? $extName : new $extName());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment