Feature: allow to administrate budget resources and charges from the admin

This commit is contained in:
2023-01-23 20:40:01 +00:00
parent 99482edf0d
commit c4eb45edcc
57 changed files with 1546 additions and 49 deletions

View 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'];
}
}