/** * Upgrades the node to new date representation. * * @param NodeInterface $node The node to be upgraded * @param string $locale The locale of the node to be upgraded * @param array $properties The properties which are or contain date fields$up */ private function upgradeNode(NodeInterface $node, $locale, $properties, $up) { foreach ($properties as $property) { $propertyName = $this->propertyEncoder->localizedContentName($property, $locale); if ($node->hasProperty($propertyName)) { $value = $this->upgradeProperty($node->getPropertyValue($propertyName), $up); $node->setProperty($propertyName, $value); } } }
/** * Removes all localized properties in the given locale from the given node. * * @param NodeInterface $node * @param string $locale */ private function removeLocalizedNodeProperties(NodeInterface $node, $locale) { // remove all localized system properties from the node foreach ($node->getProperties($this->propertyEncoder->localizedSystemName('', $locale) . '*') as $property) { $property->remove(); } // remove all localized content properties from the node foreach ($node->getProperties($this->propertyEncoder->localizedContentName('', $locale) . '*') as $property) { $property->remove(); } }
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; } }