示例#1
0
 /**
  * @see \PHPCR\NodeInterface::getNodes
  */
 public function getNodes($filter = null)
 {
     $nodes = $this->node->getNodes($filter);
     foreach ($nodes as $name => $node) {
         $nodes[$name] = new Node($node);
     }
     return $nodes;
 }
 /**
  * {@inheritdoc}
  */
 protected function initialize()
 {
     if (true === $this->initialized) {
         return;
     }
     $this->documents = $this->parentNode->getNodes();
     $this->initialized = true;
 }
示例#3
0
 /**
  * Removes non translated properties.
  *
  * @param NodeInterface $node
  */
 private function upgradeNode(NodeInterface $node)
 {
     foreach ($node->getProperties('i18n:-*') as $property) {
         $property->remove();
     }
     foreach ($node->getNodes() as $childNode) {
         $this->upgradeNode($childNode);
     }
 }
示例#4
0
 private function traverse(NodeInterface $node)
 {
     $i = 10;
     foreach ($node->getNodes() as $childNode) {
         $childNode->setProperty(NodeOrderSubscriber::SULU_ORDER, $i);
         $this->context->getOutput()->writeln(sprintf('<info>[+]</info> Setting order "<comment>%s</comment>" on <comment>%s</comment>', $i, $childNode->getPath()));
         $this->traverse($childNode);
         $i += 10;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getLocalesFor($document, NodeInterface $node, ClassMetadata $metadata)
 {
     $translations = $node->getNodes(Translation::LOCALE_NAMESPACE . ':*');
     $locales = array();
     foreach ($translations as $name => $node) {
         if ($p = strpos($name, ':')) {
             $locales[] = substr($name, $p + 1);
         }
     }
     return $locales;
 }
示例#6
0
 /**
  * This method populates the test case properties both at test setUp
  * and after renewing the session.
  *
  * The default schema is to have a root node /test_<something> with one
  * child node per test with the node name being the test name.
  */
 protected function initProperties()
 {
     $this->session = $this->sharedFixture['session'];
     $this->node = null;
     $this->rootNode = $this->session->getRootNode();
     $children = $this->rootNode->getNodes('tests_*');
     $child = $children->current();
     if ($child && $child->hasNode($this->getName())) {
         $this->node = $child->getNode($this->getName());
     }
 }
示例#7
0
 private function traverse(NodeInterface $node, $readProperties = false)
 {
     if ($readProperties) {
         foreach ($node->getProperties() as $property) {
             try {
                 $property->getValue();
             } catch (\PHPCR\RepositoryException $e) {
             }
         }
     }
     foreach ($node->getNodes() as $child) {
         $this->traverse($child, $readProperties);
     }
 }
示例#8
0
 /**
  * Upgrade a single node.
  *
  * @param NodeInterface $node
  * @param string $propertyName
  * @param string $locale
  */
 private function upgradeNode(NodeInterface $node, $propertyName, $locale)
 {
     foreach ($node->getNodes() as $child) {
         $this->upgradeNode($child, $propertyName, $locale);
     }
     if (false === $node->getPropertyValueWithDefault($propertyName, false)) {
         return;
     }
     $shadowLocale = $node->getPropertyValue($this->getPropertyName(self::SHADOW_BASE_PROPERTY, $locale));
     $tags = $this->getTags($node, $shadowLocale);
     $categories = $this->getCategories($node, $shadowLocale);
     $navigationContext = $this->getNavigationContext($node, $shadowLocale);
     $node->setProperty(sprintf(self::TAGS_PROPERTY, $locale), $tags);
     $node->setProperty(sprintf(self::CATEGORIES_PROPERTY, $locale), $categories);
     $node->setProperty(sprintf(self::NAVIGATION_CONTEXT_PROPERTY, $locale), $navigationContext);
 }
 public function testGetNodesTypeFilterList()
 {
     $this->node = $this->rootNode->getNode('tests_general_base');
     $iterator = $this->node->getNodes('id*', array('nt:file', 'nt:folder'));
     $nodes = array();
     foreach ($iterator as $n) {
         $this->assertInstanceOf('PHPCR\\NodeInterface', $n);
         /* @var $n \PHPCR\NodeInterface */
         array_push($nodes, $n->getName());
     }
     $this->assertNotContains('index.txt', $nodes);
     $this->assertContains('idExample', $nodes);
     $this->assertNotContains('test:namespacedNode', $nodes);
     $this->assertNotContains('emptyExample', $nodes);
     $this->assertNotContains('multiValueProperty', $nodes);
     $this->assertNotContains('numberPropertyNode', $nodes);
     $this->assertNotContains('NumberPropertyNodeToCompare1', $nodes);
     $this->assertNotContains('NumberPropertyNodeToCompare2', $nodes);
 }
示例#10
0
 /**
  * Sets the workflowstage and the published date for the given node and all of its children to test resp. null. This
  * is done for every language in which the given properties exist.
  *
  * @param NodeInterface $node
  */
 private function setNodeWorkflowStageToTestForCopy(NodeInterface $node)
 {
     $workflowStageNameFilter = $this->propertyEncoder->localizedSystemName(self::WORKFLOW_STAGE_FIELD, '*');
     foreach ($node->getProperties($workflowStageNameFilter) as $property) {
         /** @var PropertyInterface $property */
         $property->setValue(WorkflowStage::TEST);
     }
     $publishedNameFilter = $this->propertyEncoder->localizedSystemName(self::PUBLISHED_FIELD, '*');
     foreach ($node->getProperties($publishedNameFilter) as $property) {
         /** @var PropertyInterface $property */
         $property->setValue(null);
     }
     foreach ($node->getNodes() as $node) {
         /** @var NodeInterface $node */
         $this->setNodeWorkflowStageToTestForCopy($node);
     }
 }
示例#11
0
 /**
  * This method will either let the transport filter if that is possible or
  * forward to getNodes and return the names of the nodes found there.,
  *
  * @param NodeInterface $node
  * @param string|array  $nameFilter
  * @param string|array  $typeFilter
  *
  * @return ArrayIterator
  */
 public function filterChildNodeNamesByType(NodeInterface $node, $nameFilter, $typeFilter)
 {
     if ($this->transport instanceof NodeTypeFilterInterface) {
         return $this->transport->filterChildNodeNamesByType($node->getPath(), $node->getNodeNames($nameFilter), $typeFilter);
     }
     // fallback: get the actual nodes and let that filter. this is expensive.
     return new ArrayIterator(array_keys($node->getNodes($nameFilter, $typeFilter)->getArrayCopy()));
 }
 /**
  * If the node should be ordered after the target then we need to order the
  * node before the sibling after the target sibling. If the node should be the
  * last sibling, then the target sibling should be NULL.
  *
  * @param NodeInterface $parentNode
  * @param string $siblingName
  *
  * @return string
  */
 private function resolveAfterSiblingName(NodeInterface $parentNode, $siblingName)
 {
     $targetName = null;
     $found = false;
     foreach (array_keys($parentNode->getNodes()) as $name) {
         if ($name === $siblingName) {
             $found = true;
             continue;
         } elseif ($found) {
             $targetName = $name;
             break;
         }
     }
     return $targetName;
 }
示例#13
0
 /**
  * Cleanup specific node and his children.
  *
  * @param NodeInterface $node
  * @param string        $rootPath
  * @param bool          $dryRun
  */
 private function cleanup(OutputInterface $output, NodeInterface $node, $rootPath, $dryRun)
 {
     foreach ($node->getNodes() as $childNode) {
         $this->cleanup($output, $childNode, $rootPath, $dryRun);
     }
     $path = ltrim(str_replace($rootPath, '', $node->getPath()), '/');
     if (!$node->getPropertyValueWithDefault('sulu:history', false)) {
         $output->writeln('<info>Processing aborted: </info>/' . $path . ' <comment>(no history url)</comment>');
         return;
     }
     if ($dryRun === false) {
         $node->remove();
     }
     $output->writeln('<info>Processing: </info>/' . $path);
 }
示例#14
0
文件: SuluNode.php 项目: sulu/sulu
 /**
  * {@inheritdoc}
  */
 public function getNodes($nameFilter = null, $typeFilter = null)
 {
     return $this->node->getNodes($nameFilter, $typeFilter);
 }
 private function upgradeByParent(NodeInterface $parentNode, Webspace $webspace, Localization $localization, OutputInterface $output)
 {
     foreach ($parentNode->getNodes() as $childNode) {
         $this->upgradeNode($childNode, $webspace, $localization, $output, substr_count($childNode->getPath(), '/'));
         $this->upgradeByParent($childNode, $webspace, $localization, $output);
     }
 }
示例#16
0
 /**
  * adopts resource locator of children by iteration.
  *
  * @param NodeInterface $contentNode
  * @param int           $userId
  * @param string        $webspaceKey
  * @param string        $languageCode
  * @param bool          $iterate
  * @param string        $segmentKey
  */
 private function adaptResourceLocators(NodeInterface $contentNode, $userId, $webspaceKey, $languageCode, $segmentKey = null, $iterate = true)
 {
     foreach ($contentNode->getNodes() as $node) {
         // determine structure
         $templatePropertyName = $this->nodeHelper->getTranslatedPropertyName('template', $languageCode);
         if (!$node->hasProperty($templatePropertyName)) {
             continue;
         }
         $template = $node->getPropertyValue($templatePropertyName);
         $structure = $this->structureManager->getStructure($template);
         // only if rlp exists
         if ($structure->hasTag('sulu.rlp')) {
             // get rlp
             try {
                 $rlp = $this->loadByContent($node, $webspaceKey, $languageCode);
             } catch (ResourceLocatorNotFoundException $ex) {
                 $contentNode->getSession()->save();
                 $rlpPart = $node->getPropertyValue($this->nodeHelper->getTranslatedPropertyName('title', $languageCode));
                 $prentRlp = $this->mapper->getParentPath($node->getIdentifier(), $webspaceKey, $languageCode, $segmentKey);
                 // generate new resourcelocator
                 $rlp = $this->generate($rlpPart, $prentRlp, $webspaceKey, $languageCode);
             }
             // determine rlp property
             $property = $structure->getPropertyByTagName('sulu.rlp');
             $contentType = $this->contentTypeManager->get($property->getContentTypeName());
             $property->setValue($rlp);
             // write value to node
             $translatedProperty = $this->nodeHelper->getTranslatedProperty($property, $languageCode);
             $contentType->write($node, $translatedProperty, $userId, $webspaceKey, $languageCode, $segmentKey);
         }
         // for node move the tree will be copied to then there is the iteration over this function
         // for node copy the iteration is done by the content-type which calls over the move function
         //     recursively this function
         if ($iterate) {
             $this->adaptResourceLocators($node, $userId, $webspaceKey, $languageCode, $segmentKey);
         }
     }
 }