Skip to content

Commit c9e93ec

Browse files
authored
Merge branch 'main' into NonInteractive_formlogin
2 parents 496beed + 0624f13 commit c9e93ec

File tree

167 files changed

+541
-229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+541
-229
lines changed

.github/workflows/ci-static-analysis.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
-
2727
name: Install PHP
2828
uses: "shivammathur/setup-php@v2"
29+
with:
30+
php-version: 8.2
2931

3032
-
3133
name: Validate composer.json
@@ -58,6 +60,8 @@ jobs:
5860

5961
- name: Install PHP
6062
uses: "shivammathur/setup-php@v2"
63+
with:
64+
php-version: 8.2
6165

6266
- name: Install Composer Dependencies
6367
uses: "ramsey/composer-install@v2"

.github/workflows/ci-windows.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
SYMFONY_PHPUNIT_DIR: "$HOME/symfony-bridge/.phpunit"
1414
MAKER_SKIP_MERCURE_TEST: 1
1515
MAKER_SKIP_PANTHER_TEST: 1
16+
MAKER_TEST_WINDOWS: 1
1617
MAKER_DISABLE_FILE_LINKS: 1
1718
MAKER_ALLOW_DEV_DEPS_IN_APP: 0
1819
SYMFONY_VERSION: '7.0.x-dev'

.symfony.bundle.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ branches: ["main"]
22

33
maintained_branches: ["main"]
44

5-
doc_dir: "src/Resources/doc"
5+
doc_dir: "docs"
66

_docs_build/build.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
$outputDir = __DIR__.'/output';
3131
$buildConfig = (new BuildConfig())
3232
->setSymfonyVersion('7.1')
33-
->setContentDir(__DIR__.'/../src/Resources/doc')
33+
->setContentDir(__DIR__.'/../docs')
3434
->setOutputDir($outputDir)
3535
->setImagesDir(__DIR__.'/output/_images')
3636
->setImagesPublicPrefix('_images')

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"php": ">=8.1",
1717
"doctrine/inflector": "^2.0",
1818
"nikic/php-parser": "^4.18|^5.0",
19+
"php-cs-fixer/shim": "^v3.64",
1920
"symfony/config": "^6.4|^7.0",
2021
"symfony/console": "^6.4|^7.0",
2122
"symfony/dependency-injection": "^6.4|^7.0",
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
The <info>%command.name%</info> command generates or updates databases services in compose.yaml
2-
3-
<info>php %command.full_name%</info>
4-
5-
Supports MySQL, MariaDB and PostgreSQL
1+
The <info>%command.name%</info> command generates or updates databases services in compose.yaml
2+
3+
<info>php %command.full_name%</info>
4+
5+
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.

src/Resources/config/php-cs-fixer.config.php renamed to config/php-cs-fixer.config.php

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
/*
13+
* This PHP-CS-Fixer config file is used by the TemplateLinter for userland
14+
* code when say make:controller is run. If a user does not have a php-cs-fixer
15+
* config file, this one is used on the generated PHP files.
16+
*
17+
* It should not be confused by the root level .php-cs-fixer.dist.php config
18+
* which is used to maintain the MakerBundle codebase itself.
19+
*/
1220
return (new PhpCsFixer\Config())
1321
->setRules([
1422
'@Symfony' => true,

src/Resources/config/services.xml renamed to config/services.xml

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
</service>
4242

4343
<service id="maker.template_linter" class="Symfony\Bundle\MakerBundle\Util\TemplateLinter">
44+
<argument type="service" id="maker.file_manager" />
4445
<argument>%env(default::string:MAKER_PHP_CS_FIXER_BINARY_PATH)%</argument>
4546
<argument>%env(default::string:MAKER_PHP_CS_FIXER_CONFIG_PATH)%</argument>
4647
</service>

src/Resources/doc/index.rst renamed to docs/index.rst

+3

phpunit.xml.dist

+4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@
1919
<env name="SYMFONY_PHPUNIT_VERSION" value="9.6" />
2020
<env name="MAKER_SKIP_MERCURE_TEST" value="false"/>
2121
<env name="MAKER_SKIP_PANTHER_TEST" value="false" />
22+
<env name="MAKER_TEST_WINDOWS" value="false" />
2223
<!-- Overrides process timeout when step debugging -->
2324
<!-- <env name="MAKER_PROCESS_TIMEOUT" value="null" /> -->
25+
<!-- Dump the CLI output for a test runner process immediately after running a test -->
26+
<!-- You should only set this to true when you need to debug the actual output of a maker command within a test -->
27+
<!-- <env name="MAKER_TEST_DUMP_OUTPUT" value="false" /> -->
2428
</php>
2529

2630
<testsuites>

src/DependencyInjection/Configuration.php

-34
This file was deleted.

src/DependencyInjection/MakerExtension.php

-58
This file was deleted.

src/Generator.php

+42-10
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function generateClass(string $className, string $templateName, array $va
6363
$targetPath = $this->fileManager->getRelativePathForFutureClass($className);
6464

6565
if (null === $targetPath) {
66-
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)));
66+
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)));
6767
}
6868

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

9699
if (null === $targetPath) {
97-
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()));
100+
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()));
98101
}
99102

100-
$variables = array_merge($variables, [
101-
'class_data' => $classData,
102-
]);
103+
$globalTemplateVars = ['class_data' => $classData];
103104

104-
$this->addOperation($targetPath, $templateName, $variables);
105+
if ($isController) {
106+
$globalTemplateVars['generator'] = $this->templateComponentGenerator;
107+
}
108+
109+
$this->addOperation($targetPath, $templateName, array_merge($variables, $globalTemplateVars));
105110

106111
return $targetPath;
107112
}
@@ -294,10 +299,14 @@ private function addOperation(string $targetPath, string $templateName, array $v
294299

295300
$templatePath = $templateName;
296301
if (!file_exists($templatePath)) {
297-
$templatePath = __DIR__.'/Resources/skeleton/'.$templateName;
302+
$templatePath = \sprintf('%s/templates/%s', \dirname(__DIR__), $templateName);
298303

299304
if (!file_exists($templatePath)) {
300-
throw new \Exception(\sprintf('Cannot find template "%s"', $templateName));
305+
$templatePath = $this->getTemplateFromLegacySkeletonPath($templateName);
306+
}
307+
308+
if (!file_exists($templatePath)) {
309+
throw new \Exception(\sprintf('Cannot find template "%s" in the templates/ dir.', $templateName));
301310
}
302311
}
303312

@@ -306,4 +315,27 @@ private function addOperation(string $targetPath, string $templateName, array $v
306315
'variables' => $variables,
307316
];
308317
}
318+
319+
/**
320+
* @legacy - Remove when public generate methods become "internal" to MakerBundle in v2
321+
*/
322+
private function getTemplateFromLegacySkeletonPath(string $templateName): string
323+
{
324+
$templatePath = $templateName;
325+
if (!file_exists($templatePath)) {
326+
$templatePath = __DIR__.'/Resources/skeleton/'.$templateName;
327+
328+
if (!file_exists($templatePath)) {
329+
throw new \Exception(\sprintf('Cannot find template "%s"', $templateName));
330+
}
331+
}
332+
333+
@trigger_deprecation(
334+
'symfony/maker-bundle',
335+
'1.62.0',
336+
'Storing templates in src/Resources/skeleton is deprecated. Store MakerBundle templates in the "~/templates/" dir instead.',
337+
);
338+
339+
return $templatePath;
340+
}
309341
}

src/Maker/AbstractMaker.php

+13
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,17 @@ protected function addDependencies(array $dependencies, ?string $message = null)
5555
$message
5656
);
5757
}
58+
59+
/**
60+
* Get the help file contents needed for "setHelp()" of a maker.
61+
*
62+
* @param string $helpFileName the filename (omit path) of the help file located in config/help/
63+
* e.g. MakeController.txt
64+
*
65+
* @internal
66+
*/
67+
final protected function getHelpFileContents(string $helpFileName): string
68+
{
69+
return file_get_contents(\sprintf('%s/config/help/%s', \dirname(__DIR__, 2), $helpFileName));
70+
}
5871
}

src/Maker/Common/CanGenerateTestsTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ trait CanGenerateTestsTrait
2828

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

3434
$command

src/Maker/Common/UidTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait UidTrait
3434
*/
3535
protected function addWithUuidOption(Command $command): Command
3636
{
37-
$uidHelp = file_get_contents(\dirname(__DIR__, 2).'/Resources/help/_WithUid.txt');
37+
$uidHelp = file_get_contents(\dirname(__DIR__, 3).'/config/help/_WithUid.txt');
3838
$help = $command->getHelp()."\n".$uidHelp;
3939

4040
$command

src/Maker/MakeAuthenticator.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ public static function getCommandDescription(): string
9292
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
9393
{
9494
$command
95-
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeAuth.txt'));
95+
->setHelp($this->getHelpFileContents('MakeAuth.txt'))
96+
;
9697
}
9798

9899
public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void

src/Maker/MakeCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
5858
{
5959
$command
6060
->addArgument('name', InputArgument::OPTIONAL, \sprintf('Choose a command name (e.g. <fg=yellow>app:%s</>)', Str::asCommand(Str::getRandomTerm())))
61-
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeCommand.txt'))
61+
->setHelp($this->getHelpFileContents('MakeCommand.txt'))
6262
;
6363
}
6464

0 commit comments

Comments
 (0)