Exemplo n.º 1
0
 public function testStopPreview()
 {
     $data = $this->prepareData();
     $this->preview->start(1, $data[0]->getUuid(), 'sulu_io', 'en');
     $this->assertTrue($this->previewCache->contains(1, $data[0]->getUuid(), 'sulu_io', 'en'));
     $this->preview->stop(1, $data[0]->getUuid(), 'sulu_io', 'en');
     $this->assertFalse($this->previewCache->contains(1, $data[0]->getUuid(), 'sulu_io', 'en'));
 }
Exemplo n.º 2
0
 /**
  * Connection lost.
  *
  * @param ConnectionInterface $conn
  * @param MessageHandlerContext $context
  */
 public function onClose(ConnectionInterface $conn, MessageHandlerContext $context)
 {
     // get session vars
     $user = $context->get('user');
     $locale = $context->get('locale');
     $contentUuid = $context->get('content');
     $webspaceKey = $context->get('webspaceKey');
     $this->preview->stop($user, $contentUuid, $webspaceKey, $locale);
 }
Exemplo n.º 3
0
 /**
  * Stop preview session.
  *
  * @param ConnectionInterface   $from
  * @param MessageHandlerContext $context
  *
  * @return array
  *
  * @throws PreviewNotStartedException
  */
 private function stop(ConnectionInterface $from, MessageHandlerContext $context)
 {
     // check context parameters
     if (!$context->has('user')) {
         throw new PreviewNotStartedException();
     }
     // get user id
     $user = $context->get('user');
     // get session vars
     $contentUuid = $context->get('content');
     $locale = $context->get('locale');
     $webspaceKey = $context->get('webspaceKey');
     // stop preview
     $this->preview->stop($user, $contentUuid, $webspaceKey, $locale);
     $context->clear();
     return ['command' => 'start', 'content' => $contentUuid, 'msg' => 'OK'];
 }