/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/migrations/src/Command
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/migrations/src/Command/MigrationsCommand.php (6718B)
getName();
return 'migrations ' . $name;
}
/**
* Array of arguments to run the shell with.
*
* @var array
*/
public $argv = [];
/**
* Defines what options can be passed to the shell.
* This is required because CakePHP validates the passed options
* and would complain if something not configured here is present
*
* @return \Cake\Console\ConsoleOptionParser
*/
public function getOptionParser(): ConsoleOptionParser
{
if (parent::defaultName() === 'migrations') {
return parent::getOptionParser();
}
$parser = parent::getOptionParser();
$command = new MigrationsDispatcher::$phinxCommands[static::$commandName]();
$parser->setDescription($command->getDescription());
$definition = $command->getDefinition();
foreach ($definition->getOptions() as $key => $option) {
if (!empty($option->getShortcut())) {
$parser->addOption($option->getName(), [
'short' => $option->getShortcut(),
'help' => $option->getDescription(),
]);
continue;
}
$parser->addOption($option->getName());
}
return $parser;
}
/**
* Defines constants that are required by phinx to get running
*
* @return void
*/
public function initialize(): void
{
if (!defined('PHINX_VERSION')) {
define('PHINX_VERSION', 'UNKNOWN');
}
parent::initialize();
}
/**
* This acts as a front-controller for phinx. It just instantiates the classes
* responsible for parsing the command line from phinx and gives full control of
* the rest of the flow to it.
*
* The input parameter of the ``MigrationDispatcher::run()`` method is manually built
* in case a MigrationsShell is dispatched using ``Shell::dispatch()``.
*
* @param \Cake\Console\Arguments $args The command arguments.
* @param \Cake\Console\ConsoleIo $io The console io
* @return null|int The exit code or null for success
*/
public function execute(Arguments $args, ConsoleIo $io): ?int
{
$app = $this->getApp();
$input = new ArgvInput($this->argv);
$app->setAutoExit(false);
$exitCode = $app->run($input, $this->getOutput());
if (in_array('-h', $this->argv, true) || in_array('--help', $this->argv, true)) {
return $exitCode;
}
if (
isset($this->argv[1]) && in_array($this->argv[1], ['migrate', 'rollback'], true) &&
!in_array('--no-lock', $this->argv, true) &&
$exitCode === 0
) {
$newArgs = [];
if (!empty($args->getOption('connection'))) {
$newArgs[] = '-c';
$newArgs[] = $args->getOption('connection');
}
if (!empty($args->getOption('plugin'))) {
$newArgs[] = '-p';
$newArgs[] = $args->getOption('plugin');
}
$io->out('');
$io->out('Dumps the current schema of the database to be used while baking a diff');
$io->out('');
$dumpExitCode = $this->executeCommand(MigrationsDumpCommand::class, $newArgs, $io);
}
if (isset($dumpExitCode) && $exitCode === 0 && $dumpExitCode !== 0) {
$exitCode = 1;
}
return $exitCode;
}
/**
* Returns the MigrationsDispatcher the Shell will have to use
*
* @return \Migrations\MigrationsDispatcher
*/
protected function getApp()
{
return new MigrationsDispatcher(PHINX_VERSION);
}
/**
* Returns the instance of OutputInterface the MigrationsDispatcher will have to use.
*
* @return \Symfony\Component\Console\Output\ConsoleOutput
*/
protected function getOutput()
{
return new ConsoleOutput();
}
/**
* Override the default behavior to save the command called
* in order to pass it to the command dispatcher
*
* @param array $argv Arguments from the CLI environment.
* @param \Cake\Console\ConsoleIo $io The console io
* @return int|null Exit code or null for success.
*/
public function run(array $argv, ConsoleIo $io): ?int
{
$name = static::defaultName();
$name = explode(' ', $name);
array_unshift($argv, ...$name);
$this->argv = $argv;
return parent::run($argv, $io);
}
/**
* Output help content
*
* @param \Cake\Console\ConsoleOptionParser $parser The option parser.
* @param \Cake\Console\Arguments $args The command arguments.
* @param \Cake\Console\ConsoleIo $io The console io
* @return void
*/
protected function displayHelp(ConsoleOptionParser $parser, Arguments $args, ConsoleIo $io): void
{
$this->execute($args, $io);
}
}