/** * {@inheritdoc} */ public function render($userId, $contentUuid, $webspaceKey, $locale, $partial = false, $property = null) { if (!$this->previewCache->contains($userId, $contentUuid, $webspaceKey, $locale)) { throw new PreviewNotFoundException($userId, $contentUuid); } /** @var StructureInterface $content */ $content = $this->previewCache->fetchStructure($userId, $contentUuid, $webspaceKey, $locale); return $this->renderStructure($content, $partial, $property); }
public function testUpdateSequence() { $data = $this->prepareData(); $this->preview->start(1, $data[0]->getUuid(), 'sulu_io', 'en'); $this->preview->updateProperty(1, $data[0]->getUuid(), 'sulu_io', 'en', 'block,0,article,0', 'New-Block-Article-1-1'); $this->preview->updateProperty(1, $data[0]->getUuid(), 'sulu_io', 'en', 'block,0,article,1', 'New-Block-Article-1-2'); $this->preview->updateProperty(1, $data[0]->getUuid(), 'sulu_io', 'en', 'block,0,title', 'New-Block-Title-1'); $this->preview->updateProperty(1, $data[0]->getUuid(), 'sulu_io', 'en', 'block,1,title', 'New-Block-Title-2'); $changes = $this->preview->getChanges(1, $data[0]->getUuid(), 'sulu_io', 'en'); // check result $this->assertEquals(1, sizeof($changes['block,0'])); $this->assertEquals("\n<h1 property=\"title\">New-Block-Title-1</h1>\n" . "<ul>\n" . "<li property=\"article\">New-Block-Article-1-1</li>\n" . "<li property=\"article\">New-Block-Article-1-2</li>\n" . '</ul>', $changes['block,0'][0]); $this->assertEquals(1, sizeof($changes['block,1'])); $this->assertEquals("\n<h1 property=\"title\">New-Block-Title-2</h1>\n" . "<ul>\n" . "<li property=\"article\">Block-Article-2-1</li>\n" . "<li property=\"article\">Block-Article-2-2</li>\n" . '</ul>', $changes['block,1'][0]); // check cache $this->assertTrue($this->previewCache->contains(1, $data[0]->getUuid(), 'sulu_io', 'en')); $content = $this->previewCache->fetchStructure(1, $data[0]->getUuid(), 'sulu_io', 'en'); $this->assertEquals([['type' => 'type1', 'title' => 'New-Block-Title-1', 'article' => ['New-Block-Article-1-1', 'New-Block-Article-1-2']], ['type' => 'type1', 'title' => 'New-Block-Title-2', 'article' => ['Block-Article-2-1', 'Block-Article-2-2']]], $content->getPropertyValue('block')); }