From b701ae480045624fd57958cc747e929a9c670e26 Mon Sep 17 00:00:00 2001 From: Isaac Adzah Sai Date: Thu, 28 Dec 2023 19:07:23 +0000 Subject: [PATCH] Allow creating state or action as initial state with option --- src/Commands/ActionCommand.php | 5 +++++ src/Commands/StateCommand.php | 5 +++++ stubs/action.init.stub | 13 +++++++++++++ stubs/response.stub | 4 ++-- stubs/state.init.stub | 14 ++++++++++++++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 stubs/action.init.stub create mode 100644 stubs/state.init.stub diff --git a/src/Commands/ActionCommand.php b/src/Commands/ActionCommand.php index 6df6eb0..5b3c658 100644 --- a/src/Commands/ActionCommand.php +++ b/src/Commands/ActionCommand.php @@ -10,10 +10,15 @@ class ActionCommand extends GeneratorCommand protected $signature = 'ussd:action {name : The name of the USSD Action} + {--init : Create the class as the initial USSD action} {--force : Create the class even if USSD action already exists}'; protected function getStub() { + if ($this->option('init')) { + return __DIR__.'/../../stubs/action.init.stub'; + } + return __DIR__.'/../../stubs/action.stub'; } diff --git a/src/Commands/StateCommand.php b/src/Commands/StateCommand.php index 5c6d87c..6a60c43 100644 --- a/src/Commands/StateCommand.php +++ b/src/Commands/StateCommand.php @@ -10,10 +10,15 @@ class StateCommand extends GeneratorCommand protected $signature = 'ussd:state {name : The name of the USSD State} + {--init : Create the class as the initial USSD state} {--force : Create the class even if USSD state already exists}'; protected function getStub() { + if ($this->option('init')) { + return __DIR__.'/../../stubs/state.init.stub'; + } + return __DIR__.'/../../stubs/state.stub'; } diff --git a/stubs/action.init.stub b/stubs/action.init.stub new file mode 100644 index 0000000..0eb283e --- /dev/null +++ b/stubs/action.init.stub @@ -0,0 +1,13 @@ +text(''); + } +}