mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-20 10:27:18 +08:00
Added to the basic app, fixed config, added to core commands.
This commit is contained in:
@ -103,11 +103,18 @@ class FixtureController extends Controller
|
||||
* you can specify table name as a second parameter.
|
||||
* @param string $fixture
|
||||
*/
|
||||
public function actionApply($fixture)
|
||||
public function actionApply(array $fixture)
|
||||
{
|
||||
if ($this->getFixtureManager() == null) {
|
||||
throw new Exception(
|
||||
'Fixture manager is not configured properly. '
|
||||
. 'Please refer to official documentation for this purposes.');
|
||||
}
|
||||
|
||||
$this->getFixtureManager()->basePath = $this->fixturePath;
|
||||
$this->getFixtureManager()->db = $this->db;
|
||||
$this->loadFixtures([$fixture]);
|
||||
$this->loadFixtures($fixture);
|
||||
$this->notifySuccess($fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,4 +157,18 @@ class FixtureController extends Controller
|
||||
return $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies user that fixtures were successfully loaded.
|
||||
* @param array $fixtures
|
||||
*/
|
||||
private function notifySuccess($fixtures)
|
||||
{
|
||||
$this->stdout("Fixtures were successfully loaded from path: \n", Console::FG_YELLOW);
|
||||
$this->stdout(realpath(Yii::getAlias($this->fixturePath)) . "\n\n", Console::FG_GREEN);
|
||||
|
||||
foreach($fixtures as $index => $fixture) {
|
||||
$this->stdout($index +1 . ". " . $fixture . "\n", Console::FG_GREEN);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user