Fix #19030: Add DI container usage to yii\base\Widget::end()

This commit is contained in:
Papp Péter
2021-11-30 21:58:24 +01:00
committed by GitHub
parent d52c1237ca
commit 0d899fa18b
3 changed files with 34 additions and 1 deletions

View File

@ -31,6 +31,7 @@ Yii Framework 2 Change Log
- Bug #18988: Fix default value of `yii\console\controllers\MessageController::$translator` (WinterSilence)
- Bug #18993: Load defaults by `attributes()` in `yii\db\ActiveRecord::loadDefaultValues()` (WinterSilence)
- Bug #19021: Fix return type in PhpDoc `yii\db\Migration` functions `up()`, `down()`, `safeUp()` and `safeDown()` (WinterSilence, rhertogh)
- Bug #19030: Add DI container usage to `yii\base\Widget::end()` (papppeter)
2.0.43 August 09, 2021

View File

@ -104,7 +104,13 @@ class Widget extends Component implements ViewContextInterface
{
if (!empty(self::$stack)) {
$widget = array_pop(self::$stack);
if (get_class($widget) === get_called_class()) {
$calledClass = get_called_class();
if (Yii::$container->has($calledClass) && isset(Yii::$container->getDefinitions()[$calledClass]['class'])) {
$calledClass = Yii::$container->getDefinitions()[$calledClass]['class'];
}
if (get_class($widget) === $calledClass) {
/* @var $widget Widget */
if ($widget->beforeRun()) {
$result = $widget->run();