Skip to content

Commit

Permalink
Merge branch 'main' into NonInteractive_formlogin
Browse files Browse the repository at this point in the history
  • Loading branch information
eltharin authored Jan 10, 2025
2 parents 496beed + 0624f13 commit c9e93ec
Show file tree
Hide file tree
Showing 167 changed files with 541 additions and 229 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci-static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
-
name: Install PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: 8.2

-
name: Validate composer.json
Expand Down Expand Up @@ -58,6 +60,8 @@ jobs:

- name: Install PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: 8.2

- name: Install Composer Dependencies
uses: "ramsey/composer-install@v2"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
SYMFONY_PHPUNIT_DIR: "$HOME/symfony-bridge/.phpunit"
MAKER_SKIP_MERCURE_TEST: 1
MAKER_SKIP_PANTHER_TEST: 1
MAKER_TEST_WINDOWS: 1
MAKER_DISABLE_FILE_LINKS: 1
MAKER_ALLOW_DEV_DEPS_IN_APP: 0
SYMFONY_VERSION: '7.0.x-dev'
Expand Down
2 changes: 1 addition & 1 deletion .symfony.bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ branches: ["main"]

maintained_branches: ["main"]

doc_dir: "src/Resources/doc"
doc_dir: "docs"

2 changes: 1 addition & 1 deletion _docs_build/build.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$outputDir = __DIR__.'/output';
$buildConfig = (new BuildConfig())
->setSymfonyVersion('7.1')
->setContentDir(__DIR__.'/../src/Resources/doc')
->setContentDir(__DIR__.'/../docs')
->setOutputDir($outputDir)
->setImagesDir(__DIR__.'/output/_images')
->setImagesPublicPrefix('_images')
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"php": ">=8.1",
"doctrine/inflector": "^2.0",
"nikic/php-parser": "^4.18|^5.0",
"php-cs-fixer/shim": "^v3.64",
"symfony/config": "^6.4|^7.0",
"symfony/console": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
Expand Down
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.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
* file that was distributed with this source code.
*/

/*
* This PHP-CS-Fixer config file is used by the TemplateLinter for userland
* code when say make:controller is run. If a user does not have a php-cs-fixer
* config file, this one is used on the generated PHP files.
*
* It should not be confused by the root level .php-cs-fixer.dist.php config
* which is used to maintain the MakerBundle codebase itself.
*/
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/services.xml → config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
</service>

<service id="maker.template_linter" class="Symfony\Bundle\MakerBundle\Util\TemplateLinter">
<argument type="service" id="maker.file_manager" />
<argument>%env(default::string:MAKER_PHP_CS_FIXER_BINARY_PATH)%</argument>
<argument>%env(default::string:MAKER_PHP_CS_FIXER_CONFIG_PATH)%</argument>
</service>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/doc/index.rst → docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ optional arguments and options. Check them out with the ``--help`` option:
$ php bin/console make:controller --help
.. caution::

``make:entity`` requires ``doctrine/orm`` to be installed and configured. This maker support only ORM, not ODM.

Linting Generated Code
______________________
Expand Down
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
<env name="SYMFONY_PHPUNIT_VERSION" value="9.6" />
<env name="MAKER_SKIP_MERCURE_TEST" value="false"/>
<env name="MAKER_SKIP_PANTHER_TEST" value="false" />
<env name="MAKER_TEST_WINDOWS" value="false" />
<!-- Overrides process timeout when step debugging -->
<!-- <env name="MAKER_PROCESS_TIMEOUT" value="null" /> -->
<!-- Dump the CLI output for a test runner process immediately after running a test -->
<!-- You should only set this to true when you need to debug the actual output of a maker command within a test -->
<!-- <env name="MAKER_TEST_DUMP_OUTPUT" value="false" /> -->
</php>

<testsuites>
Expand Down
34 changes: 0 additions & 34 deletions src/DependencyInjection/Configuration.php

This file was deleted.

58 changes: 0 additions & 58 deletions src/DependencyInjection/MakerExtension.php

This file was deleted.

52 changes: 42 additions & 10 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function generateClass(string $className, string $templateName, array $va
$targetPath = $this->fileManager->getRelativePathForFutureClass($className);

if (null === $targetPath) {
throw new \LogicException(\sprintf('Could not determine where to locate the new class "%s", maybe try with a full namespace like "\\My\\Full\\Namespace\\%s"', $className, Str::getShortClassName($className)));
throw new \LogicException(\sprintf('Could not determine where to locate the new class "%s", maybe try with a full namespace like "My\\Full\\Namespace\\%s"', $className, Str::getShortClassName($className)));
}

$variables = array_merge($variables, [
Expand All @@ -81,27 +81,32 @@ public function generateClass(string $className, string $templateName, array $va
*
* @internal
*
* @param string $templateName Template name in Resources/skeleton to use
* @param string $templateName Template name in the templates/ dir to use
* @param array $variables Array of variables to pass to the template
* @param bool $isController Set to true if generating a Controller that needs
* access to the TemplateComponentGenerator ("generator") in
* the twig template. e.g. to create route attributes for a route method
*
* @return string The path where the file will be created
*
* @throws \Exception
*/
final public function generateClassFromClassData(ClassData $classData, string $templateName, array $variables = []): string
final public function generateClassFromClassData(ClassData $classData, string $templateName, array $variables = [], bool $isController = false): string
{
$classData = $this->templateComponentGenerator->configureClass($classData);
$targetPath = $this->fileManager->getRelativePathForFutureClass($classData->getFullClassName());

if (null === $targetPath) {
throw new \LogicException(\sprintf('Could not determine where to locate the new class "%s", maybe try with a full namespace like "\\My\\Full\\Namespace\\%s"', $classData->getFullClassName(), $classData->getClassName()));
throw new \LogicException(\sprintf('Could not determine where to locate the new class "%s", maybe try with a full namespace like "My\\Full\\Namespace\\%s"', $classData->getFullClassName(), $classData->getClassName()));
}

$variables = array_merge($variables, [
'class_data' => $classData,
]);
$globalTemplateVars = ['class_data' => $classData];

$this->addOperation($targetPath, $templateName, $variables);
if ($isController) {
$globalTemplateVars['generator'] = $this->templateComponentGenerator;
}

$this->addOperation($targetPath, $templateName, array_merge($variables, $globalTemplateVars));

return $targetPath;
}
Expand Down Expand Up @@ -294,10 +299,14 @@ private function addOperation(string $targetPath, string $templateName, array $v

$templatePath = $templateName;
if (!file_exists($templatePath)) {
$templatePath = __DIR__.'/Resources/skeleton/'.$templateName;
$templatePath = \sprintf('%s/templates/%s', \dirname(__DIR__), $templateName);

if (!file_exists($templatePath)) {
throw new \Exception(\sprintf('Cannot find template "%s"', $templateName));
$templatePath = $this->getTemplateFromLegacySkeletonPath($templateName);
}

if (!file_exists($templatePath)) {
throw new \Exception(\sprintf('Cannot find template "%s" in the templates/ dir.', $templateName));
}
}

Expand All @@ -306,4 +315,27 @@ private function addOperation(string $targetPath, string $templateName, array $v
'variables' => $variables,
];
}

/**
* @legacy - Remove when public generate methods become "internal" to MakerBundle in v2
*/
private function getTemplateFromLegacySkeletonPath(string $templateName): string
{
$templatePath = $templateName;
if (!file_exists($templatePath)) {
$templatePath = __DIR__.'/Resources/skeleton/'.$templateName;

if (!file_exists($templatePath)) {
throw new \Exception(\sprintf('Cannot find template "%s"', $templateName));
}
}

@trigger_deprecation(
'symfony/maker-bundle',
'1.62.0',
'Storing templates in src/Resources/skeleton is deprecated. Store MakerBundle templates in the "~/templates/" dir instead.',
);

return $templatePath;
}
}
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
Loading

0 comments on commit c9e93ec

Please sign in to comment.