本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例5: addChild
/**
* @param \Herbie\Node $child
*/
public function addChild(Node $child)
{
$child->setParent($this);
$this->children[] = $child;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例10: testSetParentOnItself
/**
* @expectedException \InvalidArgumentException
*/
public function testSetParentOnItself()
{
$node = new Node();
$node->setParent($node);
}
示例11: addChild
function addChild(Node $node)
{
$this->children[$node->name] = $node;
$node->setParent($this);
}
示例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;
}