returns the data from the given id.
public load ( string $uuid, string $webspaceKey, string $languageCode, boolean $loadGhostContent = false ) : Sulu\Component\Content\Compat\StructureInterface | ||
$uuid | string | UUID of the content |
$webspaceKey | string | Key of webspace |
$languageCode | string | Read data for given language |
$loadGhostContent | boolean | True if also a ghost page should be returned, otherwise false |
리턴 | Sulu\Component\Content\Compat\StructureInterface |
/** * @dataProvider provideSaveSnippetPage */ public function testSaveLoadSnippetPage($webspaceKey, $templateKey, $locale, $data) { foreach ($data['hotels'] as &$varName) { $varName = $this->{$varName}->getUUid(); } $req = ContentMapperRequest::create()->setType(Structure::TYPE_PAGE)->setWebspaceKey($webspaceKey)->setTemplateKey($templateKey)->setLocale($locale)->setState(StructureInterface::STATE_PUBLISHED)->setUserId(1)->setData($data); $page = $this->contentMapper->saveRequest($req); foreach ($data as $key => $value) { $this->assertEquals($value, $page->getPropertyValue($key)); } $this->assertInstanceOf(PageBridge::class, $page); $this->assertEquals($templateKey, $page->getKey()); $page = $this->contentMapper->load($page->getUuid(), $webspaceKey, $locale); $this->assertInstanceOf(PageBridge::class, $page); $this->assertEquals($templateKey, $page->getKey()); foreach ($data as $key => $value) { if ($key === 'hotels') { continue; } $this->assertEquals($value, $page->getPropertyValue($key), 'Checking property "' . $key . '"'); } $hotels = $page->getPropertyValue('hotels'); $this->assertCount(count($data['hotels']), $hotels); $this->assertEquals($data['hotels'], $hotels); }
public function testSerialize() { $pageDocument = $this->createPage(); $managedPage = $this->contentMapper->load($pageDocument->getUuid(), 'sulu_io', 'fr'); $this->assertInstanceOf(StructureBridge::class, $managedPage); $result = $this->serializer->serialize($managedPage, 'json'); return $result; }
/** * {@inheritdoc} */ public function loadSnippet($uuid, $locale = null) { if ($locale === null) { $locale = $this->requestAnalyzer->getCurrentLocalization()->getLocalization(); } try { $snippet = $this->contentMapper->load($uuid, $this->requestAnalyzer->getWebspace()->getKey(), $locale); return $this->structureResolver->resolve($snippet); } catch (DocumentNotFoundException $ex) { return; } }
/** * {@inheritdoc} */ public function warmUp($userId, $contentUuid, $webspaceKey, $locale) { $this->delete($userId, $contentUuid, $webspaceKey, $locale); $page = $this->contentMapper->load($contentUuid, $webspaceKey, $locale); $this->saveStructure($page, $userId, $contentUuid, $webspaceKey, $locale); $this->saveChanges([], $userId, $contentUuid, $webspaceKey, $locale); return $this->fetchStructure($userId, $contentUuid, $webspaceKey, $locale); }
/** * {@inheritdoc} */ public function getBreadcrumb($uuid, $webspace, $language) { $breadcrumbItems = $this->contentMapper->loadBreadcrumb($uuid, $language, $webspace); $result = []; foreach ($breadcrumbItems as $item) { $result[] = $this->contentMapper->load($item->getUuid(), $webspace, $language); } $result[] = $this->contentMapper->load($uuid, $webspace, $language); return $this->generateNavigation($result, $webspace, $language, false, null, true, false); }
/** * {@inheritdoc} */ public function resolve($uuids, $webspaceKey, $locale, $shadowLocale = null) { $snippets = []; foreach ($uuids as $uuid) { if (!array_key_exists($uuid, $this->snippetCache)) { $snippet = $this->contentMapper->load($uuid, $webspaceKey, $locale); if (!$snippet->getHasTranslation() && $shadowLocale !== null) { $snippet = $this->contentMapper->load($uuid, $webspaceKey, $shadowLocale); } $snippet->setIsShadow($shadowLocale !== null); $snippet->setShadowBaseLanguage($shadowLocale); $resolved = $this->structureResolver->resolve($snippet); $resolved['view']['template'] = $snippet->getKey(); $resolved['view']['uuid'] = $snippet->getUuid(); $this->snippetCache[$uuid] = $resolved; } $snippets[] = $this->snippetCache[$uuid]; } return $snippets; }
private function copyNode($srcLocale, $destLocale, StructureInterface $structure, $overwrite = false) { if (!$overwrite) { $destStructure = $this->contentMapper->load($structure->getUuid(), null, $destLocale, true); if (!($destStructure->getType() && $destStructure->getType()->getName() === 'ghost')) { $this->output->writeln('<info>Processing aborted: </info>' . $structure->getNodeName() . ' <comment>(use overwrite option to force)</comment>'); return; } } $this->contentMapper->copyLanguage($structure->getUuid(), $structure->getChanger(), null, $srcLocale, $destLocale, Structure::TYPE_SNIPPET); $this->output->writeln('<info>Processing: </info>' . $structure->getNodeName()); }
public function testLoadParent() { $this->contentMapper->load('321-321-321', 'sulu_test', 'en_us')->willReturn(new TestStructure('321-321-321', 'test', 1)); $extension = new ContentTwigExtension($this->contentMapper->reveal(), $this->structureResolver, $this->sessionManager->reveal(), $this->requestAnalyzer->reveal()); $result = $extension->loadParent('123-123-123'); // uuid $this->assertEquals('321-321-321', $result['uuid']); // metadata $this->assertEquals(1, $result['creator']); $this->assertEquals(1, $result['changer']); // content $this->assertEquals(['title' => 'test'], $result['content']); $this->assertEquals(['title' => []], $result['view']); }
/** * load snippet and serialize them. * * additionally cache it by id in this class */ private function loadSnippets($ids, $webspaceKey, $locale, $shadowLocale = null) { $snippets = []; foreach ($ids as $i => $ref) { if (!array_key_exists($ref, $this->snippetCache)) { $snippet = $this->contentMapper->load($ref, $webspaceKey, $locale); if (!$snippet->getHasTranslation() && $shadowLocale !== null) { $snippet = $this->contentMapper->load($ref, $webspaceKey, $shadowLocale); } $resolved = $this->structureResolver->resolve($snippet); $resolved['view']['template'] = $snippet->getKey(); $this->snippetCache[$ref] = $resolved; } $snippets[] = $this->snippetCache[$ref]; } return $snippets; }
private function copyNode($webspaceKey, $srcLocale, $destLocale, StructureInterface $structure, $overwrite = false) { if (!$overwrite) { $destStructure = $this->contentMapper->load($structure->getUuid(), $webspaceKey, $destLocale, true); if (!($destStructure->getType() && $destStructure->getType()->getName() === 'ghost')) { $this->output->writeln('<info>Processing aborted: </info>' . $structure->getPath() . ' <comment>(use overwrite option to force)</comment>'); return; } } if ($structure->getType() && $structure->getType()->getName() === 'ghost') { $this->output->writeln('<info>Processing aborted: </info>' . $structure->getPath() . ' <comment>(source language does not exist)</comment>'); return; } try { $this->contentMapper->copyLanguage($structure->getUuid(), $structure->getChanger(), $webspaceKey, $srcLocale, $destLocale); $this->output->writeln('<info>Processing: </info>' . $structure->getPath()); } catch (ResourceLocatorAlreadyExistsException $e) { $this->output->writeln(sprintf('<info>Processing aborted: </info> %s <comment>Resource Locator "%s" already exists', $structure->getPath(), $structure->getResourceLocator())); } }
/** * @param string $uuid * @return array */ public function load($uuid) { $contentStructure = $this->contentMapper->load($uuid, $this->requestAnalyzer->getWebspace()->getKey(), $this->requestAnalyzer->getCurrentLocalization()->getLocalization()); return $this->structureResolver->resolve($contentStructure); }