Skip to content

Commit

Permalink
minor symfony#1605 Move help files into new directory structure
Browse files Browse the repository at this point in the history
* add helper method to get the help file contents for each maker

* move help files to new config dir
  • Loading branch information
jrushlow authored Sep 28, 2024
1 parent 6e1ed41 commit ce60831
Show file tree
Hide file tree
Showing 63 changed files with 56 additions and 36 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The <info>%command.name%</info> command generates or updates databases services in compose.yaml
<info>php %command.full_name%</info>
Supports MySQL, MariaDB and PostgreSQL
The <info>%command.name%</info> command generates or updates databases services in compose.yaml

<info>php %command.full_name%</info>

Supports MySQL, MariaDB and PostgreSQL
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions src/Maker/AbstractMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,17 @@ protected function addDependencies(array $dependencies, ?string $message = null)
$message
);
}

/**
* Get the help file contents needed for "setHelp()" of a maker.
*
* @param string $helpFileName the filename (omit path) of the help file located in config/help/
* e.g. MakeController.txt
*
* @internal
*/
final protected function getHelpFileContents(string $helpFileName): string
{
return file_get_contents(\sprintf('%s/config/help/%s', \dirname(__DIR__, 2), $helpFileName));
}
}
2 changes: 1 addition & 1 deletion src/Maker/Common/CanGenerateTestsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait CanGenerateTestsTrait

public function configureCommandWithTestsOption(Command $command): Command
{
$testsHelp = file_get_contents(\dirname(__DIR__, 2).'/Resources/help/_WithTests.txt');
$testsHelp = file_get_contents(\dirname(__DIR__, 3).'/config/help/_WithTests.txt');
$help = $command->getHelp()."\n".$testsHelp;

$command
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/Common/UidTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait UidTrait
*/
protected function addWithUuidOption(Command $command): Command
{
$uidHelp = file_get_contents(\dirname(__DIR__, 2).'/Resources/help/_WithUid.txt');
$uidHelp = file_get_contents(\dirname(__DIR__, 3).'/config/help/_WithUid.txt');
$help = $command->getHelp()."\n".$uidHelp;

$command
Expand Down
3 changes: 2 additions & 1 deletion src/Maker/MakeAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public static function getCommandDescription(): string
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeAuth.txt'));
->setHelp($this->getHelpFileContents('MakeAuth.txt'))
;
}

public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('name', InputArgument::OPTIONAL, \sprintf('Choose a command name (e.g. <fg=yellow>app:%s</>)', Str::asCommand(Str::getRandomTerm())))
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeCommand.txt'))
->setHelp($this->getHelpFileContents('MakeCommand.txt'))
;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
->addArgument('controller-class', InputArgument::OPTIONAL, \sprintf('Choose a name for your controller class (e.g. <fg=yellow>%sController</>)', Str::asClassName(Str::getRandomTerm())))
->addOption('no-template', null, InputOption::VALUE_NONE, 'Use this option to disable template generation')
->addOption('invokable', 'i', InputOption::VALUE_NONE, 'Use this option to create an invokable controller')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeController.txt'))
->setHelp($this->getHelpFileContents('MakeController.txt'))
;

$this->configureCommandWithTestsOption($command);
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('entity-class', InputArgument::OPTIONAL, \sprintf('The class name of the entity to create CRUD (e.g. <fg=yellow>%s</>)', Str::asClassName(Str::getRandomTerm())))
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeCrud.txt'))
->setHelp($this->getHelpFileContents('MakeCrud.txt'))
;

$inputConfig->setArgumentAsNonInteractive('entity-class');
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeDockerDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function getCommandDescription(): string
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeDockerDatabase.txt'))
->setHelp($this->getHelpFileContents('MakeDockerDatabase.txt'))
;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
->addOption('broadcast', 'b', InputOption::VALUE_NONE, 'Add the ability to broadcast entity updates using Symfony UX Turbo?')
->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')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeEntity.txt'))
->setHelp($this->getHelpFileContents('MakeEntity.txt'))
;

$this->addWithUuidOption($command);
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('fixtures-class', InputArgument::OPTIONAL, 'The class name of the fixtures to create (e.g. <fg=yellow>AppFixtures</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeFixture.txt'))
->setHelp($this->getHelpFileContents('MakeFixture.txt'))
;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
$command
->addArgument('name', InputArgument::OPTIONAL, \sprintf('The name of the form class (e.g. <fg=yellow>%sType</>)', Str::asClassName(Str::getRandomTerm())))
->addArgument('bound-class', InputArgument::OPTIONAL, 'The name of Entity or fully qualified model class name that the new form will be bound to (empty for none)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeForm.txt'))
->setHelp($this->getHelpFileContents('MakeForm.txt'))
;

$inputConfig->setArgumentAsNonInteractive('bound-class');
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('name', InputArgument::OPTIONAL, 'The name of the functional test class (e.g. <fg=yellow>DefaultControllerTest</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeFunctionalTest.txt'))
->setHelp($this->getHelpFileContents('MakeFunctionalTest.txt'))
;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
$command
->addArgument('name', InputArgument::OPTIONAL, 'Choose a class name for your event listener or subscriber (e.g. <fg=yellow>ExceptionListener</> or <fg=yellow>ExceptionSubscriber</>)')
->addArgument('event', InputArgument::OPTIONAL, 'What event do you want to listen to?')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeListener.txt'))
->setHelp($this->getHelpFileContents('MakeListener.txt'))
;

$inputConfig->setArgumentAsNonInteractive('event');
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('name', InputArgument::OPTIONAL, 'The name of the message class (e.g. <fg=yellow>SendEmailMessage</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeMessage.txt'))
->setHelp($this->getHelpFileContents('MakeMessage.txt'))
;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Maker/MakeMessengerMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('name', InputArgument::OPTIONAL, 'The name of the middleware class (e.g. <fg=yellow>CustomMiddleware</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeMessage.txt'));
->setHelp($this->getHelpFileContents('MakeMessage.txt'))
;
}

public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function setApplication(Application $application)
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeMigration.txt'))
->setHelp($this->getHelpFileContents('MakeMigration.txt'))
;

if (class_exists(MigrationsDiffDoctrineCommand::class)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeRegistrationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function getCommandDescription(): string
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeRegistrationForm.txt'))
->setHelp($this->getHelpFileContents('MakeRegistrationForm.txt'))
;

$this->configureCommandWithTestsOption($command);
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static function getCommandDescription(): string
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeResetPassword.txt'))
->setHelp($this->getHelpFileContents('MakeResetPassword.txt'))
;

$this->addWithUuidOption($command);
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static function getCommandDescription(): string
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeScheduler.txt'))
->setHelp($this->getHelpFileContents('MakeScheduler.txt'))
;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeSerializerEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
$command
->addArgument('name', InputArgument::OPTIONAL, 'Choose a class name for your encoder (e.g. <fg=yellow>YamlEncoder</>)')
->addArgument('format', InputArgument::OPTIONAL, 'Pick your format name (e.g. <fg=yellow>yaml</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeSerializerEncoder.txt'))
->setHelp($this->getHelpFileContents('MakeSerializerEncoder.txt'))
;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeSerializerNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('name', InputArgument::OPTIONAL, 'Choose a class name for your normalizer (e.g. <fg=yellow>UserNormalizer</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeSerializerNormalizer.txt'))
->setHelp($this->getHelpFileContents('MakeSerializerNormalizer.txt'))
;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Maker/MakeStimulusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('name', InputArgument::REQUIRED, 'The name of the Stimulus controller (e.g. <fg=yellow>hello</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeStimulusController.txt'));
->setHelp($this->getHelpFileContents('MakeStimulusController.txt'))
;
}

public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
$command
->addArgument('name', InputArgument::OPTIONAL, 'Choose a class name for your event subscriber (e.g. <fg=yellow>ExceptionSubscriber</>)')
->addArgument('event', InputArgument::OPTIONAL, 'What event do you want to subscribe to?')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeSubscriber.txt'))
->setHelp($this->getHelpFileContents('MakeSubscriber.txt'))
;

$inputConfig->setArgumentAsNonInteractive('event');
Expand Down
3 changes: 2 additions & 1 deletion src/Maker/MakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
$command
->addArgument('type', InputArgument::OPTIONAL, 'The type of test: '.implode(', ', $typesDesc))
->addArgument('name', InputArgument::OPTIONAL, 'The name of the test class (e.g. <fg=yellow>BlogPostTest</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeTest.txt').implode("\n", $typesHelp));
->setHelp($this->getHelpFileContents('MakeTest.txt').implode("\n", $typesHelp))
;

$inputConfig->setArgumentAsNonInteractive('name');
$inputConfig->setArgumentAsNonInteractive('type');
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('name', InputArgument::OPTIONAL, 'The name of the Twig extension class (e.g. <fg=yellow>AppExtension</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeTwigExtension.txt'))
->setHelp($this->getHelpFileContents('MakeTwigExtension.txt'))
;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('name', InputArgument::OPTIONAL, 'The name of the unit test class (e.g. <fg=yellow>UtilTest</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeUnitTest.txt'))
->setHelp($this->getHelpFileContents('MakeUnitTest.txt'))
;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Maker/MakeUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
->addOption('is-entity', null, InputOption::VALUE_NONE, 'Do you want to store user data in the database (via Doctrine)?')
->addOption('identity-property-name', null, InputOption::VALUE_REQUIRED, 'Enter a property name that will be the unique "display" name for the user (e.g. <comment>email, username, uuid</comment>)')
->addOption('with-password', null, InputOption::VALUE_NONE, 'Will this app be responsible for checking the password? Choose <comment>No</comment> if the password is actually checked by some other system (e.g. a single sign-on server)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeUser.txt'));
->setHelp($this->getHelpFileContents('MakeUser.txt'))
;

$this->addWithUuidOption($command);

Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('name', InputArgument::OPTIONAL, 'The name of the validator class (e.g. <fg=yellow>EnabledValidator</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeValidator.txt'))
->setHelp($this->getHelpFileContents('MakeValidator.txt'))
;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('name', InputArgument::OPTIONAL, 'The name of the security voter class (e.g. <fg=yellow>BlogPostVoter</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeVoter.txt'))
->setHelp($this->getHelpFileContents('MakeVoter.txt'))
;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Maker/MakeWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
{
$command
->addArgument('name', InputArgument::OPTIONAL, 'Name of the webhook to create (e.g. <fg=yellow>github, stripe, ...</>)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeWebhook.txt'))
->setHelp($this->getHelpFileContents('MakeWebhook.txt'))
;

$inputConfig->setArgumentAsNonInteractive('name');
Expand Down
2 changes: 1 addition & 1 deletion src/Maker/Security/MakeCustomAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function getCommandDescription(): string
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->setHelp(file_get_contents(__DIR__.'/../../Resources/help/security/MakeCustom.txt'))
->setHelp($this->getHelpFileContents('security/MakeCustom.txt'))
;
}

Expand Down
4 changes: 3 additions & 1 deletion src/Maker/Security/MakeFormLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public static function getCommandName(): string

public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command->setHelp(file_get_contents(\dirname(__DIR__, 2).'/Resources/help/security/MakeFormLogin.txt'));
$command
->setHelp($this->getHelpFileContents('security/MakeFormLogin.txt'))
;

$this->configureCommandWithTestsOption($command);
}
Expand Down

0 comments on commit ce60831

Please sign in to comment.