mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-35655 Navigation - Generalized fetching method of navigation object and renderer in navigation block
This commit is contained in:
parent
5d6285c220
commit
c8ed28175e
@ -177,9 +177,10 @@ class block_navigation extends block_base {
|
||||
$trimlength = (int)$this->config->trimlength;
|
||||
}
|
||||
|
||||
// Initialise (only actually happens if it hasn't already been done yet
|
||||
$this->page->navigation->initialise();
|
||||
$navigation = clone($this->page->navigation);
|
||||
// Get the navigation object or don't display the block if none provided.
|
||||
if (!$navigation = $this->get_navigation()) {
|
||||
return null;
|
||||
}
|
||||
$expansionlimit = null;
|
||||
if (!empty($this->config->expansionlimit)) {
|
||||
$expansionlimit = $this->config->expansionlimit;
|
||||
@ -204,7 +205,7 @@ class block_navigation extends block_base {
|
||||
$options['linkcategories'] = (!empty($this->config->linkcategories) && $this->config->linkcategories == 'yes');
|
||||
|
||||
// Grab the items to display
|
||||
$renderer = $this->page->get_renderer('block_navigation');
|
||||
$renderer = $this->page->get_renderer($this->blockname);
|
||||
$this->content = new stdClass();
|
||||
$this->content->text = $renderer->navigation_tree($navigation, $expansionlimit, $options);
|
||||
|
||||
@ -214,6 +215,17 @@ class block_navigation extends block_base {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the navigation
|
||||
*
|
||||
* @return navigation_node The navigation object to display
|
||||
*/
|
||||
protected function get_navigation() {
|
||||
// Initialise (only actually happens if it hasn't already been done yet)
|
||||
$this->page->navigation->initialise();
|
||||
return clone($this->page->navigation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the attributes to set for this block
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user