public function add_item($key, $title, moodle_url $url, $method) {
        if (isset($this->items[$key])) {
            throw new coding_exception('Menu item already exists');
        }
        if (empty($title) or empty($key)) {
            throw new coding_exception('Empty title or item key not allowed');
        }
        $item = new stdclass();
        $item->title = $title;
        $item->url = $url;
        $item->method = $method;
        $this->items[$key] = $item;
    }
public function add_item($key, $title, moodle_url $url, $method) {
        if (isset($this->items[$key])) {
            throw new coding_exception('Menu item already exists');
        }
        if (empty($title) or empty($key)) {
            throw new coding_exception('Empty title or item key not allowed');
        }
        $item = new stdclass();
        $item->title = $title;
        $item->url = $url;
        $item->method = $method;
        $this->items[$key] = $item;
    }
public function add_item ( $ key , $ title , moodle_url $ url , $ method ) { if ( isset ( $ this -> items [ $ key ] ) ) { throw new coding_exception ( 'Menu item already exists' ) ; } if ( empty ( $ title ) or empty ( $ key ) ) { throw new coding_exception ( 'Empty title or item key not allowed' ) ; } $ item = new stdclass ( ) ; $ item -> title = $ title ; $ item -> url = $ url ; $ item -> method = $ method ; $ this -> items [ $ key ] = $ item ; }
Adds item into the menu

@param string $key item identifier
@param string $title localized action title
@param moodle_url $url action handler
@param string $method form method
Adds item into the menu