Skip to content

Commit

Permalink
Merge branch 'MDL-73645-integration-master' of https://github.com/mih…
Browse files Browse the repository at this point in the history
  • Loading branch information
snake committed Mar 3, 2022
2 parents 8d362e7 + 5de4513 commit 350d7b9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions theme/boost/classes/boostnavbar.php
Expand Up @@ -72,9 +72,9 @@ protected function prepare_nodes_for_boost(): void {
$this->remove('mycourses');
$this->remove('courses');
// Remove the course category breadcrumb node.
$this->remove($this->page->course->category);
$this->remove($this->page->course->category, \breadcrumb_navigation_node::TYPE_CATEGORY);
// Remove the course breadcrumb node.
$this->remove($this->page->course->id);
$this->remove($this->page->course->id, \breadcrumb_navigation_node::TYPE_COURSE);
// Remove the navbar nodes that already exist in the secondary navigation menu.
$this->remove_items_that_exist_in_navigation($PAGE->secondarynav);

Expand Down Expand Up @@ -102,7 +102,7 @@ protected function prepare_nodes_for_boost(): void {
$this->remove('mycourses');
$this->remove('courses');
// Remove the course category breadcrumb node.
$this->remove($this->page->course->category);
$this->remove($this->page->course->category, \breadcrumb_navigation_node::TYPE_CATEGORY);
$courseformat = course_get_format($this->page->course)->get_course();
// Section items can be only removed if a course layout (coursedisplay) is not explicitly set in the
// given course format or the set course layout is not 'One section per page'.
Expand Down Expand Up @@ -181,12 +181,18 @@ protected function item_count(): int {
* Remove a boostnavbaritem from the boost navbar.
*
* @param string|int $itemkey An identifier for the boostnavbaritem
* @param int|null $itemtype An additional type identifier for the boostnavbaritem (optional)
*/
protected function remove($itemkey): void {
protected function remove($itemkey, ?int $itemtype = null): void {

$itemfound = false;
foreach ($this->items as $key => $item) {
if ($item->key === $itemkey) {
// If a type identifier is also specified, check whether the type of the breadcrumb item matches the
// specified type. Skip if types to not match.
if (!is_null($itemtype) && $item->type !== $itemtype) {
continue;
}
unset($this->items[$key]);
$itemfound = true;
break;
Expand Down

0 comments on commit 350d7b9

Please sign in to comment.