fix: adopt multiple hotel codes
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Security\Voter;
|
||||
|
||||
use App\BusProNet\DataProvider\HotelDataProvider;
|
||||
use App\BusProNet\Model\Hotel;
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
@@ -19,10 +17,8 @@ class DispositionVoter extends Voter
|
||||
public const INVOICE = 'INVOICE';
|
||||
public const FEEDBACK = 'FEEDBACK';
|
||||
|
||||
public function __construct(
|
||||
private readonly Security $security,
|
||||
private readonly HotelDataProvider $hotelDataProvider
|
||||
) {
|
||||
public function __construct(private readonly Security $security)
|
||||
{
|
||||
}
|
||||
|
||||
protected function supports(string $attribute, mixed $subject): bool
|
||||
@@ -70,15 +66,15 @@ class DispositionVoter extends Voter
|
||||
return false;
|
||||
}
|
||||
|
||||
$userHotelCode = $token->getUser()->getHotelCode();
|
||||
/** @var User $user */
|
||||
$user = $token->getUser();
|
||||
|
||||
$destination = $disposition
|
||||
->getAssignment()
|
||||
->getDestination()
|
||||
;
|
||||
|
||||
$isMatchingHotel = str_starts_with($destination->getHotelCode(), $userHotelCode)
|
||||
|| str_ends_with($destination->getHotelCode(), $userHotelCode);
|
||||
$isMatchingHotel = $user->hasHotelCodeMatch($destination->getHotelCode());
|
||||
$isPast = $destination->getDateTo() < new \DateTimeImmutable();
|
||||
|
||||
return $isMatchingHotel && $isPast;
|
||||
|
||||
Reference in New Issue
Block a user