当前位置: 首页>>代码示例>>PHP>>正文


PHP RequestConfiguration::getFlashMessage方法代码示例

本文整理汇总了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);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:13,代码来源:FlashHelper.php

示例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);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:12,代码来源:FlashHelperSpec.php

示例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);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:14,代码来源:FlashHelperSpec.php

示例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)]);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:17,代码来源:FlashHelper.php


注:本文中的Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration::getFlashMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。