Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]

(no description)

File Size: 357 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: primary  - X-Ref

Primary navigation renderable

This file combines primary nav, custom menu, lang menu and
usermenu into a standardized format for the frontend

__construct($page)   X-Ref
primary constructor.

param: \moodle_page $page

export_for_template(?renderer_base $output = null)   X-Ref
Combine the various menus into a standardized output.

param: renderer_base|null $output
return: array

get_primary_nav($parent = null)   X-Ref
Get the primary nav object and standardize the output

param: \navigation_node|null $parent used for nested nodes, by default the primarynav node
return: array

get_custom_menu(renderer_base $output)   X-Ref
Custom menu items reside on the same level as the original nodes.
Fetch and convert the nodes to a standardised array.

param: renderer_base $output
return: array

merge_primary_and_custom(array $primary, array $custom, bool $expandedmenu = false)   X-Ref
When defining custom menu items, the active flag is not obvserved correctly. Therefore, the merge of the primary
and custom navigation must be handled a bit smarter. Change the "isactive" flag of the nodes (this may set by
default in the primary nav nodes but is entirely missing in the custom nav nodes).
Set the $expandedmenu argument to true when the menu for the mobile template is build.

param: array $primary
param: array $custom
param: bool $expandedmenu
return: array

flag_active_nodes(object $node, bool $expandedmenu = false)   X-Ref
Recursive checks if any of the children is active. If that's the case this node (the parent) is active as
well. If the node has no children, check if the node itself is active. Use pass by reference for the node
object because we actively change/set the "isactive" flag inside the method and this needs to be kept at the
callers side.
Set $expandedmenu to true, if the mobile menu is done, in this case the active flag gets the node that is
actually active, while the parent hierarchy of the active node gets the flag isopen.

param: object $node
param: bool $expandedmenu
return: bool

get_user_menu(renderer_base $output)   X-Ref
Get/Generate the user menu.

This is leveraging the data from user_get_user_navigation_info and the logic in $OUTPUT->user_menu()

param: renderer_base $output
return: array