+
+ /**
+ * Prepends a new navigation_node to the start of the navbar
+ *
+ * @param string $text
+ * @param string|moodle_url|action_link $action An action to associate with this node.
+ * @param int $type One of navigation_node::TYPE_*
+ * @param string $shorttext
+ * @param string|int $key A key to identify this node with. Key + type is unique to a parent.
+ * @param pix_icon $icon An optional icon to use for this node.
+ * @return navigation_node
+ */
+ public function prepend($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, pix_icon $icon=null) {
+ if ($this->content !== null) {
+ debugging('Nav bar items must be printed before $OUTPUT->header() has been called', DEBUG_DEVELOPER);
+ }
+ // Properties array used when creating the new navigation node
+ $itemarray = array(
+ 'text' => $text,
+ 'type' => $type
+ );
+ // Set the action if one was provided
+ if ($action!==null) {
+ $itemarray['action'] = $action;
+ }
+ // Set the shorttext if one was provided
+ if ($shorttext!==null) {
+ $itemarray['shorttext'] = $shorttext;
+ }
+ // Set the icon if one was provided
+ if ($icon!==null) {
+ $itemarray['icon'] = $icon;
+ }
+ // Default the key to the number of children if not provided
+ if ($key === null) {
+ $key = count($this->children);
+ }
+ // Set the key
+ $itemarray['key'] = $key;
+ // Set the parent to this node
+ $itemarray['parent'] = $this;
+ // Add the child node to the prepend list.
+ $this->prependchildren[] = new navigation_node($itemarray);
+ return $this;
+ }