Skip to content

fix: add src option for not standard paths #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/Maker/MakeEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
->addArgument('name', InputArgument::OPTIONAL, sprintf('Class name of the entity to create or update (e.g. <fg=yellow>%s</>)', Str::asClassName(Str::getRandomTerm())))
->addOption('regenerate', null, InputOption::VALUE_NONE, 'Instead of adding new fields, simply generate the methods (e.g. getter/setter) for existing fields')
->addOption('overwrite', null, InputOption::VALUE_NONE, 'Overwrite any existing getter/setter methods')
->addOption('src', null, InputOption::VALUE_OPTIONAL, 'source Entity Path', 'src/Entity/')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeEntity.txt'))
;

Expand All @@ -87,7 +88,7 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
return;
}

$entityFinder = $this->fileManager->createFinder('src/Entity/')
$entityFinder = $this->fileManager->createFinder($input->getOption('src'))
// remove if/when we allow entities in subdirectories
->depth('<1')
->name('*.php');
Expand All @@ -102,7 +103,7 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
}

$argument = $command->getDefinition()->getArgument('name');
$question = $this->createEntityClassQuestion($argument->getDescription());
$question = $this->createEntityClassQuestion($argument->getDescription(), $input->getOption('src'));
$value = $io->askQuestion($question);

$input->setArgument('name', $value);
Expand Down Expand Up @@ -452,9 +453,15 @@ private function printAvailableTypes(ConsoleStyle $io)
$printSection($allTypes);
}

private function createEntityClassQuestion(string $questionText): Question
/**
* @param string $questionText
* @param string $src
*
* @return Question
*/
private function createEntityClassQuestion(string $questionText, string $src = 'src/Entity'): Question
{
$entityFinder = $this->fileManager->createFinder('src/Entity/')
$entityFinder = $this->fileManager->createFinder($src)
// remove if/when we allow entities in subdirectories
->depth('<1')
->name('*.php');
Expand Down