/** * {@inheritdoc} */ public function onClose(ConnectionInterface $conn, MessageHandlerContext $context) { $this->preview->stop($context->get('previewToken')); $context->clear(); }
/** * 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); }
/** * Updates properties of current session content. * * @param ConnectionInterface $from * @param MessageHandlerContext $context * @param array $msg * * @return array * * @throws PreviewNotStartedException * @throws MissingParameterException */ private function update(ConnectionInterface $from, MessageHandlerContext $context, $msg) { // check context parameters if (!$context->has('content') && !$context->has('locale') && !$context->has('webspaceKey') && !$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'); // init msg vars if (!array_key_exists('data', $msg) && is_array($msg['data'])) { throw new MissingParameterException('data'); } $changes = $msg['data']; $this->requestAnalyzer->setWebspaceKey($webspaceKey); $this->requestAnalyzer->setLocalizationCode($locale); foreach ($changes as $property => $data) { // update property $this->preview->updateProperty($user, $contentUuid, $webspaceKey, $locale, $property, $data); } return ['command' => 'update', 'content' => $contentUuid, 'data' => $this->preview->getChanges($user, $contentUuid, $webspaceKey, $locale)]; }