Commit 4023f421 by Alexander Makarov

Allow writing widgets using return instead of echo in the run method to make it…

Allow writing widgets using return instead of echo in the run method to make it consistent with controller
parent 698d66a2
...@@ -93,8 +93,13 @@ class Widget extends Component implements ViewContextInterface ...@@ -93,8 +93,13 @@ class Widget extends Component implements ViewContextInterface
/** @var Widget $widget */ /** @var Widget $widget */
$config['class'] = get_called_class(); $config['class'] = get_called_class();
$widget = Yii::createObject($config); $widget = Yii::createObject($config);
$widget->run(); $out = $widget->run();
return ob_get_clean(); if (empty($out)) {
return ob_get_clean();
} else {
ob_clean();
return $out;
}
} }
private $_id; private $_id;
......
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