From 8cff77f677ddc140178f47901d1128c05878ef08 Mon Sep 17 00:00:00 2001 From: Jagepard Date: Sat, 19 Feb 2022 13:33:05 +0300 Subject: [PATCH 1/2] adds CreateObserverCommand --- app/Ship/Commands/CreateObserverCommand.php | 89 +++++++++++++++++++++ rudra | 3 + 2 files changed, 92 insertions(+) create mode 100644 app/Ship/Commands/CreateObserverCommand.php diff --git a/app/Ship/Commands/CreateObserverCommand.php b/app/Ship/Commands/CreateObserverCommand.php new file mode 100644 index 0000000..eaf1a2a --- /dev/null +++ b/app/Ship/Commands/CreateObserverCommand.php @@ -0,0 +1,89 @@ +writeFile( + [str_replace('/', DIRECTORY_SEPARATOR, Rudra::config()->get('app.path') . "/app/Containers/$container/Observers/"), "{$className}.php"], + $this->createClass($className, $container) + ); + + } else { + $this->actionIndex(); + } + } + + /** + * @param string $className + * @param string $container + * @return string + * + * Creates class data + * ------------------ + * Создает данные класса + */ + private function createClass(string $className, string $container) + { + return <<eventRegistration(); +Cli::addCommand("create:observer", [App\Ship\Commands\CreateObserverCommand::class]); +Cli::addCommand("cr:ob", [App\Ship\Commands\CreateObserverCommand::class]); + Cli::addCommand("create:repository", [App\Ship\Commands\CreateRepositoryCommand::class]); Cli::addCommand("cr:r", [App\Ship\Commands\CreateRepositoryCommand::class]); From a4475c5a804c85104932e96039619a4dcb7d7103 Mon Sep 17 00:00:00 2001 From: Jagepard Date: Sat, 19 Feb 2022 13:33:14 +0300 Subject: [PATCH 2/2] CreateObserverCommand --- app/Ship/Commands/CreateObserverCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Ship/Commands/CreateObserverCommand.php b/app/Ship/Commands/CreateObserverCommand.php index eaf1a2a..eefe9fa 100644 --- a/app/Ship/Commands/CreateObserverCommand.php +++ b/app/Ship/Commands/CreateObserverCommand.php @@ -16,7 +16,7 @@ public function actionIndex() { Cli::printer("Enter observer name: ", "magneta"); $prefix = str_replace(PHP_EOL, "", Cli::reader()); - $className = ucfirst($prefix) . 'Listener'; + $className = ucfirst($prefix) . 'Observer'; Cli::printer("Enter container: ", "magneta"); $container = ucfirst(str_replace(PHP_EOL, "", Cli::reader()));