本文整理汇总了PHP中Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration::getFlashMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestConfiguration::getFlashMessage方法的具体用法?PHP RequestConfiguration::getFlashMessage怎么用?PHP RequestConfiguration::getFlashMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration
的用法示例。
在下文中一共展示了RequestConfiguration::getFlashMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addSuccessFlash
/**
* {@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);
}
示例2:
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);
}
示例3:
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);
}
示例4: addSuccessFlash
/**
* {@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)]);
}