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


PHP Node::setParent方法代码示例

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


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

示例1: attachChild

 /**
  * Attach a child node
  *
  * @param \Zend\Server\Reflection\Node $node
  * @return void
  */
 public function attachChild(Node $node)
 {
     $this->children[] = $node;
     if ($node->getParent() !== $this) {
         $node->setParent($this);
     }
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:13,代码来源:Node.php

示例2: createNodeFromElement

 private function createNodeFromElement($elem, $parent)
 {
     $node = new Node();
     $node->setParent($parent);
     $node->setType($elem->nodeName);
     $node->setText($elem->nodeValue);
     $node->setDepth($parent->getDepth() + 1);
     $node->setAttributes($this->getElementAttributes($elem));
     return $node;
 }
开发者ID:heybigname,项目名称:html-to-markdown,代码行数:10,代码来源:DomNodeParser.php

示例3: addChild

 public function addChild(Node $n = null)
 {
     if ($n === null) {
         $n = new Node();
     }
     $this->children[] = $n;
     $n->setParent($this);
     $n->setTree($this->tree);
     return $n;
 }
开发者ID:webfactory,项目名称:navigation-bundle,代码行数:10,代码来源:Node.php

示例4: explode

 $parsed = str_replace("((", "( (", $parsed);
 $parsed = str_replace("))", ") )", $parsed);
 $parsed = str_replace("))", ") )", $parsed);
 $tokens = explode(" ", $parsed);
 // var_dump($tokens);
 foreach ($tokens as $token) {
     if (strcmp(substr($token, 0, 1), "(") == 0) {
         //nāk jauna frāze, jātaisa jauna lapa
         $tokenCategory = trim(substr($token, 1));
         if (!isset($rootNode)) {
             $rootNode = new Node($tokenCategory);
             $currentNode = $rootNode;
             $currentNode->level = 0;
         } else {
             $newNode = new Node($tokenCategory);
             $newNode->setParent($currentNode);
             $newNode->level = $currentNode->level + 1;
             if (!$rootNode->hasChildren()) {
                 $rootNode->addChild($newNode);
             } else {
                 $currentNode->addChild($newNode);
             }
             $currentNode = $newNode;
         }
     } elseif (strcmp(substr($token, -1, 1), ")") == 0) {
         //frāze beidzas
         //ja bija vārds, jāpievieno pie aktuālās lapas, ja nē, jāiet pie vecāka
         $tokenWord = substr($token, 0, -1);
         if (strlen($tokenWord) > 0) {
             $currentNode->setWord($tokenWord);
         }
开发者ID:M4t1ss,项目名称:K-Translate,代码行数:31,代码来源:testChunker.php

示例5: addChild

 /**
  * @param \Herbie\Node $child
  */
 public function addChild(Node $child)
 {
     $child->setParent($this);
     $this->children[] = $child;
 }
开发者ID:bobbiebenton,项目名称:herbie,代码行数:8,代码来源:Node.php

示例6: addNode

 /**
  * Add a node
  *
  * @param  Node         $node
  * @param  int|callable $cost
  * @return Node
  */
 public function addNode(Node $node, $cost = 0)
 {
     $arc = new Arc($this, $node, $cost);
     $this->arcs[] = $arc;
     $node->setParent($this);
     $this->nodes[] = $node;
     return $node;
 }
开发者ID:fieg,项目名称:graph-search,代码行数:15,代码来源:Node.php

示例7: removeChild

 public function removeChild(Node $child)
 {
     $this->children = array_values(array_filter($this->children, function ($currentChild) use($child) {
         return $currentChild !== $child;
     }));
     $child->setParent(null);
     return $child;
 }
开发者ID:torbenkoehn,项目名称:php-xtpl,代码行数:8,代码来源:Node.php

示例8: addChild

 /**
  * Adds a child to this node
  *
  * @param Node $node The child to add
  * @return Node Returns this for chaining
  */
 public function addChild(Node $node)
 {
     $node->setParent($this);
     $this->children[] = $node;
     return $this;
 }
开发者ID:scaleddynamics,项目名称:Opulence,代码行数:12,代码来源:Node.php

示例9: moveNode

 /**
  * move the node within the current schema
  *
  * @param Node $node
  * @param Node $parent
  *
  * @return $this
  */
 public function moveNode(Node $node, Node $parent)
 {
     $node->setParent($parent)->updateId();
     $this->idList[$node->id] = $node;
     return $this;
 }
开发者ID:chilimatic,项目名称:datastructure-component,代码行数:14,代码来源:Collection.php

示例10: testSetParentOnItself

 /**
  * @expectedException \InvalidArgumentException
  */
 public function testSetParentOnItself()
 {
     $node = new Node();
     $node->setParent($node);
 }
开发者ID:jacobjjc,项目名称:PageKit-framework,代码行数:8,代码来源:NodeTest.php

示例11: addChild

 function addChild(Node $node)
 {
     $this->children[$node->name] = $node;
     $node->setParent($this);
 }
开发者ID:mubasharkk,项目名称:visualize,代码行数:5,代码来源:Node.php

示例12: addChild

 /**
  * Add a node as child of this node.
  *
  * @param Node $child
  * @return $this
  */
 public function addChild(Node $child)
 {
     $this->children[] = $child;
     $child->setParent($this);
     return $this;
 }
开发者ID:fluxbb,项目名称:commonmark,代码行数:12,代码来源:Container.php


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