Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Protected Attributes | List of all members
flat_navigation Class Reference

Class used to generate a collection of navigation nodes most closely related to the current page. More...

Inheritance diagram for flat_navigation:
navigation_node_collection

Public Member Functions

 __construct (moodle_page &$page)
 Constructor. More...
 
 add (navigation_node $node, $beforekey=null)
 Override the parent so we can set a label for this collection if it has not been set yet. More...
 
 count ()
 Gets the number of nodes in this collection. More...
 
 find ($key, $type=null)
 Searches for a node with matching key and type. More...
 
 get ($key, $type=null)
 Fetches a node from this collection. More...
 
 get_collectionlabel ()
 Return a label for this collection. More...
 
 get_key_list ()
 Return a list of all the keys of all the nodes. More...
 
 getIterator ()
 Gets an array iterator for the collection. More...
 
 initialise ()
 Build the list of navigation nodes based on the current navigation and settings trees.
 
 last ()
 Fetches the last node that was added to this collection. More...
 
 remove ($key, $type=null)
 Removes the node with the given key and type from the collection. More...
 
 set_collectionlabel ($label)
 Set a label for this collection. More...
 
 type ($type)
 Fetches all nodes of a given type from this collection. More...
 

Protected Attributes

array $collection = array()
 A multidimensional array to where the first key is the type and the second key is the nodes key.
 
string $collectionlabel = ''
 Label for collection of nodes.
 
int $count = 0
 The total number of items added to this array.
 
navigation_node $last = null
 A reference to the last node that was added to the collection.
 
array $orderedcollection = array()
 An array that contains references to nodes in the same order they were added. More...
 
moodle_page $page
 the moodle page that the navigation belongs to
 

Detailed Description

Class used to generate a collection of navigation nodes most closely related to the current page.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

flat_navigation::__construct ( moodle_page $page)

Constructor.

Parameters
moodle_page$page

Member Function Documentation

◆ add()

flat_navigation::add ( navigation_node  $node,
  $beforekey = null 
)

Override the parent so we can set a label for this collection if it has not been set yet.

Parameters
navigation_node$nodeNode to add
string$beforekeyIf specified, adds before a node with this key, otherwise adds at end
Return values
navigation_nodeAdded node

Reimplemented from navigation_node_collection.

◆ count()

navigation_node_collection::count ( )
inherited

Gets the number of nodes in this collection.

This option uses an internal count rather than counting the actual options to avoid a performance hit through the count function.

Return values
int

◆ find()

navigation_node_collection::find (   $key,
  $type = null 
)
inherited

Searches for a node with matching key and type.

This function searches both the nodes in this collection and all of the nodes in each collection belonging to the nodes in this collection.

Recursive.

Parameters
string | int$keyThe key of the node we want to find.
int$typeOne of navigation_node::TYPE_*.
Return values
navigation_node|null

◆ get()

navigation_node_collection::get (   $key,
  $type = null 
)
inherited

Fetches a node from this collection.

Parameters
string | int$keyThe key of the node we want to find.
int$typeOne of navigation_node::TYPE_*.
Return values
navigation_node|null

◆ get_collectionlabel()

navigation_node_collection::get_collectionlabel ( )
inherited

Return a label for this collection.

Return values
string

◆ get_key_list()

navigation_node_collection::get_key_list ( )
inherited

Return a list of all the keys of all the nodes.

Return values
arraythe keys.

◆ getIterator()

navigation_node_collection::getIterator ( )
inherited

Gets an array iterator for the collection.

This is required by the IteratorAggregator interface and is used by routines such as the foreach loop.

Return values
ArrayIterator

◆ last()

navigation_node_collection::last ( )
inherited

Fetches the last node that was added to this collection.

Return values
navigation_node

◆ remove()

navigation_node_collection::remove (   $key,
  $type = null 
)
inherited

Removes the node with the given key and type from the collection.

Parameters
string | int$keyThe key of the node we want to find.
int$type
Return values
bool

◆ set_collectionlabel()

navigation_node_collection::set_collectionlabel (   $label)
inherited

Set a label for this collection.

Parameters
string$label

◆ type()

navigation_node_collection::type (   $type)
inherited

Fetches all nodes of a given type from this collection.

Parameters
string | int$typenode type being searched for.
Return values
arrayordered collection

Member Data Documentation

◆ $orderedcollection

array navigation_node_collection::$orderedcollection = array()
protectedinherited

An array that contains references to nodes in the same order they were added.

This is maintained as a progressive array.


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