Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Sep 9, 2023
1 parent 4a95bcf commit 2cd3e9f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/Commands/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;

/**
* @property string|null $name
Expand Down Expand Up @@ -257,6 +258,44 @@ protected function isReservedName(string $name): bool
return in_array($name, $this->reservedNames);
}

/**
* Get a list of possible model names.
*
* @return array<int, string>
*/
protected function possibleModels()
{
$sourcePath = $this->preset->sourcePath();

$modelPath = is_dir("{$sourcePath}/Models") ? "{$sourcePath}/Models" : $sourcePath;

return collect((new Finder)->files()->depth(0)->in($modelPath))
->map(fn ($file) => $file->getBasename('.php'))
->sort()
->values()
->all();
}

/**
* Get a list of possible event names.
*
* @return array<int, string>
*/
protected function possibleEvents()
{
$eventPath = sprintf('%s/Events', $this->preset->sourcePath());

if (! is_dir($eventPath)) {
return [];
}

return collect((new Finder)->files()->depth(0)->in($eventPath))
->map(fn ($file) => $file->getBasename('.php'))
->sort()
->values()
->all();
}

/**
* Prompt for missing input arguments using the returned questions.
*
Expand Down

0 comments on commit 2cd3e9f

Please sign in to comment.