/var/www/vhosts/ihelp.ro/httpdocs/vendor/robmorgan/phinx/src/Phinx/Console/Command
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/robmorgan/phinx/src/Phinx/Console/Command/SeedRun.php (4307B)
addOption('--environment', '-e', InputOption::VALUE_REQUIRED, 'The target environment');
$this->setDescription('Run database seeders')
->addOption('--seed', '-s', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'What is the name of the seeder?')
->setHelp(
<<
seed:run command runs all available or individual seeders
phinx seed:run -e development
phinx seed:run -e development -s UserSeeder
phinx seed:run -e development -s UserSeeder -s PermissionSeeder -s LogSeeder
phinx seed:run -e development -v
EOT
);
}
/**
* Run database seeders.
*
* @param \Symfony\Component\Console\Input\InputInterface $input Input
* @param \Symfony\Component\Console\Output\OutputInterface $output Output
* @return int integer 0 on success, or an error code.
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->bootstrap($input, $output);
/** @var array|null $seedSet */
$seedSet = $input->getOption('seed');
/** @var string|null $environment */
$environment = $input->getOption('environment');
if ($environment === null) {
$environment = $this->getConfig()->getDefaultEnvironment();
$output->writeln('warning no environment specified, defaulting to: ' . $environment, $this->verbosityLevel);
} else {
$output->writeln('using environment ' . $environment, $this->verbosityLevel);
}
if (!$this->getConfig()->hasEnvironment($environment)) {
$output->writeln(sprintf('The environment "%s" does not exist', $environment));
return self::CODE_ERROR;
}
$envOptions = $this->getConfig()->getEnvironment($environment);
if (isset($envOptions['adapter'])) {
$output->writeln('using adapter ' . $envOptions['adapter'], $this->verbosityLevel);
}
if (isset($envOptions['wrapper'])) {
$output->writeln('using wrapper ' . $envOptions['wrapper'], $this->verbosityLevel);
}
if (isset($envOptions['name'])) {
$output->writeln('using database ' . $envOptions['name'], $this->verbosityLevel);
} else {
$output->writeln('Could not determine database name! Please specify a database name in your config file.');
return self::CODE_ERROR;
}
if (isset($envOptions['table_prefix'])) {
$output->writeln('using table prefix ' . $envOptions['table_prefix'], $this->verbosityLevel);
}
if (isset($envOptions['table_suffix'])) {
$output->writeln('using table suffix ' . $envOptions['table_suffix'], $this->verbosityLevel);
}
$start = microtime(true);
if (empty($seedSet)) {
// run all the seed(ers)
$this->getManager()->seed($environment);
} else {
// run seed(ers) specified in a comma-separated list of classes
foreach ($seedSet as $seed) {
$this->getManager()->seed($environment, trim($seed));
}
}
$end = microtime(true);
$output->writeln('', $this->verbosityLevel);
$output->writeln('All Done. Took ' . sprintf('%.4fs', $end - $start) . '', $this->verbosityLevel);
return self::CODE_SUCCESS;
}
}