/** * 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); }
public function testRun() { $this->initPhpcr(); $snippet = $this->documentManager->create('snippet'); $snippet->setStructureType('car'); $snippet->setTitle('Hallo'); $snippet->getStructure()->bind(['description' => 'This is a perfect description.']); $this->documentManager->persist($snippet, 'en', ['parent_path' => '/cmf/snippets/car']); $this->documentManager->flush(); $this->tester->execute(['srcLocale' => 'en', 'destLocale' => 'de']); $output = $this->tester->getDisplay(); $this->assertContains('Done', $output); $this->documentRegistry->clear(); $resultEN = $this->documentManager->find($snippet->getUuid(), 'en'); $resultDE = $this->documentManager->find($snippet->getUuid(), 'de'); $this->assertEquals('Hallo', $resultDE->getTitle()); $this->assertEquals('Hallo', $resultEN->getTitle()); $this->assertEquals('This is a perfect description.', $resultDE->getStructure()->getProperty('description')->getValue()); $this->assertEquals('This is a perfect description.', $resultEN->getStructure()->getProperty('description')->getValue()); }
public function testRun() { $this->initPhpcr(); $page = $this->documentManager->create('page'); $page->setStructureType('default'); $page->setTitle('Hallo'); $page->getStructure()->bind(['article' => 'This is a perfect description.']); $page->setResourceSegment('/hallo'); $this->documentManager->persist($page, 'de', ['parent_path' => '/cmf/sulu_io/contents']); $this->documentManager->flush(); $this->tester->execute(['webspaceKey' => 'sulu_io', 'srcLocale' => 'de', 'destLocale' => 'en']); $output = $this->tester->getDisplay(); $this->assertContains('Done', $output); $this->documentRegistry->clear(); $resultEN = $this->documentManager->find($page->getUuid(), 'en'); $resultDE = $this->documentManager->find($page->getUuid(), 'de'); $this->assertEquals('Hallo', $resultDE->getTitle()); $this->assertEquals('Hallo', $resultEN->getTitle()); $this->assertEquals('This is a perfect description.', $resultDE->getStructure()->getProperty('article')->getValue()); $this->assertEquals('This is a perfect description.', $resultEN->getStructure()->getProperty('article')->getValue()); $this->assertEquals('/hallo', $resultDE->getResourceSegment()); $this->assertEquals('/hallo', $resultEN->getResourceSegment()); }
/** * @deprecated * * {@inheritdoc} */ public function save($data, $structureType, $webspaceKey, $locale, $userId, $partialUpdate = true, $uuid = null, $parentUuid = null, $state = null, $isShadow = null, $shadowBaseLanguage = null, $documentAlias = LegacyStructure::TYPE_PAGE) { // map explicit arguments to data $data['parent'] = $parentUuid; $data['workflowStage'] = $state; $data['structureType'] = $structureType; if ($isShadow) { $data['shadowLocaleEnabled'] = true; } if ($shadowBaseLanguage) { $data['shadowLocale'] = $shadowBaseLanguage; } if ($uuid) { $document = $this->documentManager->find($uuid, $locale, array('type' => $documentAlias, 'load_ghost_content' => false)); } else { $document = $this->documentManager->create($documentAlias); } if (!$document instanceof StructureBehavior) { throw new \RuntimeException(sprintf('The content mapper can only be used to save documents implementing the StructureBehavior interface, got: "%s"', get_class($document))); } $options = array('clear_missing_content' => !$partialUpdate); // We eventually handle this from the controller, in which case we will not // have to deal with not knowing what sort of form we will have. if ($document instanceof WebspaceBehavior) { $options['webspace_key'] = $webspaceKey; } // disable csrf protection, since we can't produce a token, because the form is cached on the client $options['csrf_protection'] = false; $form = $this->formFactory->create($documentAlias, $document, $options); $clearMissing = false; $form->submit($data, $clearMissing); if (!$form->isValid()) { throw new InvalidFormException($form); } $this->documentManager->persist($document, $locale, array('user' => $userId)); $this->documentManager->flush(); $structure = $this->documentToStructure($document); $event = new ContentNodeEvent($this->inspector->getNode($document), $structure); $this->eventDispatcher->dispatch(ContentEvents::NODE_POST_SAVE, $event); return $structure; }
/** * Saves a new snippet. * * @param Request $request * * @return \Symfony\Component\HttpFoundation\Response */ public function postAction(Request $request) { $document = $this->documentManager->create('snippet'); $form = $this->processForm($request, $document); return $this->handleView($form->getData()); }