/**
* 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' => 'stop', 'content' => $contentUuid, 'msg' => 'OK'];
}