mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-24 10:27:46 +02:00
Menu: Provide own class for dashboard homes navigation items
This commit is contained in:
parent
c94284e9b2
commit
715adfedb1
41
library/Icinga/Web/HomeMenu.php
Normal file
41
library/Icinga/Web/HomeMenu.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Web;
|
||||||
|
|
||||||
|
use Icinga\Model\Home;
|
||||||
|
use Icinga\Web\Dashboard\Dashboard;
|
||||||
|
use Icinga\Web\Navigation\DashboardHome;
|
||||||
|
use ipl\Stdlib\Filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entrypoint of the dashboard homes
|
||||||
|
*/
|
||||||
|
class HomeMenu extends Menu
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->initHome();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initHome()
|
||||||
|
{
|
||||||
|
$user = Dashboard::getUser();
|
||||||
|
$dashboardItem = $this->getItem('dashboard');
|
||||||
|
|
||||||
|
$homes = Home::on(Dashboard::getConn());
|
||||||
|
$homes->filter(Filter::equal('username', $user->getUsername()));
|
||||||
|
|
||||||
|
foreach ($homes as $home) {
|
||||||
|
$dashboardHome = new DashboardHome($home->name, [
|
||||||
|
'uuid' => $home->id,
|
||||||
|
'label' => t($home->label),
|
||||||
|
'priority' => $home->priority,
|
||||||
|
'type' => $home->type,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$dashboardItem->addChild($dashboardHome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user