Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Protected Attributes | List of all members
custom_menu_item Class Reference
Inheritance diagram for custom_menu_item:
renderable templatable custom_menu

Public Member Functions

 __construct ($text, moodle_url $url=null, $title=null, $sort=null, custom_menu_item $parent=null)
 Constructs the new custom menu item. More...
 
 add ($text, moodle_url $url=null, $title=null, $sort=null)
 Adds a custom menu item as a child of this node given its properties. More...
 
 export_for_template (renderer_base $output)
 Export this data so it can be used as the context for a mustache template. More...
 
 get_children ()
 Sorts and returns the children for this item. More...
 
 get_parent ()
 Gets the parent this child belong to. More...
 
 get_sort_order ()
 Gets the sort order for this child. More...
 
 get_text ()
 Returns the text for this item. More...
 
 get_title ()
 Returns the title for this item. More...
 
 get_url ()
 Returns the url for this item. More...
 
 has_children ()
 Returns true if this item has any children. More...
 
 remove_child (custom_menu_item $menuitem)
 Removes a custom menu item that is a child or descendant to the current menu. More...
 
 set_text ($text)
 Sets the text for the node. More...
 
 set_title ($title)
 Sets the title for the node. More...
 
 set_url (moodle_url $url)
 Sets the url for the node. More...
 
 sort ()
 Sorts the children this item has.
 

Protected Attributes

array $children = array()
 A array in which to store children this item has.
 
int $lastsort = 0
 A reference to the sort var of the last child that was added.
 
custom_menu_item $parent
 A reference to the parent for this item or NULL if it is a top level item.
 
int $sort
 A sort order for the item, not necessary if you order things in the CFG var.
 
string $text
 The text to show for the item.
 
string $title
 A title to apply to the item. More...
 
moodle_url $url
 The link to give the icon if it has no children.
 

Constructor & Destructor Documentation

◆ __construct()

custom_menu_item::__construct (   $text,
moodle_url  $url = null,
  $title = null,
  $sort = null,
custom_menu_item  $parent = null 
)

Constructs the new custom menu item.

Parameters
string$text
moodle_url$urlA moodle url to apply as the link for this item [Optional]
string$titleA title to apply to this item [Optional]
int$sortA sort or to use if we need to sort differently [Optional]
custom_menu_item$parentA reference to the parent custom_menu_item this child belongs to, only if the child has a parent. [Optional]

Member Function Documentation

◆ add()

custom_menu_item::add (   $text,
moodle_url  $url = null,
  $title = null,
  $sort = null 
)

Adds a custom menu item as a child of this node given its properties.

Parameters
string$text
moodle_url$url
string$title
int$sort
Return values
custom_menu_item

◆ export_for_template()

custom_menu_item::export_for_template ( renderer_base  $output)

Export this data so it can be used as the context for a mustache template.

Parameters
renderer_base$outputUsed to do a final render of any components that need to be rendered for export.
Return values
array

Implements templatable.

◆ get_children()

custom_menu_item::get_children ( )

Sorts and returns the children for this item.

Return values
array

◆ get_parent()

custom_menu_item::get_parent ( )

Gets the parent this child belong to.

Return values
custom_menu_item

◆ get_sort_order()

custom_menu_item::get_sort_order ( )

Gets the sort order for this child.

Return values
int

◆ get_text()

custom_menu_item::get_text ( )

Returns the text for this item.

Return values
string

◆ get_title()

custom_menu_item::get_title ( )

Returns the title for this item.

Return values
string

◆ get_url()

custom_menu_item::get_url ( )

Returns the url for this item.

Return values
moodle_url

◆ has_children()

custom_menu_item::has_children ( )

Returns true if this item has any children.

Return values
bool

◆ remove_child()

custom_menu_item::remove_child ( custom_menu_item  $menuitem)

Removes a custom menu item that is a child or descendant to the current menu.

Returns true if child was found and removed.

Parameters
custom_menu_item$menuitem
Return values
bool

◆ set_text()

custom_menu_item::set_text (   $text)

Sets the text for the node.

Parameters
string$text

◆ set_title()

custom_menu_item::set_title (   $title)

Sets the title for the node.

Parameters
string$title

◆ set_url()

custom_menu_item::set_url ( moodle_url  $url)

Sets the url for the node.

Parameters
moodle_url$url

Member Data Documentation

◆ $title

string custom_menu_item::$title
protected

A title to apply to the item.

By default the text


The documentation for this class was generated from the following file: