*/ class ContingentSyncStateRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, ContingentSyncState::class); } public function findOneByHotelCode(string $hotelCode): ?ContingentSyncState { return $this->findOneBy(['hotelCode' => $hotelCode]); } /** * @return array */ public function findAllIndexedByHotelCode(): array { $indexed = []; foreach ($this->findAll() as $state) { $indexed[(string) $state->getHotelCode()] = $state; } return $indexed; } /** * Drops the sync state of every hotel code that is no longer synced. * * @param non-empty-list $hotelCodes the codes that are still synced */ public function deleteExceptHotelCodes(array $hotelCodes): int { return (int) $this->createQueryBuilder('s') ->delete() ->where('s.hotelCode NOT IN (:hotelCodes)') ->setParameter('hotelCodes', $hotelCodes) ->getQuery() ->execute(); } }