Skip to content

Commit

Permalink
Allow to call ->addFilter with a class name as string
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Dec 12, 2017
1 parent 9628050 commit 3bf955b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 4 additions & 3 deletions ViewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ protected function initFilters()
{
if (!empty($this->filters)) {
foreach ($this->filters as $name => $handler) {
if (is_string($handler) && !is_callable($handler)) {
$handler = new $handler();
}
$this->addFilter($name, $handler);
}
}
Expand Down Expand Up @@ -161,6 +158,10 @@ public function render($view, $file, $params)
*/
public function addFilter($name, $handler)
{
if (is_string($handler) && !is_callable($handler)) {
$handler = new $handler();
}

$this->pug->filter($name, $handler);
}
}
1 change: 0 additions & 1 deletion tests/unit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*
* @link https://github.com/rmrevin/yii2-pug/blob/master/tests/unit/bootstrap.php
*/

define('YII_ENABLE_ERROR_HANDLER', true);
define('YII_DEBUG', true);
$_SERVER['SCRIPT_NAME'] = '/' . __DIR__;
Expand Down

0 comments on commit 3bf955b

Please sign in to comment.