mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 14:28:27 +08:00
Fixes #14864: Ability to use dependencies in constructor of migrations
This commit is contained in:

committed by
Alexander Makarov

parent
7ff12aac42
commit
ab8c54f12a
@ -76,7 +76,7 @@ Yii Framework 2 Change Log
|
|||||||
- Chg #14286: Used primary inputmask package name instead of an alias (samdark)
|
- Chg #14286: Used primary inputmask package name instead of an alias (samdark)
|
||||||
- Chg #14321: `yii\widgets\MaskedInput` is now registering its JavaScript `clientOptions` initialization code in head section (DaveFerger)
|
- Chg #14321: `yii\widgets\MaskedInput` is now registering its JavaScript `clientOptions` initialization code in head section (DaveFerger)
|
||||||
- Chg #14487: Changed i18n message error to warning (dmirogin)
|
- Chg #14487: Changed i18n message error to warning (dmirogin)
|
||||||
|
- Enh #14864: Ability to use dependencies in constructor of migrations (vtvz)
|
||||||
|
|
||||||
2.0.12 June 05, 2017
|
2.0.12 June 05, 2017
|
||||||
--------------------
|
--------------------
|
||||||
|
@ -14,6 +14,7 @@ use yii\base\NotSupportedException;
|
|||||||
use yii\console\Controller;
|
use yii\console\Controller;
|
||||||
use yii\console\Exception;
|
use yii\console\Exception;
|
||||||
use yii\console\ExitCode;
|
use yii\console\ExitCode;
|
||||||
|
use yii\db\MigrationInterface;
|
||||||
use yii\helpers\Console;
|
use yii\helpers\Console;
|
||||||
use yii\helpers\FileHelper;
|
use yii\helpers\FileHelper;
|
||||||
|
|
||||||
@ -760,10 +761,13 @@ abstract class BaseMigrateController extends Controller
|
|||||||
protected function createMigration($class)
|
protected function createMigration($class)
|
||||||
{
|
{
|
||||||
$this->includeMigrationFile($class);
|
$this->includeMigrationFile($class);
|
||||||
$migration = new $class();
|
|
||||||
|
/** @var MigrationInterface $migration */
|
||||||
|
$migration = Yii::createObject($class);
|
||||||
if ($migration instanceof BaseObject && $migration->canSetProperty('compact')) {
|
if ($migration instanceof BaseObject && $migration->canSetProperty('compact')) {
|
||||||
$migration->compact = $this->compact;
|
$migration->compact = $this->compact;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $migration;
|
return $migration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,12 @@ class MigrateController extends BaseMigrateController
|
|||||||
protected function createMigration($class)
|
protected function createMigration($class)
|
||||||
{
|
{
|
||||||
$this->includeMigrationFile($class);
|
$this->includeMigrationFile($class);
|
||||||
return new $class(['db' => $this->db, 'compact' => $this->compact]);
|
|
||||||
|
return Yii::createObject([
|
||||||
|
'class' => $class,
|
||||||
|
'db' => $this->db,
|
||||||
|
'compact' => $this->compact,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user