title = $title; $this->url = $url; $this->first = false; $this->last = false; } /** * Return an array of Breadcrumb instances build from the parents of a given item. * The first and last Breadcrumb instances will be marked first/last as appropriate. * Each breadcrumb will have a ?show= query parameter that refers to the id of the next * item in line. * * @return array Breadcrumb instances */ static function array_from_item_parents($item) { if ($item->id == item::root()->id) { return array(); } $bc = array_merge($item->parents()->as_array(), array($item)); for ($i = 0; $i < count($bc) - 1; $i++) { $bc[$i] = new Breadcrumb($bc[$i]->title, $bc[$i]->url("show={$bc[$i+1]->id}")); } $bc[$i] = new Breadcrumb($item->title, $item->url()); $bc[0]->set_first(); end($bc)->set_last(); return $bc; } public function set_first() { $this->first = true; return $this; } public function set_last() { $this->last = true; return $this; } }