Commit fb2bb91e by Alexander Makarov

Merge pull request #2161 from yiisoft/widget-allow-return-instead-of-echo

Allow writing widgets using return instead of echo in the run method to make it consistent with controller
parents f51d0180 0367cebc
...@@ -121,6 +121,7 @@ Yii Framework 2 Change Log ...@@ -121,6 +121,7 @@ Yii Framework 2 Change Log
- Chg #2057: AutoTimestamp attributes defaults changed from `create_time` and `update_time` to `created_at` and `updated_at` (creocoder) - Chg #2057: AutoTimestamp attributes defaults changed from `create_time` and `update_time` to `created_at` and `updated_at` (creocoder)
- Chg #2063: Removed `yii\web\Request::acceptTypes` and renamed `yii\web\Request::acceptedContentTypes` to `acceptableContentTypes` (qiangxue) - Chg #2063: Removed `yii\web\Request::acceptTypes` and renamed `yii\web\Request::acceptedContentTypes` to `acceptableContentTypes` (qiangxue)
- Chg #2157: The '*' category pattern will match all categories that do not match any other patterns listed in `I18N::translations` (qiangxue, Ragazzo) - Chg #2157: The '*' category pattern will match all categories that do not match any other patterns listed in `I18N::translations` (qiangxue, Ragazzo)
- Chg #2161: Added ability to use `return` in `Widget::run` (samdark)
- Chg: Renamed `yii\jui\Widget::clientEventsMap` to `clientEventMap` (qiangxue) - Chg: Renamed `yii\jui\Widget::clientEventsMap` to `clientEventMap` (qiangxue)
- Chg: Renamed `ActiveRecord::getPopulatedRelations()` to `getRelatedRecords()` (qiangxue) - Chg: Renamed `ActiveRecord::getPopulatedRelations()` to `getRelatedRecords()` (qiangxue)
- Chg: Renamed `attributeName` and `className` to `targetAttribute` and `targetClass` for `UniqueValidator` and `ExistValidator` (qiangxue) - Chg: Renamed `attributeName` and `className` to `targetAttribute` and `targetClass` for `UniqueValidator` and `ExistValidator` (qiangxue)
......
...@@ -93,8 +93,8 @@ class Widget extends Component implements ViewContextInterface ...@@ -93,8 +93,8 @@ 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(); return ob_get_clean() . $out;
} }
private $_id; private $_id;
...@@ -149,6 +149,7 @@ class Widget extends Component implements ViewContextInterface ...@@ -149,6 +149,7 @@ class Widget extends Component implements ViewContextInterface
/** /**
* Executes the widget. * Executes the widget.
* @return string the result of widget execution to be outputted.
*/ */
public function run() public function run()
{ {
......
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