$this->security->isGranted('ROLE_ADMINISTRATIVE') || $this->assertTeamerAccess($token, $disposition), static::DELETE => $this->security->isGranted('ROLE_ADMIN'), static::FEEDBACK => $this->security->isGranted('ROLE_ADMINISTRATIVE') || $this->assertHouseManagerAccess($token, $disposition), default => false, }; } private function assertHouseManagerAccess(TokenInterface $token, Disposition $disposition): bool { if (false === $this->security->isGranted('ROLE_HOUSE_MANAGER')) { return false; } /** @var User $user */ $user = $token->getUser(); $destination = $disposition ->getAssignment() ->getDestination() ; $isMatchingHotel = $user->hasHotelCodeMatch($destination->getHotelCode()); $isPast = $destination->getDateTo() < new \DateTimeImmutable(); return $isMatchingHotel && $isPast; } private function assertTeamerAccess(TokenInterface $token, Disposition $disposition): bool { if (false === $this->security->isGranted('ROLE_TEAMER')) { return false; } /** @var User $user */ $user = $token->getUser(); return $user->getTeamer() === $disposition->getTeamer(); } }