Skip to content

Commit 257caa3

Browse files
committed
#47 validate now in handle
1 parent 99ef5b0 commit 257caa3

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/Commands/MakeEntityCommand.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public function __construct()
155155
*/
156156
public function handle()
157157
{
158+
$this->validateInput();
158159
$this->eventDispatcher->listen(SuccessCreateMessage::class, $this->getSuccessMessageCallback());
159160

160161
try {
@@ -175,19 +176,19 @@ protected function classExists($path, $name)
175176
return file_exists($classPath);
176177
}
177178

178-
protected function generate()
179+
protected function validateInput()
179180
{
180-
foreach ($this->rules['only'] as $option => $generators) {
181-
182-
if ($this->option('only-api')) {
183-
$modelName = $this->argument('name');
184-
185-
if (!$this->classExists('services', "{$modelName}Service")) {
186-
187-
throw new ClassNotExistsException('Cannot create API without entity.');
188-
}
181+
if ($this->option('only-api')) {
182+
$modelName = $this->argument('name');
183+
if (!$this->classExists('services', "{$modelName}Service")) {
184+
throw new ClassNotExistsException('Cannot create API without entity.');
189185
}
186+
}
187+
}
190188

189+
protected function generate()
190+
{
191+
foreach ($this->rules['only'] as $option => $generators) {
191192
if ($this->option($option)) {
192193
foreach ($generators as $generator) {
193194
$this->runGeneration($generator);

0 commit comments

Comments
 (0)