Example #1
0
 public function testGetJsonData()
 {
     $data = ['test' => true];
     $this->windowState->setData($data);
     $this->assertEquals($data, $this->windowState->getData());
     $this->assertEquals(json_encode($data), $this->windowState->getJsonData());
 }
 /** {@inheritdoc} */
 public function load(ObjectManager $manager)
 {
     $user = $manager->getRepository('OroUserBundle:User')->findOneBy(['username' => 'admin']);
     $state = new WindowsState();
     $state->setUser($user)->setData(['cleanUrl' => '/path']);
     $manager->persist($state);
     $manager->flush();
     $this->setReference('windows_state.admin', $state);
 }
 /**
  * REST POST
  *
  * @ApiDoc(
  *  description="Add Windows State",
  *  resource=true
  * )
  * @return Response
  */
 public function postAction()
 {
     $postArray = $this->getPost();
     /** @var $user UserInterface */
     $user = $this->getUser();
     $postArray['user'] = $user;
     /** @var $entity \Oro\Bundle\WindowsBundle\Entity\WindowsState */
     $entity = new WindowsState();
     $entity->setData($postArray['data']);
     $entity->setUser($user);
     $manager = $this->getManager();
     $manager->persist($entity);
     $manager->flush();
     return $this->handleView($this->view(['id' => $entity->getId()], Codes::HTTP_CREATED));
 }
Example #4
0
 /**
  * Renders fragment by window state.
  *
  * @param \Twig_Environment $environment
  * @param WindowsState $windowState
  *
  * @return string
  */
 public function renderFragment(\Twig_Environment $environment, WindowsState $windowState)
 {
     $result = '';
     $windowState->setRenderedSuccessfully(false);
     $data = $windowState->getData();
     if (isset($data['cleanUrl'])) {
         if (isset($data['type'])) {
             $wid = isset($data['wid']) ? $data['wid'] : $this->getUniqueIdentifier();
             $uri = $this->getUrlWithContainer($data['cleanUrl'], $data['type'], $wid);
         } else {
             $uri = $data['cleanUrl'];
         }
     } else {
         return $result;
     }
     try {
         /** @var HttpKernelExtension $httpKernelExtension */
         $httpKernelExtension = $environment->getExtension('http_kernel');
         $result = $httpKernelExtension->renderFragment($uri);
         $windowState->setRenderedSuccessfully(true);
         return $result;
     } catch (NotFoundHttpException $e) {
         $this->em->remove($windowState);
         $this->em->flush($windowState);
     }
     return $result;
 }
 /**
  * @param array $data
  * @return WindowsState
  */
 protected function createWindowState(array $data = [])
 {
     $state = new WindowsState();
     $state->setData($data);
     return $state;
 }
 public function testDoPreUpdate()
 {
     $item = new WindowsState();
     $item->doPreUpdate();
     $this->assertInstanceOf('DateTime', $item->getUpdatedAt());
 }