load() public method

public load ( $uuid, $webspaceKey, $locale, $loadGhostContent = false )
Example #1
0
 /**
  * Return snippets identified by the given UUIDs.
  *
  * UUIDs which fail to resolve to a snippet will be ignored.
  *
  * @param array  $uuids
  * @param string $languageCode
  *
  * @return Snippet[]
  */
 public function getSnippetsByUuids(array $uuids = [], $languageCode)
 {
     $snippets = [];
     foreach ($uuids as $uuid) {
         try {
             $snippet = $this->contentMapper->load($uuid, null, $languageCode);
             $snippets[] = $snippet;
         } catch (DocumentNotFoundException $e) {
             // ignore not found items
         }
     }
     return $snippets;
 }
Example #2
0
 /**
  * It should return the resource locators including the reosurce locator
  * of the shadow page.
  */
 public function testGetResourceLocatorsWithShadow()
 {
     $page = $this->documentManager->create('page');
     $page->setStructureType('overview');
     $page->setTitle('Beschreibung');
     $page->setResourceSegment('/beschreibung');
     $page->setWorkflowStage(WorkflowStage::PUBLISHED);
     $this->documentManager->persist($page, 'de', ['parent_path' => '/cmf/sulu_io/contents']);
     $this->documentManager->flush();
     $page->setTitle('Description');
     $page->setResourceSegment('/description');
     $page->setWorkflowStage(WorkflowStage::TEST);
     $this->documentManager->persist($page, 'en', ['parent_path' => '/cmf/sulu_io/contents']);
     $this->documentManager->flush();
     $page->setShadowLocaleEnabled(true);
     $page->setShadowLocale('de');
     $this->documentManager->persist($page, 'en', ['parent_path' => '/cmf/sulu_io/contents']);
     $this->documentManager->flush();
     $content = $this->mapper->load($page->getUuid(), 'sulu_io', 'en');
     $urls = $content->getUrls();
     $this->assertArrayHasKey('en', $urls);
     $this->assertEquals('/description', $urls['en']);
     $this->assertArrayNotHasKey('en_us', $urls);
     $this->assertArrayHasKey('de', $urls);
     $this->assertEquals('/beschreibung', $urls['de']);
     $this->assertArrayNotHasKey('de_at', $urls);
     $this->assertArrayNotHasKey('es', $urls);
 }
Example #3
0
 /**
  * Return a response for the case where there is an referential integrity violation.
  *
  * It will return a 409 (Conflict) response with an array of structures which reference
  * the node and an array of "other" nodes (i.e. non-structures) which reference the node.
  *
  * @param string $webspace
  * @param NodeInterface[] $references
  *
  * @return Response
  */
 private function getReferentialIntegrityResponse($webspace, $references)
 {
     $data = ['structures' => [], 'other' => []];
     foreach ($references as $reference) {
         if ($reference->getParent()->isNodeType('sulu:page')) {
             $content = $this->contentMapper->load($reference->getParent()->getIdentifier(), $webspace, $this->languageCode, true);
             $data['structures'][] = $content->toArray();
         } else {
             $data['other'] = $reference->getPath();
         }
     }
     return new JsonResponse($data, 409);
 }
Example #4
0
 /**
  * Return a response for the case where there is an referential integrity violation.
  *
  * It will return a 409 (Conflict) response with an array of structures which reference
  * the node and an array of "other" nodes (i.e. non-structures) which reference the node.
  *
  * @param string $webspace
  * @param NodeInterface[] $references
  * @param string $uuid
  *
  * @return Response
  */
 private function getReferentialIntegrityResponse($webspace, $references, $uuid, $locale)
 {
     $data = ['structures' => [], 'other' => [], 'isDefault' => $this->defaultSnippetManager->isDefault($uuid)];
     foreach ($references as $reference) {
         if ($reference->getParent()->isNodeType('sulu:page')) {
             $content = $this->contentMapper->load($reference->getParent()->getIdentifier(), $webspace, $locale, true);
             $data['structures'][] = $content->toArray();
         } else {
             $data['other'][] = $reference->getParent()->getPath();
         }
     }
     return new JsonResponse($data, 409);
 }