public function actionLoad(array $fixturesInput = [])
{
if ($fixturesInput === []) {
$this->stdout($this->getHelpSummary() . "\n");
$helpCommand = Console::ansiFormat('yii help fixture', [Console::FG_CYAN]);
$this->stdout("Use {$helpCommand} to get usage info.\n");
return self::EXIT_CODE_NORMAL;
}
$filtered = $this->filterFixtures($fixturesInput);
$except = $filtered['except'];
if (!$this->needToApplyAll($fixturesInput[0])) {
$fixtures = $filtered['apply'];
$foundFixtures = $this->findFixtures($fixtures);
$notFoundFixtures = array_diff($fixtures, $foundFixtures);
if ($notFoundFixtures) {
$this->notifyNotFound($notFoundFixtures);
}
} else {
$foundFixtures = $this->findFixtures();
}
$fixturesToLoad = array_diff($foundFixtures, $except);
if (!$foundFixtures) {
throw new Exception("No files were found for: \"" . implode(', ', $fixturesInput) . "\".\n" . "Check that files exist under fixtures path: \n\"" . $this->getFixturePath() . "\".");
}
if (!$fixturesToLoad) {
$this->notifyNothingToLoad($foundFixtures, $except);
return static::EXIT_CODE_NORMAL;
}
if (!$this->confirmLoad($fixturesToLoad, $except)) {
return static::EXIT_CODE_NORMAL;
}
$fixtures = $this->getFixturesConfig(array_merge($this->globalFixtures, $fixturesToLoad));
if (!$fixtures) {
throw new Exception('No fixtures were found in namespace: "' . $this->namespace . '"' . '');
}
$fixturesObjects = $this->createFixtures($fixtures);
$this->unloadFixtures($fixturesObjects);
$this->loadFixtures($fixturesObjects);
$this->notifyLoaded($fixtures);
return static::EXIT_CODE_NORMAL;
}