getFlashMessage() public method

public getFlashMessage ( null $message ) : mixed | null
$message null
return mixed | null
Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function addSuccessFlash(RequestConfiguration $requestConfiguration, $actionName, ResourceInterface $resource = null)
 {
     $metadata = $requestConfiguration->getMetadata();
     $flashMessage = $requestConfiguration->getFlashMessage($actionName);
     $translatedMessage = $this->translateMessage($flashMessage, $metadata);
     if ($flashMessage === $translatedMessage) {
         $translatedMessage = $this->translateMessage(sprintf('sylius.resource.%s', $actionName), $metadata);
     }
     $this->session->getBag('flashes')->add('success', $translatedMessage);
 }
Esempio n. 2
0
 function it_adds_custom_message(SessionInterface $session, TranslatorBagInterface $translator, MessageCatalogueInterface $messageCatalogue, FlashBagInterface $flashBag, MetadataInterface $metadata, RequestConfiguration $requestConfiguration, ResourceInterface $resource)
 {
     $metadata->getApplicationName()->willReturn('app');
     $metadata->getHumanizedName()->willReturn('book');
     $requestConfiguration->getMetadata()->willReturn($metadata);
     $requestConfiguration->getFlashMessage('send')->willReturn('app.book.send');
     $translator->getCatalogue('en')->willReturn($messageCatalogue);
     $messageCatalogue->has('app.book.send', 'flashes')->willReturn(true);
     $session->getBag('flashes')->willReturn($flashBag);
     $flashBag->add('success', 'app.book.send')->shouldBeCalled();
     $this->addSuccessFlash($requestConfiguration, 'send', $resource);
 }
Esempio n. 3
0
 function it_uses_default_translation_if_message_is_not_translated(SessionInterface $session, FlashBagInterface $flashBag, TranslatorInterface $translator, MetadataInterface $metadata, RequestConfiguration $requestConfiguration, ResourceInterface $resource)
 {
     $metadata->getApplicationName()->willReturn('sylius');
     $metadata->getName()->willReturn('product');
     $metadata->getHumanizedName()->willReturn('product');
     $requestConfiguration->getMetadata()->willReturn($metadata);
     $requestConfiguration->isHtmlRequest()->willReturn(true);
     $session->getBag('flashes')->willReturn($flashBag);
     $requestConfiguration->getFlashMessage(ResourceActions::CREATE)->willReturn('sylius.product.create');
     $translator->trans('sylius.product.create', ['%resource%' => 'Product'], 'flashes')->willReturn('sylius.product.create');
     $translator->trans('sylius.resource.create', ['%resource%' => 'Product'], 'flashes')->willReturn('Product has been successfully created.');
     $flashBag->add('success', 'Product has been successfully created.')->shouldBeCalled();
     $this->addSuccessFlash($requestConfiguration, ResourceActions::CREATE, $resource);
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function addSuccessFlash(RequestConfiguration $requestConfiguration, $actionName, ResourceInterface $resource = null)
 {
     $metadata = $requestConfiguration->getMetadata();
     $metadataName = $metadata->getHumanizedName();
     $message = $requestConfiguration->getFlashMessage($actionName);
     if (false === $message) {
         return;
     }
     if ($this->isTranslationDefined($message, $this->defaultLocale)) {
         $this->addFlash('success', $message);
         return;
     }
     $this->addFlash('success', $this->getResourceMessage($actionName), ['%resource%' => ucfirst($metadataName)]);
 }