Skip to content

Commit 9ac0b3b

Browse files
authored
Merge branch 'main' into feature/custom-namespaces
2 parents c06bb10 + e607f12 commit 9ac0b3b

37 files changed

+421
-42
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ jobs:
7474
image: dunglas/mercure
7575
env:
7676
SERVER_NAME: :1337
77-
MERCURE_PUBLISHER_JWT_KEY: '!ChangeMe!'
78-
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeMe!'
77+
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
78+
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
7979
MERCURE_EXTRA_DIRECTIVES: |
8080
anonymous
8181
cors_origins *

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
# Changelog
22

3+
## [v1.47.0](https://github.com/symfony/maker-bundle/releases/tag/v1.47.0)
4+
5+
*October 4th, 2022*
6+
7+
### Feature
8+
9+
- [#1211](https://github.com/symfony/maker-bundle/pull/1211) - [make:twig-extension] Change folder for Twig Extension - *@seb-jean*
10+
11+
### Bug
12+
13+
- [#1217](https://github.com/symfony/maker-bundle/pull/1217) - [make:registration-form] render the raw signedUrl in the email template -
14+
*@jrushlow*
15+
- [#1210](https://github.com/symfony/maker-bundle/pull/1210) - [make:serializer] use empty string in str_replace - *@jrushlow*
16+
- [#1209](https://github.com/symfony/maker-bundle/pull/1209) - [make:crud] use save instead of add in `upgradePassword` - *@seb-jean*
17+
18+
## [v1.46.0](https://github.com/symfony/maker-bundle/releases/tag/v1.46.0)
19+
20+
*September 23rd, 2022*
21+
22+
### Feature
23+
24+
- [#1204](https://github.com/symfony/maker-bundle/pull/1204) - [make:crud] use save instead of add repository methods - *@jrushlow*
25+
- [#1202](https://github.com/symfony/maker-bundle/pull/1202) - [reset-password] use higher level "options" in ChangePasswordFormType.tpl.php - *@seb-jean*
26+
- [#1019](https://github.com/symfony/maker-bundle/pull/1019) - Add `make:twig-component` maker - *@kbond*
27+
### Bug
28+
29+
- [#1199](https://github.com/symfony/maker-bundle/pull/1199) - [make:entity] fix compatibility with api-platform 3.0 - *@yobrx*
30+
- [#1176](https://github.com/symfony/maker-bundle/pull/1176) - [make:entity] Fix error while making blob in entity - *@mdoutreluingne*
31+
332
## [v1.45.0](https://github.com/symfony/maker-bundle/releases/tag/v1.45.0)
433

534
*July 26th, 2022*

src/Maker/MakeEntity.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
namespace Symfony\Bundle\MakerBundle\Maker;
1313

14-
use ApiPlatform\Core\Annotation\ApiResource;
14+
use ApiPlatform\Core\Annotation\ApiResource as LegacyApiResource;
15+
use ApiPlatform\Metadata\ApiResource;
1516
use Doctrine\DBAL\Types\Type;
1617
use Symfony\Bundle\MakerBundle\ConsoleStyle;
1718
use Symfony\Bundle\MakerBundle\DependencyBuilder;
@@ -320,10 +321,17 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
320321
public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null): void
321322
{
322323
if (null !== $input && $input->getOption('api-resource')) {
323-
$dependencies->addClassDependency(
324-
ApiResource::class,
325-
'api'
326-
);
324+
if (class_exists(ApiResource::class)) {
325+
$dependencies->addClassDependency(
326+
ApiResource::class,
327+
'api'
328+
);
329+
} else {
330+
$dependencies->addClassDependency(
331+
LegacyApiResource::class,
332+
'api'
333+
);
334+
}
327335
}
328336

329337
if (null !== $input && $input->getOption('broadcast')) {

src/Maker/MakeResetPassword.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
* @author Antoine Michelet <[email protected]>
7474
*
7575
* @internal
76+
*
7677
* @final
7778
*/
7879
class MakeResetPassword extends AbstractMaker

src/Maker/MakeTwigComponent.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony MakerBundle package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\MakerBundle\Maker;
13+
14+
use Symfony\Bundle\MakerBundle\ConsoleStyle;
15+
use Symfony\Bundle\MakerBundle\DependencyBuilder;
16+
use Symfony\Bundle\MakerBundle\Generator;
17+
use Symfony\Bundle\MakerBundle\InputConfiguration;
18+
use Symfony\Bundle\MakerBundle\Str;
19+
use Symfony\Component\Console\Command\Command;
20+
use Symfony\Component\Console\Input\InputArgument;
21+
use Symfony\Component\Console\Input\InputInterface;
22+
use Symfony\Component\Console\Input\InputOption;
23+
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
24+
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
25+
26+
/**
27+
* @author Kevin Bond <[email protected]>
28+
*/
29+
final class MakeTwigComponent extends AbstractMaker
30+
{
31+
public static function getCommandName(): string
32+
{
33+
return 'make:twig-component';
34+
}
35+
36+
public static function getCommandDescription(): string
37+
{
38+
return 'Creates a twig (or live) component';
39+
}
40+
41+
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
42+
{
43+
$command
44+
->setDescription(self::getCommandDescription())
45+
->addArgument('name', InputArgument::OPTIONAL, 'The name of your twig component (ie <fg=yellow>NotificationComponent</>)')
46+
->addOption('live', null, InputOption::VALUE_NONE, 'Whether to create a live twig component (requires <fg=yellow>symfony/ux-live-component</>)')
47+
;
48+
}
49+
50+
public function configureDependencies(DependencyBuilder $dependencies): void
51+
{
52+
$dependencies->addClassDependency(AsTwigComponent::class, 'symfony/ux-twig-component');
53+
}
54+
55+
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void
56+
{
57+
$name = $input->getArgument('name');
58+
$live = $input->getOption('live');
59+
60+
if ($live && !class_exists(AsLiveComponent::class)) {
61+
throw new \RuntimeException('You must install symfony/ux-live-component to create a live component (composer require symfony/ux-live-component)');
62+
}
63+
64+
$factory = $generator->createClassNameDetails(
65+
$name,
66+
'Twig\\Components',
67+
'Component'
68+
);
69+
70+
$shortName = Str::asSnakeCase(Str::removeSuffix($factory->getShortName(), 'Component'));
71+
72+
$generator->generateClass(
73+
$factory->getFullName(),
74+
sprintf('%s/../Resources/skeleton/twig/%s', __DIR__, $live ? 'LiveComponent.tpl.php' : 'Component.tpl.php'),
75+
[
76+
'live' => $live,
77+
'short_name' => $shortName,
78+
]
79+
);
80+
$generator->generateTemplate(
81+
"components/{$shortName}.html.twig",
82+
sprintf('%s/../Resources/skeleton/twig/%s', __DIR__, 'component_template.tpl.php')
83+
);
84+
85+
$generator->writeChanges();
86+
87+
$this->writeSuccessMessage($io);
88+
$io->newLine();
89+
$io->writeln(" To render the component, use {{ component('{$shortName}') }}.");
90+
$io->newLine();
91+
}
92+
93+
public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void
94+
{
95+
if (!$input->getOption('live')) {
96+
$input->setOption('live', $io->confirm('Make this a live component?', class_exists(AsLiveComponent::class)));
97+
}
98+
}
99+
}

src/Resources/config/makers.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<tag name="maker.command" />
2222
</service>
2323

24+
<service id="maker.maker.make_twig_component" class="Symfony\Bundle\MakerBundle\Maker\MakeTwigComponent">
25+
<tag name="maker.command" />
26+
</service>
27+
2428
<service id="maker.maker.make_controller" class="Symfony\Bundle\MakerBundle\Maker\MakeController">
2529
<argument type="service" id="maker.php_compat_util" />
2630
<tag name="maker.command" />

src/Resources/skeleton/crud/controller/Controller.tpl.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function index(EntityManagerInterface $entityManager): Response
2929
<?php endif ?>
3030

3131
<?= $generator->generateRouteForControllerMethod('/new', sprintf('%s_new', $route_name), ['GET', 'POST']) ?>
32-
<?php if (isset($repository_full_class_name) && $generator->repositoryHasAddRemoveMethods($repository_full_class_name)) { ?>
32+
<?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name)) { ?>
3333
public function new(Request $request, <?= $repository_class_name ?> $<?= $repository_var ?>): Response
3434
<?php } else { ?>
3535
public function new(Request $request, EntityManagerInterface $entityManager): Response
@@ -39,9 +39,9 @@ public function new(Request $request, EntityManagerInterface $entityManager): Re
3939
$form = $this->createForm(<?= $form_class_name ?>::class, $<?= $entity_var_singular ?>);
4040
$form->handleRequest($request);
4141

42-
<?php if (isset($repository_full_class_name) && $generator->repositoryHasAddRemoveMethods($repository_full_class_name)) { ?>
42+
<?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name)) { ?>
4343
if ($form->isSubmitted() && $form->isValid()) {
44-
$<?= $repository_var ?>->add($<?= $entity_var_singular ?>, true);
44+
$<?= $repository_var ?>->save($<?= $entity_var_singular ?>, true);
4545

4646
return $this->redirectToRoute('<?= $route_name ?>_index', [], Response::HTTP_SEE_OTHER);
4747
}
@@ -76,7 +76,7 @@ public function show(<?= $entity_class_name ?> $<?= $entity_var_singular ?>): Re
7676
}
7777

7878
<?= $generator->generateRouteForControllerMethod(sprintf('/{%s}/edit', $entity_identifier), sprintf('%s_edit', $route_name), ['GET', 'POST']) ?>
79-
<?php if (isset($repository_full_class_name) && $generator->repositoryHasAddRemoveMethods($repository_full_class_name)) { ?>
79+
<?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name)) { ?>
8080
public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>, <?= $repository_class_name ?> $<?= $repository_var ?>): Response
8181
<?php } else { ?>
8282
public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>, EntityManagerInterface $entityManager): Response
@@ -85,9 +85,9 @@ public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_va
8585
$form = $this->createForm(<?= $form_class_name ?>::class, $<?= $entity_var_singular ?>);
8686
$form->handleRequest($request);
8787

88-
<?php if (isset($repository_full_class_name) && $generator->repositoryHasAddRemoveMethods($repository_full_class_name)) { ?>
88+
<?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name)) { ?>
8989
if ($form->isSubmitted() && $form->isValid()) {
90-
$<?= $repository_var ?>->add($<?= $entity_var_singular ?>, true);
90+
$<?= $repository_var ?>->save($<?= $entity_var_singular ?>, true);
9191

9292
return $this->redirectToRoute('<?= $route_name ?>_index', [], Response::HTTP_SEE_OTHER);
9393
}
@@ -113,13 +113,13 @@ public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_va
113113
}
114114

115115
<?= $generator->generateRouteForControllerMethod(sprintf('/{%s}', $entity_identifier), sprintf('%s_delete', $route_name), ['POST']) ?>
116-
<?php if (isset($repository_full_class_name) && $generator->repositoryHasAddRemoveMethods($repository_full_class_name)) { ?>
116+
<?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name)) { ?>
117117
public function delete(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>, <?= $repository_class_name ?> $<?= $repository_var ?>): Response
118118
<?php } else { ?>
119119
public function delete(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>, EntityManagerInterface $entityManager): Response
120120
<?php } ?>
121121
{
122-
<?php if (isset($repository_full_class_name) && $generator->repositoryHasAddRemoveMethods($repository_full_class_name)) { ?>
122+
<?php if (isset($repository_full_class_name) && $generator->repositoryHasSaveAndRemoveMethods($repository_full_class_name)) { ?>
123123
if ($this->isCsrfTokenValid('delete'.$<?= $entity_var_singular ?>->get<?= ucfirst($entity_identifier) ?>(), $request->request->get('_token'))) {
124124
$<?= $repository_var ?>->remove($<?= $entity_var_singular ?>, true);
125125
}

src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class <?= $class_name ?> extends WebTestCase<?= "\n" ?>
1515
protected function setUp(): void
1616
{
1717
$this->client = static::createClient();
18-
$this->manager = (static::getContainer()->get('doctrine'))->getManager();
18+
$this->manager = static::getContainer()->get('doctrine')->getManager();
1919
$this->repository = $this->manager->getRepository(<?= $entity_class_name; ?>::class);
2020

2121
foreach ($this->repository->findAll() as $object) {

src/Resources/skeleton/crud/test/Test.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class <?= $class_name ?> extends WebTestCase<?= "\n" ?>
1414
protected function setUp(): void
1515
{
1616
$this->client = static::createClient();
17-
$this->repository = (static::getContainer()->get('doctrine'))->getRepository(<?= $entity_class_name; ?>::class);
17+
$this->repository = static::getContainer()->get('doctrine')->getRepository(<?= $entity_class_name; ?>::class);
1818

1919
foreach ($this->repository->findAll() as $object) {
2020
$this->repository->remove($object, true);

src/Resources/skeleton/doctrine/Repository.tpl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(ManagerRegistry $registry)
1919
parent::__construct($registry, <?= $entity_class_name; ?>::class);
2020
}
2121

22-
public function add(<?= $entity_class_name ?> $entity, bool $flush = false): void
22+
public function save(<?= $entity_class_name ?> $entity, bool $flush = false): void
2323
{
2424
$this->getEntityManager()->persist($entity);
2525

@@ -51,7 +51,7 @@ public function upgradePassword(<?= sprintf('%s ', $password_upgrade_user_interf
5151

5252
$user->setPassword($newHashedPassword);
5353

54-
$this->add($user, true);
54+
$this->save($user, true);
5555
}
5656

5757
<?php endif ?>

src/Resources/skeleton/registration/twig_email.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<p>
44
Please confirm your email address by clicking the following link: <br><br>
5-
<a href="{{ signedUrl }}">Confirm my Email</a>.
5+
<a href="{{ signedUrl|raw }}">Confirm my Email</a>.
66
This link will expire in {{ expiresAtMessageKey|trans(expiresAtMessageData, 'VerifyEmailBundle') }}.
77
</p>
88

src/Resources/skeleton/resetPassword/ChangePasswordFormType.tpl.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
1111
$builder
1212
->add('plainPassword', RepeatedType::class, [
1313
'type' => PasswordType::class,
14+
'options' => [
15+
'attr' => [
16+
'autocomplete' => 'new-password',
17+
],
18+
],
1419
'first_options' => [
15-
'attr' => ['autocomplete' => 'new-password'],
1620
'constraints' => [
1721
new NotBlank([
1822
'message' => 'Please enter a password',
@@ -27,7 +31,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
2731
'label' => 'New password',
2832
],
2933
'second_options' => [
30-
'attr' => ['autocomplete' => 'new-password'],
3134
'label' => 'Repeat Password',
3235
],
3336
'invalid_message' => 'The password fields must match.',

src/Resources/skeleton/serializer/Normalizer.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function normalize($object, string $format = null, array $context = []):
2121

2222
public function supportsNormalization($data, string $format = null, array $context = []): bool
2323
{
24-
return $data instanceof \App\Entity\<?= str_replace('Normalizer', null, $class_name) ?>;
24+
return $data instanceof \App\Entity\<?= str_replace('Normalizer', '', $class_name) ?>;
2525
}
2626

2727
public function hasCacheableSupportsMethod(): bool
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?= "<?php\n" ?>
2+
3+
namespace <?= $namespace; ?>;
4+
5+
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
6+
7+
#[AsTwigComponent('<?= $short_name; ?>')]
8+
final class <?= $class_name."\n" ?>
9+
{
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?= "<?php\n" ?>
2+
3+
namespace <?= $namespace; ?>;
4+
5+
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
6+
use Symfony\UX\LiveComponent\DefaultActionTrait;
7+
8+
#[AsLiveComponent('<?= $short_name; ?>')]
9+
final class <?= $class_name."\n" ?>
10+
{
11+
use DefaultActionTrait;
12+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div{{ attributes }}>
2+
<!-- component html -->
3+
</div>

src/Resources/skeleton/validator/Constraint.tpl.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/**
88
* @Annotation
9+
*
910
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
1011
*/
1112
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]

0 commit comments

Comments
 (0)