Skip to content

Commit

Permalink
Add some items on dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mklkj committed Aug 6, 2018
1 parent 01cdd8f commit cceadc4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/framework/View/AdminView.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function pageNav($type, $nesting, $classes, array $before = [], array $af
{
$nav = new Navigation();
$nav->setType($type);
$nav->setItems(self::$menuItemsCollection);
$nav->setItems($this->getMenuItems());
$nav->setCurrent(self::$request);
$nav->setClasses($classes);
$nav->setNesting($nesting);
Expand Down Expand Up @@ -143,6 +143,11 @@ private function getBreadcrumbElements()
return $array;
}

protected function getMenuItems()
{
return self::$menuItemsCollection;
}

/**
* @return string
*/
Expand Down
17 changes: 17 additions & 0 deletions src/module/Dashboard/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Rudolf\Modules\Dashboard;

use Rudolf\Component\Helpers\Navigation\MenuItem;
use Rudolf\Framework\View\AdminView;

class View extends AdminView
Expand All @@ -13,4 +14,20 @@ public function dashboard()

$this->template = 'dashboard';
}

public function getMenuCollection()
{
$items = array_filter($this->getMenuItems()->getAll(), function($a) {
/** @var MenuItem $a */
return 0 === $a->getParentId() && 'main' === $a->getType();
});

usort($items, function($a, $b) {
/** @var MenuItem $a */
/** @var MenuItem $b */
return $a->getPosition() > $b->getPosition();
});

return $items;
}
}

0 comments on commit cceadc4

Please sign in to comment.