protected function setUp() { $this->contentMapper = $this->getContainer()->get('sulu.content.mapper'); $this->requestAnalyzer = $this->getContainer()->get('sulu_core.webspace.request_analyzer'); $this->structureResolver = $this->getContainer()->get('sulu_website.resolver.structure'); $this->requestAnalyzer->setWebspaceKey('sulu_io'); $this->requestAnalyzer->setLocalizationCode('en'); $this->initPhpcr(); $this->extension = new SnippetTwigExtension($this->contentMapper, $this->requestAnalyzer, $this->structureResolver); }
/** * 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)]; }