本文整理汇总了PHP中navigation_node::set_parent方法的典型用法代码示例。如果您正苦于以下问题:PHP navigation_node::set_parent方法的具体用法?PHP navigation_node::set_parent怎么用?PHP navigation_node::set_parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类navigation_node
的用法示例。
在下文中一共展示了navigation_node::set_parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_node
/**
* Adds a navigation node as a child of this one, given a $node object
* created using the create function.
* @param navigation_node $childnode Node to add
* @param string $beforekey
* @return navigation_node The added node
*/
public function add_node(navigation_node $childnode, $beforekey = null)
{
// First convert the nodetype for this node to a branch as it will now have children
if ($this->nodetype !== self::NODETYPE_BRANCH) {
$this->nodetype = self::NODETYPE_BRANCH;
}
// Set the parent to this node
$childnode->set_parent($this);
// Default the key to the number of children if not provided
if ($childnode->key === null) {
$childnode->key = $this->children->count();
}
// Add the child using the navigation_node_collections add method
$node = $this->children->add($childnode, $beforekey);
// If added node is a category node or the user is logged in and it's a course
// then mark added node as a branch (makes it expandable by AJAX)
$type = $childnode->type;
if ($type == self::TYPE_CATEGORY || isloggedin() && $type == self::TYPE_COURSE) {
$node->nodetype = self::NODETYPE_BRANCH;
}
// If this node is hidden mark it's children as hidden also
if ($this->hidden) {
$node->hidden = true;
}
// Return added node (reference returned by $this->children->add()
return $node;
}