当前位置: 首页>>代码示例>>PHP>>正文


PHP NodeInterface::getDepth方法代码示例

本文整理汇总了PHP中PHPCR\NodeInterface::getDepth方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::getDepth方法的具体用法?PHP NodeInterface::getDepth怎么用?PHP NodeInterface::getDepth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPCR\NodeInterface的用法示例。


在下文中一共展示了NodeInterface::getDepth方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->contentMapper = $this->prophesize('Sulu\\Component\\Content\\Mapper\\ContentMapperInterface');
     $this->requestAnalyzer = $this->prophesize('Sulu\\Component\\Webspace\\Analyzer\\RequestAnalyzerInterface');
     $this->contentTypeManager = $this->prophesize('Sulu\\Component\\Content\\ContentTypeManagerInterface');
     $this->structureManager = $this->prophesize('Sulu\\Component\\Content\\Compat\\StructureManagerInterface');
     $this->sessionManager = $this->prophesize('Sulu\\Component\\PHPCR\\SessionManager\\SessionManagerInterface');
     $this->session = $this->prophesize('PHPCR\\SessionInterface');
     $this->node = $this->prophesize('PHPCR\\NodeInterface');
     $this->parentNode = $this->prophesize('PHPCR\\NodeInterface');
     $this->startPageNode = $this->prophesize('PHPCR\\NodeInterface');
     $webspace = new Webspace();
     $webspace->setKey('sulu_test');
     $locale = new Localization();
     $locale->setCountry('us');
     $locale->setLanguage('en');
     $this->requestAnalyzer->getWebspace()->willReturn($webspace);
     $this->requestAnalyzer->getCurrentLocalization()->willReturn($locale);
     $this->contentTypeManager->get('text_line')->willReturn(new TextLine(''));
     $this->sessionManager->getSession()->willReturn($this->session->reveal());
     $this->sessionManager->getContentNode('sulu_test')->willReturn($this->startPageNode->reveal());
     $this->session->getNodeByIdentifier('123-123-123')->willReturn($this->node->reveal());
     $this->session->getNodeByIdentifier('321-321-321')->willReturn($this->parentNode->reveal());
     $this->node->getIdentifier()->willReturn('123-123-123');
     $this->node->getParent()->willReturn($this->parentNode->reveal());
     $this->node->getDepth()->willReturn(4);
     $this->parentNode->getIdentifier()->willReturn('321-321-321');
     $this->parentNode->getDepth()->willReturn(3);
     $this->startPageNode->getDepth()->willReturn(3);
     $this->structureResolver = new StructureResolver($this->contentTypeManager->reveal(), $this->structureManager->reveal());
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:32,代码来源:ContentTwigExtensionTest.php

示例2: visitAncestors

 /**
  * Let the visitor visit the ancestors from root node according to mapper
  * down to the parent of the node identified by url
  *
  * @param string $url the url (without eventual prefix from routing config)
  * @param ItemVisitorInterface $visitor the visitor to look at the nodes
  */
 public function visitAncestors($url, ItemVisitorInterface $visitor)
 {
     $node = $this->session->getNode($this->mapper->getStorageId($url));
     $i = $this->rootnode->getDepth();
     while (($ancestor = $node->getAncestor($i++)) != $node) {
         $ancestor->accept($visitor);
     }
 }
开发者ID:ronnylt,项目名称:symfony-cmf,代码行数:15,代码来源:HierarchyWalker.php

示例3: exportSystemViewRecursive

 /**
  * Recursively output node and all its children into the file in the system
  * view format
  *
  * @param NodeInterface $node   the node to output
  * @param resource      $stream The stream resource (i.e. acquired with fopen) to
  *      which the XML serialization of the subgraph will be output. Must
  *      support the fwrite method.
  * @param boolean $skipBinary A boolean governing whether binary properties
  *      are to be serialized.
  * @param boolean $noRecurse A boolean governing whether the subgraph at
  *      absPath is to be recursed.
  * @param boolean $root Whether this is the root node of the resulting
  *      document, meaning the namespace declarations have to be included in
  *      it.
  */
 private static function exportSystemViewRecursive(NodeInterface $node, NamespaceRegistryInterface $ns, $stream, $skipBinary, $noRecurse, $root = false)
 {
     fwrite($stream, '<sv:node');
     if ($root) {
         self::exportNamespaceDeclarations($ns, $stream);
     }
     fwrite($stream, ' sv:name="' . (0 === $node->getDepth() ? 'jcr:root' : htmlspecialchars($node->getName())) . '">');
     // the order MUST be primary type, then mixins, if any, then jcr:uuid if its a referenceable node
     fwrite($stream, '<sv:property sv:name="jcr:primaryType" sv:type="Name"><sv:value>' . htmlspecialchars($node->getPropertyValue('jcr:primaryType')) . '</sv:value></sv:property>');
     if ($node->hasProperty('jcr:mixinTypes')) {
         fwrite($stream, '<sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true">');
         foreach ($node->getPropertyValue('jcr:mixinTypes') as $type) {
             fwrite($stream, '<sv:value>' . htmlspecialchars($type) . '</sv:value>');
         }
         fwrite($stream, '</sv:property>');
     }
     if ($node->isNodeType('mix:referenceable')) {
         fwrite($stream, '<sv:property sv:name="jcr:uuid" sv:type="String"><sv:value>' . $node->getIdentifier() . '</sv:value></sv:property>');
     }
     foreach ($node->getProperties() as $name => $property) {
         /** @var $property \PHPCR\PropertyInterface */
         if ($name == 'jcr:primaryType' || $name == 'jcr:mixinTypes' || $name == 'jcr:uuid') {
             // explicitly handled before
             continue;
         }
         if (PropertyType::BINARY == $property->getType() && $skipBinary) {
             // do not output binary data in the xml
             continue;
         }
         fwrite($stream, '<sv:property sv:name="' . htmlentities($name) . '" sv:type="' . PropertyType::nameFromValue($property->getType()) . '"' . ($property->isMultiple() ? ' sv:multiple="true"' : '') . '>');
         $values = $property->isMultiple() ? $property->getString() : array($property->getString());
         foreach ($values as $value) {
             if (PropertyType::BINARY == $property->getType()) {
                 $val = base64_encode($value);
             } else {
                 $val = htmlspecialchars($value);
                 //TODO: can we still have invalid characters after this? if so base64 and property, xsi:type="xsd:base64Binary"
             }
             fwrite($stream, "<sv:value>{$val}</sv:value>");
         }
         fwrite($stream, "</sv:property>");
     }
     if (!$noRecurse) {
         foreach ($node as $child) {
             if (!($child->getDepth() == 1 && NodeHelper::isSystemItem($child))) {
                 self::exportSystemViewRecursive($child, $ns, $stream, $skipBinary, $noRecurse);
             }
         }
     }
     fwrite($stream, '</sv:node>');
 }
开发者ID:viral810,项目名称:ngSimpleCMS,代码行数:67,代码来源:ImportExport.php

示例4: getDepth

 /**
  * {@inheritdoc}
  */
 public function getDepth()
 {
     return $this->node->getDepth();
 }
开发者ID:sulu,项目名称:sulu,代码行数:7,代码来源:SuluNode.php

示例5: collectPrefetchHierarchy

 /**
  * Gather the parent and all child mappings so they can be fetched in one
  * go.
  *
  * @param ClassMetadata $class  The metadata about the document to know what to do.
  * @param NodeInterface $node   The node to prefetch parent and childs for.
  * @param string|null   $locale The locale to also prefetch the translation
  *      child if applicable.
  *
  * @return array List of absolute paths to nodes that should be prefetched.
  */
 public function collectPrefetchHierarchy(ClassMetadata $class, NodeInterface $node, $locale = null)
 {
     $prefetch = array();
     if ($class->parentMapping && $node->getDepth() > 0) {
         $prefetch[] = PathHelper::getParentPath($node->getPath());
     }
     foreach ($class->childMappings as $fieldName) {
         $childName = $class->mappings[$fieldName]['nodeName'];
         $prefetch[] = PathHelper::absolutizePath($childName, $node->getPath());
     }
     if ($locale && count($prefetch) && 'child' === $class->translator) {
         $prefetch[] = $node->getPath() . '/phpcr_locale:' . $locale;
     }
     return $prefetch;
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:26,代码来源:PrefetchHelper.php

示例6: testGetDepth

 public function testGetDepth()
 {
     $this->assertEquals(1, $this->node->getDepth());
     $this->assertEquals(3, $this->deepnode->getDepth());
 }
开发者ID:laurentiuc,项目名称:phpcr-api-tests,代码行数:5,代码来源:NodeReadMethodsTest.php


注:本文中的PHPCR\NodeInterface::getDepth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。