Deprecation: since 1.0-? use the DocumentManager instead
Inheritance: implements Sulu\Component\Content\Mapper\ContentMapperInterface
Example #1
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 #2
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 #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
  * @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);
 }
Example #4
0
 private function saveStartPage($data, $templateKey, $webspaceKey, $locale, $userId)
 {
     return $this->mapper->save($data, $templateKey, $webspaceKey, $locale, $userId, true, $this->getHomeUuid(), null, WorkflowStage::PUBLISHED, null, null, 'home');
 }
 /**
  * @expectedException Sulu\Component\DocumentManager\Exception\DocumentNotFoundException
  * @expectedExceptionMessage Requested document of type "page" but got
  */
 public function testUpdatePageWrongType()
 {
     $req = ContentMapperRequest::create()->setUuid($this->snippet1->getUuid())->setType(Structure::TYPE_PAGE)->setWebspaceKey('sulu_io')->setTemplateKey('test_page')->setLocale('de')->setState(StructureInterface::STATE_PUBLISHED)->setUserId(1)->setData(['title' => 'Foo']);
     $this->contentMapper->saveRequest($req);
 }
Example #6
0
 /**
  * Return snippets.
  *
  * If $type is given then only return the snippets of that type.
  *
  * @param string $languageCode
  * @param string $type         Optional snippet type
  * @param int    $offset       Optional offset
  * @param int    $max          Optional max
  * @param string $search
  * @param string $sortBy
  * @param string $sortOrder
  *
  * @throws \InvalidArgumentException
  *
  * @return Snippet[]
  */
 public function getSnippets($languageCode, $type = null, $offset = null, $max = null, $search = null, $sortBy = null, $sortOrder = null)
 {
     $query = $this->getSnippetsQuery($languageCode, $type, $offset, $max, $search, $sortBy, $sortOrder);
     return $this->contentMapper->loadByQuery($query, $languageCode, null, false, true);
 }
Example #7
0
 /**
  * Copy snippet from src-locale to dest-locale.
  *
  * @param string $uuid
  * @param int $userId
  * @param string $srcLocale
  * @param string $destLocales
  *
  * @return SnippetBridge
  */
 public function copyLocale($uuid, $userId, $srcLocale, $destLocales)
 {
     return $this->contentMapper->copyLanguage($uuid, $userId, null, $srcLocale, $destLocales, Structure::TYPE_SNIPPET);
 }