diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 73913f2f21a..9d45700cff9 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -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; + } } /**