Merge branch 'MDL-56699-master' of git://github.com/damyon/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2016-11-09 02:11:55 +01:00
commit 6c5ee657a7

View File

@ -255,27 +255,6 @@ class navigation_node implements renderable {
return ($count > 1);
}
/**
* Recursively walk the tree looking for a node with a valid action.
* Depth first search.
*
* @return bool
*/
public function resolve_action() {
if ($this->action) {
return $this->action;
}
if (!empty($this->children)) {
foreach ($this->children as $child) {
$action = $child->resolve_action();
if (!empty($action)) {
return $action;
}
}
}
return false;
}
/**
* Get a list of sibling navigation nodes at the same level as this one.
*
@ -827,6 +806,21 @@ class navigation_node implements renderable {
}
}
}
/**
* Get the action url for this navigation node.
* Called from templates.
*
* @since Moodle 3.2
*/
public function action() {
if ($this->action instanceof moodle_url) {
return $this->action;
} else if ($this->action instanceof action_link) {
return $this->action->url;
}
return $this->action;
}
}
/**