Merge branch 'master' into feature/multiple-hotelcodes
This commit is contained in:
@@ -43,7 +43,7 @@ class HotelDataProvider
|
||||
$hotels = [];
|
||||
|
||||
foreach ($this->getAll() as $hotel) {
|
||||
if (str_starts_with($hotel->getCode(), $code)) {
|
||||
if (str_starts_with($hotel->getCode(), $code) || str_ends_with($hotel->getCode(), $code)) {
|
||||
$hotels[] = $hotel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Controller\HouseManager;
|
||||
|
||||
use App\BusProNet\DataProvider\HotelDataProvider;
|
||||
use App\Entity\User;
|
||||
use App\Repository\DispositionRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@@ -12,10 +11,8 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class IndexController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly HotelDataProvider $hotelDataProvider,
|
||||
private readonly DispositionRepository $dispositionRepository
|
||||
) {
|
||||
public function __construct(private readonly DispositionRepository $dispositionRepository)
|
||||
{
|
||||
}
|
||||
|
||||
#[Route('/house-manager', name: 'app_house_manager_index')]
|
||||
@@ -25,11 +22,6 @@ class IndexController extends AbstractController
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
|
||||
$hotels = $this
|
||||
->hotelDataProvider
|
||||
->findByCode($user->getHotelCode())
|
||||
;
|
||||
|
||||
$newDispositions = $this
|
||||
->dispositionRepository
|
||||
->findNewDispositionsByHotelCodes($user->getHotelCodes())
|
||||
|
||||
@@ -70,20 +70,18 @@ class DispositionVoter extends Voter
|
||||
return false;
|
||||
}
|
||||
|
||||
$hotels = $this
|
||||
->hotelDataProvider
|
||||
->findByCode($token->getUser()->getHotelCode())
|
||||
;
|
||||
$hotelBusProIds = array_map(function (Hotel $hotel) {
|
||||
return $hotel->getBusProId();
|
||||
}, $hotels);
|
||||
$destination = $disposition
|
||||
->getAssignment()
|
||||
->getDestination()
|
||||
;
|
||||
$userHotelCode = $token->getUser()->getHotelCode();
|
||||
|
||||
return in_array($destination->getHotelBusProId(), $hotelBusProIds)
|
||||
&& $destination->getDateTo() < new \DateTimeImmutable();
|
||||
$destination = $disposition
|
||||
->getAssignment()
|
||||
->getDestination()
|
||||
;
|
||||
|
||||
$isMatchingHotel = str_starts_with($destination->getHotelCode(), $userHotelCode)
|
||||
|| str_ends_with($destination->getHotelCode(), $userHotelCode);
|
||||
$isPast = $destination->getDateTo() < new \DateTimeImmutable();
|
||||
|
||||
return $isMatchingHotel && $isPast;
|
||||
}
|
||||
|
||||
private function assertTeamerAccess(Disposition $disposition): bool
|
||||
|
||||
Reference in New Issue
Block a user