phoneNumberHelper->getFormattedNumberList($number); $qb = $this->connection->createQueryBuilder(); $foundContacts = $qb->select('l.id') ->from(MAUTIC_TABLE_PREFIX.'leads', 'l') ->where( $qb->expr()->or( 'l.mobile IN (:numbers)', 'l.phone IN (:numbers)' ) ) ->setParameter('numbers', $searchForNumbers, ArrayParameterType::STRING) ->executeQuery() ->fetchAllAssociative(); $ids = array_column($foundContacts, 'id'); if (0 === count($ids)) { throw new NumberNotFoundException($number); } $collection = new ArrayCollection(); /** @var Lead[] $contacts */ $contacts = $this->leadRepository->getEntities(['ids' => $ids]); foreach ($contacts as $contact) { $collection->set($contact->getId(), $contact); } return $collection; } }