コード例 #1
0
 /**
  * Save messages from flash-bag service to flash-bag cookie.
  *
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST !== $event->getRequestType() || $event->getRequest()->isXmlHttpRequest()) {
         return;
     }
     if (!$this->flashBagService->isDirty()) {
         return;
     }
     $messages = $this->flashBagService->all();
     $this->flashBagCookie->setValue($messages);
     $response = $event->getResponse();
     $response->headers->setCookie($this->flashBagCookie->toCookie());
 }
コード例 #2
0
 /**
  * Check DirtyFlashBag::setAll marks service as dirty.
  */
 public function testSetAll()
 {
     $service = new DirtyFlashBag();
     $service->setAll(['test']);
     $this->assertTrue($service->isDirty());
 }