當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。