[New routing] Refactoring verify shop user#18879
[New routing] Refactoring verify shop user#18879loic425 wants to merge 3 commits intoSylius:new-routingfrom
Conversation
loic425
commented
Feb 26, 2026
| Q | A |
|---|---|
| Branch? | new-routing |
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Related tickets | partially #18212 |
| License | MIT |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❗ Preview Environment deployment failed on BunnyshellSee: Environment Details | Pipeline Logs Check https://github.com/Sylius/Sylius/actions/runs/22486940304 for details. Available commands:
|
464301f to
006bf6d
Compare
...Sylius/Bundle/CoreBundle/CommandHandler/Shop/Account/SendAccountRegistrationEmailHandler.php
Outdated
Show resolved
Hide resolved
006bf6d to
939ccd6
Compare
|
|
||
| namespace Sylius\Bundle\CoreBundle\CommandHandler\Shop\Account; | ||
|
|
||
| use InvalidArgumentException; |
There was a problem hiding this comment.
| use InvalidArgumentException; |
src/Sylius/Bundle/CoreBundle/CommandHandler/Shop/Account/VerifyShopUserHandler.php
Outdated
Show resolved
Hide resolved
| use Sylius\Bundle\CoreBundle\Command\Shop\Account\VerifyShopUser; | ||
| use Sylius\Bundle\CoreBundle\CommandDispatcher\ResetPasswordDispatcherInterface; | ||
| use Sylius\Bundle\CoreBundle\Provider\FlashBagProvider; | ||
| use Sylius\Bundle\UserBundle\Form\Model\PasswordReset; | ||
| use Sylius\Bundle\UserBundle\Form\Type\UserResetPasswordType; | ||
| use Sylius\Component\Channel\Context\ChannelContextInterface; | ||
| use Sylius\Component\Locale\Context\LocaleContextInterface; | ||
| use Sylius\Component\User\Model\UserInterface; | ||
| use Sylius\Component\User\Repository\UserRepositoryInterface; | ||
| use Symfony\Component\Form\FormFactoryInterface; | ||
| use Symfony\Component\HttpFoundation\RedirectResponse; | ||
| use Symfony\Component\HttpFoundation\Request; | ||
| use Symfony\Component\HttpFoundation\RequestStack; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
| use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
| use Symfony\Component\Messenger\MessageBusInterface; | ||
| use Symfony\Component\Routing\RouterInterface; | ||
| use Symfony\Contracts\Translation\TranslatorInterface; | ||
| use Twig\Environment; |
There was a problem hiding this comment.
Some of these aren't used at all
8833ef1 to
1835a6c
Compare
Co-authored-by: Jan Góralski <jan.wojciech.goralski@gmail.com>
1835a6c to
4e91066
Compare
|
@NoResponseMate Flash messages are already translated in the UI. <div {{ sylius_test_html_attribute('flash-messages') }}>
{% if flash is iterable %}
{{ flash.message|trans(flash.parameters, 'flashes') }}
{% else %}
{{ flash|trans({}, 'flashes') }}
{% endif %}
</div> |
src/Sylius/Bundle/ShopBundle/Controller/VerifyShopUserAction.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Would be cool to sync arguments order between VerifyShopUser and SendAccountRegistrationEmail and future commands.
Right now it's like so, but putting subject on first line and channelCode, localeCode in this order would look better.
--- public readonly string $shopUserEmail,
--- public readonly string $localeCode,
--- public readonly string $channelCode,
+++ public readonly string $channelCode,
+++ public readonly string $localeCode,
+++ public readonly string $token,| public readonly string $shopUserEmail, | ||
| public readonly string $localeCode, | ||
| public readonly string $channelCode, |
There was a problem hiding this comment.
| public readonly string $shopUserEmail, | |
| public readonly string $localeCode, | |
| public readonly string $channelCode, | |
| public readonly string $shopUserEmail, | |
| public readonly string $channelCode, | |
| public readonly string $localeCode, |
| public readonly string $channelCode, | ||
| public readonly string $localeCode, | ||
| public readonly string $token, |
There was a problem hiding this comment.
| public readonly string $channelCode, | |
| public readonly string $localeCode, | |
| public readonly string $token, | |
| public readonly string $token, | |
| public readonly string $channelCode, | |
| public readonly string $localeCode, |
| use Symfony\Component\Messenger\Attribute\AsMessageHandler; | ||
|
|
||
| #[AsMessageHandler] | ||
| final class SendAccountRegistrationEmailHandler |
There was a problem hiding this comment.
| final class SendAccountRegistrationEmailHandler | |
| final readonly class SendAccountRegistrationEmailHandler |
| if (null === $shopUser) { | ||
| throw new \InvalidArgumentException( | ||
| sprintf('There is no shop user with %s email', $command->shopUserEmail), | ||
| ); | ||
| } |
There was a problem hiding this comment.
Why not use Assert as usual?
| if (null === $shopUser) { | |
| throw new \InvalidArgumentException( | |
| sprintf('There is no shop user with %s email', $command->shopUserEmail), | |
| ); | |
| } | |
| Assert::notNull($shopUser, sprintf('There is no shop user with %s email', $command->shopUserEmail)); |
| if (null === $channel) { | ||
| throw new \InvalidArgumentException( | ||
| sprintf('There is no channel with %s code', $command->channelCode), | ||
| ); | ||
| } |
| return; | ||
| } | ||
|
|
||
| $this->accountRegistrationEmailManager->sendAccountRegistrationEmail($shopUser, $channel, $command->localeCode); |
There was a problem hiding this comment.
Missing check, that localeCode matches provided channel.
| if (null === $user) { | ||
| throw new \InvalidArgumentException( | ||
| sprintf('There is no shop user with %s email verification token', $command->token), | ||
| ); | ||
| } |
| $user->enable(); | ||
|
|
||
| $this->commandBus->dispatch( | ||
| new SendAccountRegistrationEmail($user->getEmail(), $command->localeCode, $command->channelCode), |
There was a problem hiding this comment.
It's okay to skip channelCode/localeCode asserts as long as SendAccountRegistrationEmail checks them.
There was a problem hiding this comment.
P.S. We should dispatch events, like ShopUserVerified, not hardcode command calls.