mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Update budget element voter and improve form handling in permissions group
The base class of BudgetElementVoter has been changed to Voter, and the form handling in PermissionsGroupController has been improved for better validation. In addition, minor changes were made for better menu building and service configuration was updated. Unnecessary date validation in AbstractElement has been removed as well.
This commit is contained in:
@@ -40,7 +40,6 @@ abstract class AbstractElement
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
private ?Person $person = null;
|
||||
|
||||
#[Assert\Date]
|
||||
#[ORM\Column(name: 'startDate', type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)]
|
||||
private \DateTimeImmutable $startDate;
|
||||
|
||||
|
@@ -16,25 +16,26 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class HouseholdMenuBuilder implements LocalMenuBuilderInterface
|
||||
final readonly class HouseholdMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
public function __construct(protected AuthorizationCheckerInterface $authorizationChecker, protected TranslatorInterface $translator) {}
|
||||
public function __construct(private Security $security, private TranslatorInterface $translator) {}
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
/** @var Household $household */
|
||||
$household = $parameters['household'];
|
||||
|
||||
// if ($this->authorizationChecker->isGranted(BudgetElementVoter::SHOW, $household)) {
|
||||
$menu->addChild($this->translator->trans('household.Budget'), [
|
||||
'route' => 'chill_budget_elements_household_index',
|
||||
'routeParameters' => [
|
||||
'id' => $household->getId(),
|
||||
], ])
|
||||
->setExtras(['order' => 19]);
|
||||
// }
|
||||
if ($this->security->isGranted(BudgetElementVoter::SEE, $household)) {
|
||||
$menu->addChild($this->translator->trans('household.Budget'), [
|
||||
'route' => 'chill_budget_elements_household_index',
|
||||
'routeParameters' => [
|
||||
'id' => $household->getId(),
|
||||
], ])
|
||||
->setExtras(['order' => 19]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
|
@@ -19,8 +19,9 @@ use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
|
||||
class BudgetElementVoter extends Voter implements ProvideRoleHierarchyInterface
|
||||
{
|
||||
final public const CREATE = 'CHILL_BUDGET_ELEMENT_CREATE';
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
services:
|
||||
Chill\BudgetBundle\Security\Authorization\BudgetElementVoter:
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: security.voter }
|
||||
autoconfigure: true
|
||||
|
Reference in New Issue
Block a user