/** * It should get a legacy structure bridge. */ public function testGetStructure() { $structureType = 'content'; $documentType = 'page'; $this->factory->getStructureMetadata($documentType, $structureType)->willReturn($this->structure->reveal()); $bridge = $this->structureManager->getStructure($structureType, $documentType); $this->assertInstanceOf(StructureBridge::class, $bridge); }
/** * @param VisitorInterface $visitor * @param array $data * @param array $type * @param Context $context * * @return PageBridge */ public function doDeserialize(VisitorInterface $visitor, array $data, array $type, Context $context) { $document = $context->accept($data['document'], ['name' => $data['documentClass']]); $structure = $this->structureFactory->getStructureMetadata('page', $data['structure']); $bridge = new PageBridge($structure, $this->inspector, $this->propertyFactory, $document); // filthy hack to set the Visitor::$result to null and force the // serializer to return the Bridge and not the Document $visitor->setNavigator($context->getNavigator()); return $bridge; }
/** * It returns all structures that are available. */ public function testGetStructures() { $this->loader->load($this->mappingFile, 'page')->willReturn($this->structure->reveal()); $this->loader->load($this->mappingFile, 'page')->shouldBeCalledTimes(1); $structures = $this->factory->getStructures('page'); $this->assertEquals($this->structure->reveal(), $structures[0]); }
/** * {@inheritDoc} */ public function getMetadataForDocument(Document $document) { if (!$document->hasField(self::FIELD_STRUCTURE_TYPE)) { return; } $className = $document->getClass(); $structureType = $document->getField(self::FIELD_STRUCTURE_TYPE)->getValue(); $documentMetadata = $this->metadataFactory->getMetadataForClass($className); $structure = $this->structureFactory->getStructureMetadata($documentMetadata->getAlias(), $structureType); return $this->getMetadata($documentMetadata, $structure); }
/** * {@inheritdoc} */ public function getClassFqns() { $classFqns = []; foreach ($this->metadataFactory->getAllMetadata() as $metadata) { if (!$this->structureFactory->hasStructuresFor($metadata->getAlias())) { continue; } $classFqns[] = $metadata->getClass(); } return $classFqns; }
/** * It returns all structures that are available. */ public function testGetStructures() { $this->loader->load($this->somethingMappingFile, 'page')->willReturn($this->somethingStructure->reveal()); $this->loader->load($this->defaultMappingFile, 'page')->willReturn($this->defaultStructure->reveal()); $this->loader->load($this->somethingMappingFile, 'page')->shouldBeCalledTimes(1); $this->loader->load($this->defaultMappingFile, 'page')->shouldBeCalledTimes(1); $structures = $this->factory->getStructures('page'); $this->assertCount(3, $structures); $this->assertEquals($this->defaultStructure->reveal(), $structures[0]); $this->assertEquals($this->somethingStructure->reveal(), $structures[1]); $this->assertEquals($this->defaultStructure->reveal(), $structures[2]); }
private function upgradeNode(NodeInterface $node, Webspace $webspace, Localization $localization, OutputInterface $output, $depth = 0) { $locale = $localization->getLocale(); $localizedTemplatePropertyName = $this->propertyEncoder->localizedSystemName('template', $locale); if (!$node->hasProperty($localizedTemplatePropertyName)) { return; } $structureMetadata = $this->structureMetadataFactory->getStructureMetadata($this->metadataFactory->getMetadataForPhpcrNode($node)->getAlias(), $node->getPropertyValue($localizedTemplatePropertyName)); $property = $structureMetadata->getPropertyByTagName('sulu.rlp'); if (!$property) { return; } $nodeType = $node->getPropertyValue($this->propertyEncoder->localizedSystemName('nodeType', $locale)); if ($property->getContentTypeName() !== 'resource_locator' && $nodeType !== Structure::NODE_TYPE_CONTENT) { return; } $baseRoutePath = $this->sessionManager->getRoutePath($webspace->getKey(), $localization->getLocale()); foreach ($node->getReferences('sulu:content') as $routeProperty) { if (strpos($routeProperty->getPath(), $baseRoutePath) !== 0) { continue; } $routeNode = $routeProperty->getParent(); if ($routeNode->getPropertyValue('sulu:history') === true) { continue; } $resourceLocator = substr($routeNode->getPath(), strlen($baseRoutePath)); if ($resourceLocator) { // only set if resource locator is not empty // if the resource locator is empty it is the homepage, whose url should not be changed $node->setProperty($this->propertyEncoder->localizedContentName($property->getName(), $locale), $resourceLocator); $prefix = ' '; for ($i = 0; $i < $depth; ++$i) { $prefix .= '-'; } $title = $node->getPropertyValue($this->propertyEncoder->localizedContentName('title', $locale)); $output->writeln($prefix . '> "' . $title . '": ' . $resourceLocator); } break; } }