コード例 #1
0
 /**
  * Renders fragment by window state.
  *
  * @param \Twig_Environment $environment
  * @param AbstractWindowsState $windowState
  *
  * @return string
  */
 public function renderFragment(\Twig_Environment $environment, AbstractWindowsState $windowState)
 {
     $result = '';
     $scheduleDelete = false;
     $windowState->setRenderedSuccessfully(false);
     try {
         $uri = $this->windowsStateRequestManager->getUri($windowState->getData());
         /** @var HttpKernelExtension $httpKernelExtension */
         $httpKernelExtension = $environment->getExtension('http_kernel');
         $result = $httpKernelExtension->renderFragment($uri);
         $windowState->setRenderedSuccessfully(true);
         return $result;
     } catch (NotFoundHttpException $e) {
         $scheduleDelete = true;
     } catch (\InvalidArgumentException $e) {
         $scheduleDelete = true;
     }
     if ($scheduleDelete) {
         try {
             $this->windowsStateManagerRegistry->getManager()->deleteWindowsState($windowState->getId());
         } catch (AccessDeniedException $e) {
             return $result;
         }
     }
     return $result;
 }
コード例 #2
0
 public function testGetWindowsState()
 {
     $user = new User();
     $windowStateId = 42;
     $windowState = $this->createWindowState(['cleanUrl' => 'foo']);
     $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $token->expects($this->once())->method('getUser')->willReturn($user);
     $this->tokenStorage->expects($this->once())->method('getToken')->willReturn($token);
     $repo = $this->getMockBuilder('Oro\\Bundle\\WindowsBundle\\Entity\\Repository\\WindowsStateRepository')->disableOriginalConstructor()->getMock();
     $this->doctrineHelper->expects($this->once())->method('getEntityRepository')->willReturn($repo);
     $repo->expects($this->once())->method('findBy')->with(['user' => $user, 'id' => $windowStateId])->willReturn($windowState);
     $this->requestStateManager->expects($this->never())->method($this->anything());
     $this->assertSame($windowState, $this->manager->getWindowsState($windowStateId));
 }
コード例 #3
0
 /**
  * @param int $windowId
  * @return bool
  */
 public function updateWindowsState($windowId)
 {
     return (bool) $this->getRepository()->update($this->getUser(), $this->filterId($windowId), $this->requestStateManager->getData());
 }
コード例 #4
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage cleanUrl is missing
  */
 public function testDataEmpty()
 {
     $this->manager->getUri([]);
 }