Skip to content

Commit

Permalink
MDL-72930 navigation: Update to the participants page navigation.
Browse files Browse the repository at this point in the history
This adds the ability for the participants page to display injected
navigation nodes in the users navigation node.
  • Loading branch information
abgreeve committed Jan 4, 2022
1 parent f85662d commit ffdf385
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/classes/output/participants_action_bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,31 @@ protected function get_content_for_select(): array {
}
}

// TODO: Implement MDL-72930.
// Need to do some funky code here to find out if we have added third party navigation nodes.
$thirdpartynodearray = $this->get_thirdparty_node_array() ?: [];
$formattedcontent = array_merge($formattedcontent, $thirdpartynodearray);
return $formattedcontent;
}

/**
* Gets an array of third party navigation nodes in an array formatted for a url_select element.
*
* @return array|null The thirdparty node array.
*/
protected function get_thirdparty_node_array(): ?array {
$results = [];

$flatnodes = array_merge(...(array_values($this->get_ordered_nodes())));

foreach ($this->node->children as $child) {
if (array_search($child->key, $flatnodes) === false) {
$results[] = $child;
}
}

return \core\navigation\views\secondary::create_menu_element($results, true);
}

/**
* Recursively tries to find a matching url
* @param array $urlcontent The content for the url_select
Expand Down

0 comments on commit ffdf385

Please sign in to comment.