mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-07 15:25:00 +00:00
Feature: allow to administrate budget resources and charges from the admin
This commit is contained in:
62
src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php
Normal file
62
src/Bundle/ChillBudgetBundle/Menu/AdminMenuBuilder.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\BudgetBundle\Menu;
|
||||
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
final class AdminMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
// all the entries below must have ROLE_ADMIN permissions
|
||||
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$menu->addChild('Budget', [
|
||||
'route' => 'chill_admin_budget',
|
||||
])
|
||||
->setAttribute('class', 'list-group-item-header')
|
||||
->setExtras([
|
||||
'order' => 7050,
|
||||
'explain' => 'Budget resource and charge type configuration',
|
||||
]);
|
||||
$menu
|
||||
->addChild('admin.menu.Resource types', [
|
||||
'route' => 'chill_crud_resource_kind_index',
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 7060,
|
||||
]);
|
||||
$menu
|
||||
->addChild('admin.menu.Charge types', [
|
||||
'route' => 'chill_crud_charge_kind_index',
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 7070,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
{
|
||||
return ['admin_section', 'admin_budget'];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user