Inheritance: implements Sulu\Component\Content\Compat\StructureInterface
 private function upgradeNode(StructureBridge $page, Webspace $webspace, Localization $localization, OutputInterface $output, $depth = 0)
 {
     /** @var SessionManagerInterface $sessionManager */
     $sessionManager = $this->getContainer()->get('sulu.phpcr.session');
     $session = $sessionManager->getSession();
     $node = $session->getNodeByIdentifier($page->getUuid());
     /** @var RlpStrategyInterface $strategy */
     $strategy = $this->getContainer()->get('sulu.content.rlp.strategy.tree');
     /** @var ResourceLocator $resourceLocator */
     $resourceLocator = $this->getContainer()->get('sulu.content.type.resource_locator');
     if (!$page->hasTag('sulu.rlp')) {
         return;
     }
     $property = $page->getPropertyByTagName('sulu.rlp');
     if ($property->getContentTypeName() !== 'resource_locator' && $page->getNodeType() !== Structure::NODE_TYPE_CONTENT) {
         return;
     }
     $transProperty = new TranslatedProperty($property, $localization->getLocalization(), $this->getContainer()->getParameter('sulu.content.language.namespace'));
     try {
         // load value
         $rl = $strategy->loadByContent($node, $webspace->getKey(), $localization->getLocalization());
         // save value
         $property->setValue($rl);
         $resourceLocator->write($node, $transProperty, 1, $webspace->getKey(), $localization->getLocalization());
         $session->save();
         $prefix = '   ';
         for ($i = 0; $i < $depth; ++$i) {
             $prefix .= '-';
         }
         $output->writeln($prefix . '> "' . $page->getPropertyValue('title') . '": ' . $rl);
     } catch (ResourceLocatorNotFoundException $ex) {
     }
 }
Esempio n. 2
0
 public function getLanguageCode()
 {
     if (!$this->document) {
         return $this->locale;
     }
     // return original locale for shadow or ghost pages
     if ($this->getIsShadow() || $this->getType() && $this->getType()->getName() === 'ghost') {
         return $this->inspector->getOriginalLocale($this->getDocument());
     }
     return parent::getLanguageCode();
 }
Esempio n. 3
0
 public function testGetNodeNameForInternalLink()
 {
     $metadata = $this->prophesize(StructureMetadata::class);
     $inspector = $this->prophesize(DocumentInspector::class);
     $propertyFactory = $this->prophesize(LegacyPropertyFactory::class);
     $redirectDocument = $this->prophesize(BasePageDocument::class);
     $redirectDocument->getTitle()->willReturn('test');
     $document = $this->prophesize(BasePageDocument::class);
     $document->getTitle()->shouldNotBeCalled();
     $document->getRedirectType()->willReturn(RedirectType::INTERNAL);
     $document->getRedirectTarget()->willReturn($redirectDocument->reveal());
     $structure = new StructureBridge($metadata->reveal(), $inspector->reveal(), $propertyFactory->reveal(), $document->reveal());
     $this->assertEquals('test', $structure->getNodeName());
 }