mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
moved include file logic to separate method
This commit is contained in:
@ -716,6 +716,21 @@ abstract class BaseMigrateController extends Controller
|
||||
* @return \yii\db\MigrationInterface the migration instance
|
||||
*/
|
||||
protected function createMigration($class)
|
||||
{
|
||||
$this->includeMigrationFile($class);
|
||||
return new $class();
|
||||
}
|
||||
|
||||
/**
|
||||
* Includes the migration file for a given migration class name.
|
||||
*
|
||||
* This function will do nothing on namespaced migrations, which are loaded by
|
||||
* autoloading automatically. It will include the migration file, by searching
|
||||
* [[migrationPath]] for classes without namespace.
|
||||
* @param string $class the migration class name.
|
||||
* @since 2.0.12
|
||||
*/
|
||||
protected function includeMigrationFile($class)
|
||||
{
|
||||
$class = trim($class, '\\');
|
||||
if (strpos($class, '\\') === false) {
|
||||
@ -732,8 +747,6 @@ abstract class BaseMigrateController extends Controller
|
||||
require_once($file);
|
||||
}
|
||||
}
|
||||
|
||||
return new $class();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -182,23 +182,7 @@ class MigrateController extends BaseMigrateController
|
||||
*/
|
||||
protected function createMigration($class)
|
||||
{
|
||||
$class = trim($class, '\\');
|
||||
if (strpos($class, '\\') === false) {
|
||||
if (is_array($this->migrationPath)) {
|
||||
foreach($this->migrationPath as $path) {
|
||||
$file = $path . DIRECTORY_SEPARATOR . $class . '.php';
|
||||
if (is_file($file)) {
|
||||
require_once($file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$file = $this->migrationPath . DIRECTORY_SEPARATOR . $class . '.php';
|
||||
require_once($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->includeMigrationFile($class);
|
||||
return new $class(['db' => $this->db]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user