feat: integrate with htmx
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Security\Voter;
|
||||
use App\BusProNet\DataProvider\HotelDataProvider;
|
||||
use App\BusProNet\Model\Hotel;
|
||||
use App\Entity\Disposition;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
@@ -17,8 +18,10 @@ class DispositionVoter extends Voter
|
||||
public const INVOICE = 'INVOICE';
|
||||
public const FEEDBACK = 'FEEDBACK';
|
||||
|
||||
public function __construct(private readonly HotelDataProvider $hotelDataProvider)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Security $security,
|
||||
private readonly HotelDataProvider $hotelDataProvider
|
||||
) {
|
||||
}
|
||||
|
||||
protected function supports(string $attribute, mixed $subject): bool
|
||||
@@ -52,12 +55,12 @@ class DispositionVoter extends Voter
|
||||
|
||||
private function assertAdministrativeAccess(TokenInterface $token): bool
|
||||
{
|
||||
return in_array('ROLE_ADMINISTRATIVE', $token->getRoleNames());
|
||||
return $this->security->isGranted('ROLE_ADMINISTRATIVE');
|
||||
}
|
||||
|
||||
private function assertHouseManagerAccess(TokenInterface $token, Disposition $disposition): bool
|
||||
{
|
||||
if (false === in_array('ROLE_HOUSE_MANAGER', $token->getRoleNames())) {
|
||||
if (false === $this->security->isGranted('ROLE_HOUSE_MANAGER')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -79,7 +82,7 @@ class DispositionVoter extends Voter
|
||||
|
||||
private function assertTeamerAccess(TokenInterface $token, Disposition $disposition): bool
|
||||
{
|
||||
if (false === in_array('ROLE_TEAMER', $token->getRoleNames())) {
|
||||
if (false === $this->security->isGranted('ROLE_TEAMER')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user