$this->assertAdministrativeAccess($token) || $this->assertTeamerAccess($token, $disposition), static::DELETE => $this->assertAdministrativeAccess($token), static::FEEDBACK => $this->assertHouseManagerAccess($token, $disposition), default => false, }; } private function assertAdministrativeAccess(TokenInterface $token): bool { return in_array('ROLE_ADMINISTRATIVE', $token->getRoleNames()); } private function assertHouseManagerAccess(TokenInterface $token, Disposition $disposition): bool { if (false === in_array('ROLE_HOUSE_MANAGER', $token->getRoleNames())) { return false; } $hotels = $this ->hotelDataProvider ->findByCode($token->getUser()->getHotelCode()) ; $hotelBusProIds = array_map(function (Hotel $hotel) { return $hotel->getBusProId(); }, $hotels); $destination = $disposition ->getAssignment() ->getDestination() ; return in_array($destination->getHotelBusProId(), $hotelBusProIds) && $destination->getDateTo() < new \DateTimeImmutable(); } private function assertTeamerAccess(TokenInterface $token, Disposition $disposition): bool { if (false === in_array('ROLE_TEAMER', $token->getRoleNames())) { return false; } return $token->getUser()->getTeamer() === $disposition->getTeamer(); } }