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


PHP Node::getChildren方法代码示例

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


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

示例1: parseNode

 /**
  * @param \tomzx\HtmlParser\Node $node
  * @return array
  */
 protected function parseNode(Node $node)
 {
     $statements = $node->getChildren();
     foreach ($node->getChildren() as $child) {
         $statements[] = $this->parseNode($child);
     }
     return $statements;
 }
开发者ID:tomzx,项目名称:html-parser,代码行数:12,代码来源:Parser.php

示例2: testChildrenManipulation

 public function testChildrenManipulation()
 {
     $node = new Node();
     $node->setChildren(['foo']);
     $this->assertCount(1, $node->getChildren());
     $this->assertEquals(['foo'], $node->getChildren());
     $node->clearChildren();
     $this->assertEmpty($node->getChildren());
     $node->setChildAtIndex($child1 = new Node(), 2);
     $this->assertCount(1, $children = $node->getChildren());
     $this->assertEquals($child1, reset($children));
     $this->assertEquals(2, key($children));
 }
开发者ID:sohailaammarocs,项目名称:lfc,代码行数:13,代码来源:NodeTraitTest.php

示例3: render

 public function render(Node $node)
 {
     echo str_repeat('--', $node->getDepth()) . $node->getType() . "\n";
     foreach ($node->getChildren() as $child) {
         $this->render($child);
     }
 }
开发者ID:heybigname,项目名称:html-to-markdown,代码行数:7,代码来源:TextRenderer.php

示例4: getSiblings

 /**
  * Returns siblings of the node, optionally including the node itself.
  *
  * @param bool $includeSelf If true, the node itself will be included in the resulting
  *                          array. In either case, the sort order will be correct.
  *                          This argument is deprecated and will be removed in v2.0
  *
  * Note: The argument is deprecated and will be removed in version 2; please
  * use getSiblingsAndSelf().
  *
  * @return Node[]
  */
 public function getSiblings($includeSelf = false)
 {
     $siblings = array();
     foreach ($this->parent->getChildren() as $child) {
         if ($includeSelf || $child->getId() != $this->getId()) {
             $siblings[] = $child;
         }
     }
     return $siblings;
 }
开发者ID:rocketyang,项目名称:hasscms-app,代码行数:22,代码来源:Node.php

示例5: getChildren

 public function getChildren()
 {
     if (!$this->areBaseChildrenAccessible()) {
         return parent::getChildren();
     }
     $names = array_keys(array_merge($this->getBaseNode()->getChildren(), $this->childNodes));
     $nodes = [];
     foreach ($names as $name) {
         $nodes[$name] = $this->getChild($name);
     }
     return $nodes;
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:12,代码来源:WrappedNode.php

示例6: applyArgs

 protected function applyArgs(Node $node)
 {
     if ($node instanceof TextNode) {
         $node->setContent($this->interpolate($node->getContent()));
     } else {
         if ($node instanceof Element) {
             foreach ($node->getAttributes() as $attr => $value) {
                 $node->setAttribute($attr, $this->interpolate($value));
             }
         }
     }
     foreach ($node->getChildren() as $child) {
         $this->applyArgs($child);
     }
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:15,代码来源:IncludeElement.php

示例7: find

 /**
  * Find matching nodes among node children
  *
  * @param Node $node
  *
  * @param string $ignoreRoot
  *
  * @return \USync\AST\NodeInterface[]
  */
 public function find(Node $node, $ignoreRoot = true)
 {
     $ret = [];
     if ($ignoreRoot && $node->isRoot()) {
         foreach ($node->getChildren() as $child) {
             $this->_find($ret, $child);
         }
     } else {
         $this->_find($ret, $node);
     }
     return $ret;
 }
开发者ID:makinacorpus,项目名称:drupal-usync,代码行数:21,代码来源:Path.php

示例8: toArray

 /**
  * Returns an array representation of the given Node structure.
  *
  * @param Node $node
  *
  * @return array
  */
 public function toArray(Node $node)
 {
     return array('name' => $node->getName(), 'value' => $node->getValue(), 'attributes' => $node->getAttributes(), 'children' => array_map(function (Node $child) {
         return $this->toArray($child);
     }, $node->getChildren()));
 }
开发者ID:dborsatto,项目名称:object-xml,代码行数:13,代码来源:Manager.php

示例9: addNode

 /**
  * Create a new node and its children
  * 
  * @param object Hierarchy $newHierarchy
  * @param object Node $oldNode
  * @param optional object Id $parentId 
  * @return void
  * @access protected
  * @since 4/17/08
  */
 protected function addNode(Hierarchy $newHierarchy, Node $oldNode, Id $parentId = null)
 {
     // If it has already been created, get it and try to set its parent
     try {
         $newNode = $newHierarchy->getNode($oldNode->getId());
         if (!is_null($parentId)) {
             try {
                 $newNode->addParent($parentId);
             } catch (Exception $e) {
                 // Do nothing if the child already exists
                 if ($e->getMessage() != "A child with the given id already exists!") {
                     throw $e;
                 }
             }
         }
     } catch (UnknownIdException $e) {
         if (is_null($parentId)) {
             $newNode = $newHierarchy->createRootNode($oldNode->getId(), $oldNode->getType(), $oldNode->getDisplayName(), $oldNode->getDescription());
         } else {
             $newNode = $newHierarchy->createNode($oldNode->getId(), $parentId, $oldNode->getType(), $oldNode->getDisplayName(), $oldNode->getDescription());
         }
         $this->nodeStatus->updateStatistics();
     }
     $oldChildren = $oldNode->getChildren();
     while ($oldChildren->hasNext()) {
         $oldChild = $oldChildren->next();
         $this->addNode($newHierarchy, $oldChild, $newNode->getId());
     }
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:39,代码来源:migration.php

示例10: getIterator

 /**
  * @return \RecursiveIteratorIterator
  */
 public function getIterator()
 {
     return new \RecursiveIteratorIterator($this->head->getChildren(), \RecursiveIteratorIterator::SELF_FIRST);
 }
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:bug65328.php

示例11: writeType

 /**
  * Write an individual type to the stream.
  *
  * @param resource $fPtr    Stream pointer
  * @param int      $tagType Type of tag to write
  * @param Node     $node    Node containing value to write
  *
  * @return bool
  */
 private function writeType($fPtr, $tagType, Node $node)
 {
     switch ($tagType) {
         case Tag::TAG_BYTE:
             // Signed byte (8 bit)
             return $this->dataHandler->putTAGByte($fPtr, $node->getValue());
         case Tag::TAG_SHORT:
             // Signed short (16 bit, big endian)
             return $this->dataHandler->putTAGShort($fPtr, $node->getValue());
         case Tag::TAG_INT:
             // Signed integer (32 bit, big endian)
             return $this->dataHandler->putTAGInt($fPtr, $node->getValue());
         case Tag::TAG_LONG:
             // Signed long (64 bit, big endian)
             return $this->dataHandler->putTAGLong($fPtr, $node->getValue());
         case Tag::TAG_FLOAT:
             // Floating point value (32 bit, big endian, IEEE 754-2008)
             return $this->dataHandler->putTAGFloat($fPtr, $node->getValue());
         case Tag::TAG_DOUBLE:
             // Double value (64 bit, big endian, IEEE 754-2008)
             return $this->dataHandler->putTAGDouble($fPtr, $node->getValue());
         case Tag::TAG_BYTE_ARRAY:
             // Byte array
             return $this->dataHandler->putTAGByteArray($fPtr, $node->getValue());
         case Tag::TAG_STRING:
             // String
             return $this->dataHandler->putTAGString($fPtr, $node->getValue());
         case Tag::TAG_INT_ARRAY:
             // Byte array
             return $this->dataHandler->putTAGIntArray($fPtr, $node->getValue());
         case Tag::TAG_LIST:
             // List
             if (!($this->dataHandler->putTAGByte($fPtr, $node->getPayloadType()) && $this->dataHandler->putTAGInt($fPtr, count($node->getChildren())))) {
                 return false;
             }
             foreach ($node->getChildren() as $childNode) {
                 if (!$this->writeType($fPtr, $node->getPayloadType(), $childNode)) {
                     return false;
                 }
             }
             return true;
         case Tag::TAG_COMPOUND:
             // Compound
             foreach ($node->getChildren() as $childNode) {
                 if (!$this->writeTag($fPtr, $childNode)) {
                     return false;
                 }
             }
             if (!$this->writeType($fPtr, Tag::TAG_END, new Node())) {
                 return false;
             }
             return true;
         case Tag::TAG_END:
             // End tag
             return is_int(fwrite($fPtr, ""));
     }
 }
开发者ID:rickselby,项目名称:nbt,代码行数:66,代码来源:Service.php

示例12: getChildrenReturnsEmptyArrayWhenNoChildNodesExist

 /**
  * @test
  */
 public function getChildrenReturnsEmptyArrayWhenNoChildNodesExist()
 {
     $parent = new Node(array('id' => 52));
     $this->assertSame(array(), $parent->getChildren());
 }
开发者ID:bluem,项目名称:tree,代码行数:8,代码来源:NodeTest.php


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