public function __construct(KernelInterface $kernel)
{
parent::__construct($kernel);
// store in reference
$this->getContainer()->set('breadcrumb', $this);
// get more information for the homepage
$homeInfo = Navigation::getPageInfo(1);
// add homepage as first item (with correct element)
$this->addElement($homeInfo['navigation_title'], Navigation::getURL(1));
// get other pages
$pages = $this->URL->getPages();
// init vars
$items = array();
$errorURL = Navigation::getURL(404);
// loop pages
while (!empty($pages)) {
// init vars
$url = implode('/', $pages);
$menuId = Navigation::getPageId($url);
$pageInfo = Navigation::getPageInfo($menuId);
// do we know something about the page
if ($pageInfo !== false && isset($pageInfo['navigation_title'])) {
// only add pages that aren't direct actions
if ($pageInfo['tree_type'] != 'direct_action') {
// get URL
$pageURL = Navigation::getURL($menuId);
// if this is the error-page, so we won't show an URL.
if ($pageURL == $errorURL) {
$pageURL = null;
}
// add to the items
$items[] = array('title' => $pageInfo['navigation_title'], 'url' => $pageURL);
}
}
// remove element
array_pop($pages);
}
// reverse so everything is in place
krsort($items);
// loop and add elements
foreach ($items as $row) {
$this->addElement($row['title'], $row['url']);
}
}