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


PHP SessionInterface::getFlashBag方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\Session\SessionInterface::getFlashBag方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionInterface::getFlashBag方法的具体用法?PHP SessionInterface::getFlashBag怎么用?PHP SessionInterface::getFlashBag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\Session\SessionInterface的用法示例。


在下文中一共展示了SessionInterface::getFlashBag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addFlash

 /**
  * @param string $type
  * @param string $message
  */
 protected function addFlash($type, $message)
 {
     if (!$this->session) {
         $this->session = $this->getSession();
     }
     $this->session->getFlashBag()->set('notice', 'Session  saved!');
 }
开发者ID:peterAK,项目名称:pgs-sts,代码行数:11,代码来源:BaseController.php

示例2: updateSecondaryResources

 public function updateSecondaryResources(ActivityParameters $parameters, \stdClass $stepStructure)
 {
     // Store current resources to clean removed
     $existingResources = $parameters->getSecondaryResources();
     $existingResources = $existingResources->toArray();
     // Publish new resources
     $publishedResources = array();
     if (!empty($stepStructure->resources)) {
         $i = 0;
         foreach ($stepStructure->resources as $resource) {
             $resourceNode = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceNode')->findOneById($resource->resourceId);
             if (!empty($resourceNode)) {
                 $parameters->addSecondaryResource($resourceNode);
                 $publishedResources[] = $resourceNode;
             } else {
                 $warning = $this->translator->trans('warning_compl_resource_deleted', array('resourceId' => $resource->resourceId, 'resourceName' => $resource->name), "innova_tools");
                 $this->session->getFlashBag()->add('warning', $warning);
                 unset($stepStructure->resources[$i]);
             }
             $i++;
         }
     }
     // Clean removed resources
     foreach ($existingResources as $existingResource) {
         if (!in_array($existingResource, $publishedResources)) {
             $parameters->removeSecondaryResource($existingResource);
         }
     }
     return $this;
 }
开发者ID:CPASimUSante,项目名称:PathBundle,代码行数:30,代码来源:StepManager.php

示例3: publishAction

 /**
  * Publish path
  * Create all needed resources for path to be played
  * 
  * @Route(
  *     "/publish/{id}/{redirect}",
  *     name         = "innova_path_publish",
  *     requirements = {"id" = "\d+"},
  *     options      = {"expose" = true}
  * )
  * @Method({"GET", "PUT"})
  */
 public function publishAction(Path $path, $redirect = false, Request $request)
 {
     $this->pathManager->checkAccess('EDIT', $path);
     $response = array();
     try {
         $this->publishingManager->publish($path);
         // Publish success
         $response['status'] = 'OK';
         $response['messages'] = array();
         $response['data'] = json_decode($path->getStructure());
         // Send updated data
     } catch (\Exception $e) {
         // Error
         $response['status'] = 'ERROR';
         $response['messages'] = array($e->getMessage());
         $response['data'] = null;
     }
     if ($redirect) {
         // That's not an AJAX call, so display a flash message and redirect the User
         $message = 'OK' === $response['status'] ? 'publish_success' : 'publish_error';
         $this->session->getFlashBag()->add('OK' === $response['status'] ? 'success' : 'error', $this->translator->trans($message, array(), 'path_wizards'));
         return new RedirectResponse($request->headers->get('referer'));
     }
     return new JsonResponse($response);
 }
开发者ID:CPASimUSante,项目名称:PathBundle,代码行数:37,代码来源:PathController.php

示例4: testGetSetFlash

 public function testGetSetFlash()
 {
     $this->assertNull($this->session->getFlash('notice'));
     $this->assertEquals('default', $this->session->getFlash('notice', 'default'));
     $this->session->getFlashBag()->add('notice', 'foo');
     $this->session->getFlashBag()->add('notice', 'foo2');
     // test that BC works by only retrieving the first added.
     $this->assertEquals('foo', $this->session->getFlash('notice'));
     $this->assertNull($this->session->getFlash('notice'));
 }
开发者ID:laubosslink,项目名称:lab,代码行数:10,代码来源:SessionTest.php

示例5: testGetSetFlash

 public function testGetSetFlash()
 {
     set_error_handler(array($this, "deprecationErrorHandler"));
     $this->assertNull($this->session->getFlash('notice'));
     $this->assertEquals('default', $this->session->getFlash('notice', 'default'));
     $this->session->getFlashBag()->add('notice', 'foo');
     $this->session->getFlashBag()->add('notice', 'foo2');
     // test that BC works by only retrieving the first added.
     $this->assertEquals('foo', $this->session->getFlash('notice'));
     $this->assertNull($this->session->getFlash('notice'));
     restore_error_handler();
 }
开发者ID:rodionrakib,项目名称:twig,代码行数:12,代码来源:SessionTest.php

示例6: redirect

 public function redirect($url, $message = null)
 {
     if ($this->request->isXmlHttpRequest()) {
         $json = array();
         $json['redirect'] = $url;
         if ($message) {
             $json['message'] = $message;
         }
         return new JsonResponse($json);
     } else {
         if ($message) {
             $this->session->getFlashBag()->add('success', $message);
         }
         return new RedirectResponse($url);
     }
 }
开发者ID:xoeoro,项目名称:helper-bundle,代码行数:16,代码来源:HelperService.php

示例7: testFlashMessageWithCustomDomain

 /**
  * Test the flash manager get() method with a specified domain
  */
 public function testFlashMessageWithCustomDomain()
 {
     // Given
     $translator = $this->flashManager->getTranslator();
     $translator->addLoader('array', new ArrayLoader());
     $translator->addResource('array', array('my_bundle_success_message' => 'My bundle success message!'), 'en', 'MyCustomDomain');
     // When
     $this->session->getFlashBag()->set('my_bundle_success', 'my_bundle_success_message');
     $messages = $this->flashManager->get('success', 'MyCustomDomain');
     $this->session->getFlashBag()->set('my_bundle_success', 'my_bundle_success_message');
     $messagesWithoutDomain = $this->flashManager->get('success');
     // Then
     $this->assertCount(1, $messages);
     $this->assertCount(1, $messagesWithoutDomain);
     foreach ($messages as $message) {
         $this->assertEquals($message, 'My bundle success message!');
     }
     foreach ($messagesWithoutDomain as $message) {
         $this->assertEquals($message, 'my_bundle_success_message');
     }
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:24,代码来源:FlashManagerTest.php

示例8: getGlobals

 /**
  * Returns all global assignable admin template variables
  *
  * @return array
  */
 public function getGlobals()
 {
     return ['user' => $this->session->get('admin/user'), 'menu' => $this->session->get('admin/menu'), 'flashbag' => $this->session->getFlashBag()];
 }
开发者ID:jmarceli,项目名称:WellCommerce,代码行数:9,代码来源:AdminExtension.php

示例9: attachFlashBag

 protected function attachFlashBag(SessionInterface $session)
 {
     if (!$this->flashLogger->isFlashBagAttached() && $session instanceof Session) {
         $this->flashLogger->attachFlashBag($session->getFlashBag());
     }
 }
开发者ID:robbert-vdh,项目名称:bolt,代码行数:6,代码来源:FlashLoggerListener.php

示例10: getGlobals

 /**
  * {@inheritdoc}
  */
 public function getGlobals()
 {
     $scope = $this->session->get('admin/shop');
     return ['user' => $this->session->get('admin/user'), 'menu' => $this->adminMenuProvider->getMenu(), 'shops' => $this->session->get('admin/shops'), 'activeContextId' => $scope['id'], 'flashbag' => $this->session->getFlashBag()];
 }
开发者ID:pguso,项目名称:WellCommerce,代码行数:8,代码来源:AdminExtension.php

示例11: reset

 /**
  * Resets the flash bag.
  */
 public function reset()
 {
     $this->session->getFlashBag()->clear();
 }
开发者ID:mgdigital,项目名称:bootstrap-bundle,代码行数:7,代码来源:FlashMessage.php

示例12: addToSession

 /**
  * @param string $key
  * @param string $value
  *
  * @return void
  */
 protected function addToSession($key, $value)
 {
     $this->session->getFlashBag()->add($key, $value);
 }
开发者ID:spryker,项目名称:Messenger,代码行数:10,代码来源:SessionMessageTray.php

示例13: __construct

 protected function __construct(\Symfony\Component\HttpFoundation\Session\SessionInterface $session)
 {
     $session->start();
     $this->flashBag = $session->getFlashBag();
     return $this;
 }
开发者ID:benjamincrozat,项目名称:easy-flash-messages,代码行数:6,代码来源:plugin.php

示例14: addFlash

 /**
  * @param string $type
  * @param string $message
  */
 protected function addFlash($type, $message)
 {
     $this->session->getFlashBag()->add($type, $message);
 }
开发者ID:radmar,项目名称:ElnurAbstractControllerBundle,代码行数:8,代码来源:AbstractController.php

示例15: addUserFlash

 /**
  * Adds a flash message to the given session.
  *
  * @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
  * @param string $type
  * @param string $message
  */
 protected function addUserFlash(SessionInterface $session, $type, $message)
 {
     $session->getFlashBag()->add($type, $message);
 }
开发者ID:gibilogic,项目名称:crud-bundle,代码行数:11,代码来源:FlashableTrait.php


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