mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57:12 +00:00
Apply suggestions from code review
Co-authored-by: Jan Góralski <jan.wojciech.goralski@gmail.com>
This commit is contained in:
parent
d02ec94d42
commit
c462b1a21d
6 changed files with 8 additions and 27 deletions
|
|
@ -13,7 +13,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\CommandHandler\Shop\Account;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Sylius\Bundle\CoreBundle\Command\Shop\Account\SendAccountRegistrationEmail;
|
||||
use Sylius\Bundle\CoreBundle\Command\Shop\Account\VerifyShopUser;
|
||||
use Sylius\Component\Core\Model\ShopUserInterface;
|
||||
|
|
@ -39,7 +38,7 @@ final readonly class VerifyShopUserHandler
|
|||
/** @var ShopUserInterface|null $user */
|
||||
$user = $this->shopUserRepository->findOneBy(['emailVerificationToken' => $command->token]);
|
||||
if (null === $user) {
|
||||
throw new InvalidArgumentException(
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('There is no shop user with %s email verification token', $command->token),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\ShopBundle\Controller;
|
||||
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Sylius\Bundle\CoreBundle\Provider\FlashBagProvider;
|
||||
use Sylius\Bundle\OrderBundle\Resetter\CartChangesResetterInterface;
|
||||
use Sylius\Bundle\ShopBundle\Form\Type\CartType;
|
||||
use Sylius\Component\Order\Context\CartContextInterface;
|
||||
|
|
@ -25,8 +26,6 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\FlashBagAwareSessionInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Twig\Environment;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
|
@ -84,10 +83,6 @@ final readonly class CartCheckoutAction
|
|||
|
||||
private function addErrorNotification(string $message): void
|
||||
{
|
||||
$session = $this->requestStack->getSession();
|
||||
|
||||
Assert::isInstanceOf($session, FlashBagAwareSessionInterface::class);
|
||||
|
||||
$session->getFlashBag()->add('error', $message);
|
||||
FlashBagProvider::getFlashBag($this->requestStack)->add('error', $message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ final readonly class RequestPasswordResetTokenAction
|
|||
private RouterInterface $router,
|
||||
private FormFactoryInterface $formFactory,
|
||||
private MessageBusInterface $messageBus,
|
||||
private TranslatorInterface $translator,
|
||||
private RequestStack $requestStack,
|
||||
) {
|
||||
}
|
||||
|
|
@ -70,6 +69,6 @@ final readonly class RequestPasswordResetTokenAction
|
|||
|
||||
private function addSuccessNotification(): void
|
||||
{
|
||||
FlashBagProvider::getFlashBag($this->requestStack)->add('success', $this->translator->trans('sylius.user.reset_password_request', [], 'flashes'));
|
||||
FlashBagProvider::getFlashBag($this->requestStack)->add('success', 'sylius.user.reset_password_request');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ final readonly class ResetPasswordAction
|
|||
private RouterInterface $router,
|
||||
private FormFactoryInterface $formFactory,
|
||||
private UserRepositoryInterface $userRepository,
|
||||
private TranslatorInterface $translator,
|
||||
private RequestStack $requestStack,
|
||||
private ResetPasswordDispatcherInterface $resetPasswordDispatcher,
|
||||
private string $tokenTtl,
|
||||
|
|
@ -86,11 +85,11 @@ final readonly class ResetPasswordAction
|
|||
|
||||
private function addSuccessNotification(): void
|
||||
{
|
||||
FlashBagProvider::getFlashBag($this->requestStack)->add('success', $this->translator->trans('sylius.user.reset_password', [], 'flashes'));
|
||||
FlashBagProvider::getFlashBag($this->requestStack)->add('success', 'sylius.user.reset_password');
|
||||
}
|
||||
|
||||
private function addErrorNotification(): void
|
||||
{
|
||||
FlashBagProvider::getFlashBag($this->requestStack)->add('error', $this->translator->trans('sylius.user.expire_password_reset_token', [], 'flashes'));
|
||||
FlashBagProvider::getFlashBag($this->requestStack)->add('error', 'sylius.user.expire_password_reset_token');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,24 +14,17 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\ShopBundle\Controller;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
|
|
@ -41,7 +34,6 @@ final readonly class VerifyShopUserAction
|
|||
public function __construct(
|
||||
private RouterInterface $router,
|
||||
private UserRepositoryInterface $userRepository,
|
||||
private TranslatorInterface $translator,
|
||||
private RequestStack $requestStack,
|
||||
private ChannelContextInterface $channelContext,
|
||||
private LocaleContextInterface $localeContext,
|
||||
|
|
@ -75,11 +67,11 @@ final readonly class VerifyShopUserAction
|
|||
|
||||
private function addSuccessNotification(): void
|
||||
{
|
||||
FlashBagProvider::getFlashBag($this->requestStack)->add('success', $this->translator->trans('sylius.user.verify_email', [], 'flashes'));
|
||||
FlashBagProvider::getFlashBag($this->requestStack)->add('success', 'sylius.user.verify_email');
|
||||
}
|
||||
|
||||
private function addErrorNotification(): void
|
||||
{
|
||||
FlashBagProvider::getFlashBag($this->requestStack)->add('error', $this->translator->trans('sylius.user.verify_email_by_invalid_token', [], 'flashes'));
|
||||
FlashBagProvider::getFlashBag($this->requestStack)->add('error', 'sylius.user.verify_email_by_invalid_token');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,6 @@ return static function (ContainerConfigurator $container) {
|
|||
service('router.default'),
|
||||
service('form.factory'),
|
||||
service('sylius.repository.shop_user'),
|
||||
service('translator'),
|
||||
service('request_stack'),
|
||||
service('sylius.command_dispatcher.reset_password.shop'),
|
||||
param('sylius.shop_user.token.password_reset.ttl'),
|
||||
|
|
@ -142,7 +141,6 @@ return static function (ContainerConfigurator $container) {
|
|||
service('router.default'),
|
||||
service('form.factory'),
|
||||
service('sylius.command_bus'),
|
||||
service('translator'),
|
||||
service('request_stack'),
|
||||
])
|
||||
->tag('controller.service_arguments')
|
||||
|
|
@ -153,7 +151,6 @@ return static function (ContainerConfigurator $container) {
|
|||
->args([
|
||||
service('router.default'),
|
||||
service('sylius.repository.shop_user'),
|
||||
service('translator'),
|
||||
service('request_stack'),
|
||||
service('sylius.context.channel'),
|
||||
service('sylius.context.locale'),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue