public function addFlash(PurchaseCompleteEvent $event) { switch ($event->getSubject()->getState()) { case PaymentInterface::STATE_COMPLETED: $type = 'success'; $message = 'sylius.checkout.success'; break; case PaymentInterface::STATE_PROCESSING: case PaymentInterface::STATE_PENDING: $type = 'notice'; $message = 'sylius.checkout.processing'; break; case PaymentInterface::STATE_NEW: $type = 'notice'; $message = 'sylius.checkout.new'; break; case PaymentInterface::STATE_VOID: case PaymentInterface::STATE_CANCELLED: $type = 'notice'; $message = 'sylius.checkout.canceled'; break; case PaymentInterface::STATE_FAILED: $type = 'error'; $message = 'sylius.checkout.failed'; break; default: $type = 'error'; $message = 'sylius.checkout.unknown'; break; } $this->session->getBag('flashes')->add($type, $this->translator->trans($message, [], 'flashes')); }
function let(CartProviderInterface $cartProvider, UrlGeneratorInterface $router, SessionInterface $session, FlashBagInterface $flashBag, TranslatorInterface $translator, PurchaseCompleteEvent $event, PaymentInterface $payment) { $this->beConstructedWith($cartProvider, $router, $session, $translator, 'sylius_checkout_payment'); $session->getBag('flashes')->willReturn($flashBag); $event->getSubject()->willReturn($payment); $router->generate('sylius_checkout_payment')->willReturn('/payment'); }