/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/migrations/src/Command
NameSizeModeActions
Phinx/-0755rm
BakeMigrationCommand.php44810644editdlrm
BakeMigrationDiffCommand.php204860644editdlrm
BakeMigrationSnapshotCommand.php49870644editdlrm
BakeSeedCommand.php71390644editdlrm
BakeSimpleMigrationCommand.php59660644editdlrm
MigrationsCacheBuildCommand.php8440644editdlrm
MigrationsCacheClearCommand.php8440644editdlrm
MigrationsCommand.php67180644editdlrm
MigrationsCreateCommand.php8360644editdlrm
MigrationsDumpCommand.php8320644editdlrm
MigrationsMarkMigratedCommand.php8480644editdlrm
MigrationsMigrateCommand.php8380644editdlrm
MigrationsRollbackCommand.php8400644editdlrm
MigrationsSeedCommand.php8320644editdlrm
MigrationsStatusCommand.php8360644editdlrm
SnapshotTrait.php30780644editdlrm
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/migrations/src/Command/BakeSimpleMigrationCommand.php (5966B)
getMigrationName($name); return Util::getCurrentTimestamp() . '_' . Inflector::camelize($name) . '.php'; } /** * @inheritDoc */ public function getPath(Arguments $args): string { $path = ROOT . DS . $this->pathFragment; if (isset($this->plugin)) { $path = $this->_pluginPath($this->plugin) . $this->pathFragment; } return str_replace('/', DS, $path); } /** * @inheritDoc */ public function execute(Arguments $args, ConsoleIo $io): ?int { $this->extractCommonProperties($args); $name = $args->getArgumentAt(0); if (empty($name)) { $io->err('You must provide a name to bake a ' . $this->name()); $this->abort(); return null; } $name = $this->_getName($name); $name = Inflector::camelize($name); $this->bake($name, $args, $io); return static::CODE_SUCCESS; } /** * @inheritDoc */ public function bake(string $name, Arguments $args, ConsoleIo $io): void { $this->io = $io; $migrationWithSameName = glob($this->getPath($args) . '*_' . $name . '.php'); if (!empty($migrationWithSameName)) { $force = $args->getOption('force'); if (!$force) { $io->abort( sprintf( 'A migration with the name `%s` already exists. Please use a different name.', $name ) ); } $io->info(sprintf('A migration with the name `%s` already exists, it will be deleted.', $name)); foreach ($migrationWithSameName as $migration) { $io->info(sprintf('Deleting migration file `%s`...', $migration)); if (unlink($migration)) { $io->success(sprintf('Deleted `%s`', $migration)); } else { $io->err(sprintf('An error occurred while deleting `%s`', $migration)); } } } $renderer = new TemplateRenderer(); $renderer->set('name', $name); $renderer->set($this->templateData($args)); $contents = $renderer->generate($this->template()); $filename = $this->getPath($args) . $this->fileName($name); $this->createFile($filename, $contents, $args, $io); $emptyFile = $this->getPath($args) . '.gitkeep'; $this->deleteEmptyFile($emptyFile, $io); } /** * @param string $path Where to put the file. * @param string $contents Content to put in the file. * @param \Cake\Console\Arguments $args The command arguments. * @param \Cake\Console\ConsoleIo $io The console io * @return bool Success */ protected function createFile(string $path, string $contents, Arguments $args, ConsoleIo $io): bool { return $io->createFile($path, $contents); } /** * Returns a class name for the migration class * * If the name is invalid, the task will exit * * @param string|null $name Name for the generated migration * @return string Name of the migration file */ protected function getMigrationName($name = null) { if (empty($name)) { $this->io->abort('Choose a migration name to bake in CamelCase format'); } /** @psalm-suppress PossiblyNullArgument */ $name = $this->_getName($name); $name = Inflector::camelize($name); if (!preg_match('/^[A-Z]{1}[a-zA-Z0-9]+$/', $name)) { $this->io->abort('The className is not correct. The className can only contain "A-Z" and "0-9".'); } return $name; } /** * Gets the option parser instance and configures it. * * @param \Cake\Console\ConsoleOptionParser $parser Option parser to update. * @return \Cake\Console\ConsoleOptionParser */ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser { $parser = $this->_setCommonOptions($parser); $parser->setDescription( 'Bake migration class.' )->addOption('no-test', [ 'boolean' => true, 'help' => 'Do not generate a test skeleton.', ])->addOption('force', [ 'short' => 'f', 'boolean' => true, 'help' => 'Force overwriting existing file if a migration already exists with the same name.', ]); return $parser; } }