From 8f8a5f2c3e86ac5fc368d67debfbc997f1c6c6f2 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 27 Nov 2024 17:28:52 +0100 Subject: [PATCH 1/2] Fix BC topic. --- src/Command/BakeSimpleMigrationCommand.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Command/BakeSimpleMigrationCommand.php b/src/Command/BakeSimpleMigrationCommand.php index 31e0db7d..4988eaa6 100644 --- a/src/Command/BakeSimpleMigrationCommand.php +++ b/src/Command/BakeSimpleMigrationCommand.php @@ -44,6 +44,13 @@ abstract class BakeSimpleMigrationCommand extends SimpleBakeCommand */ protected ?ConsoleIo $io = null; + /** + * Arguments + * + * @var \Cake\Console\Arguments|null + */ + protected ?Arguments $args = null; + /** * @inheritDoc */ @@ -55,17 +62,16 @@ public function name(): string /** * @inheritDoc */ - public function fileName($name, ?string $path = null): string + public function fileName($name): string { $name = $this->getMigrationName($name); $timestamp = Util::getCurrentTimestamp(); $suffix = '_' . Inflector::camelize($name) . '.php'; - if ($path) { - $offset = 0; - while (glob($path . $timestamp . '_*\\.php')) { - $timestamp = Util::getCurrentTimestamp(++$offset); - } + $path = $this->getPath($this->args); + $offset = 0; + while (glob($path . $timestamp . '_*\\.php')) { + $timestamp = Util::getCurrentTimestamp(++$offset); } return $timestamp . $suffix; @@ -109,6 +115,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int public function bake(string $name, Arguments $args, ConsoleIo $io): void { $this->io = $io; + $this->args = $args; $migrationWithSameName = glob($this->getPath($args) . '*_' . $name . '.php'); if (!empty($migrationWithSameName)) { $force = $args->getOption('force'); From 8320211512e022d3330cfbf4a426c26da3e7e7f1 Mon Sep 17 00:00:00 2001 From: mscherer Date: Wed, 27 Nov 2024 17:35:42 +0100 Subject: [PATCH 2/2] Fix BC topic. --- src/Command/BakeSimpleMigrationCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command/BakeSimpleMigrationCommand.php b/src/Command/BakeSimpleMigrationCommand.php index 4988eaa6..97007138 100644 --- a/src/Command/BakeSimpleMigrationCommand.php +++ b/src/Command/BakeSimpleMigrationCommand.php @@ -145,7 +145,7 @@ public function bake(string $name, Arguments $args, ConsoleIo $io): void $contents = $renderer->generate($this->template()); $path = $this->getPath($args); - $filename = $path . $this->fileName($name, $path); + $filename = $path . $this->fileName($name); $this->createFile($filename, $contents, $args, $io); $emptyFile = $path . '.gitkeep';