Sulu\Bundle\ContentBundle\Command\MaintainResourceLocatorCommand::upgradeNode PHP Метод

upgradeNode() приватный Метод

private upgradeNode ( PHPCR\NodeInterface $node, Webspace $webspace, Localization $localization, Symfony\Component\Console\Output\OutputInterface $output, $depth )
$node PHPCR\NodeInterface
$webspace Sulu\Component\Webspace\Webspace
$localization Sulu\Component\Localization\Localization
$output Symfony\Component\Console\Output\OutputInterface
    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;
        }
    }