em = $em; $this->tokenStorage = $tokenStorage; $this->authorizationHelper = $authorizationHelper; $this->paginatorFactory = $paginatorFactory; } public function getOrder(): int { return 59866; } public function isActiveByDefault(): bool { return false; } public function renderResult(array $terms, $start = 0, $limit = 50, $options = [], $format = 'html') { $centers = $this->authorizationHelper ->getReachableCenters( $this->tokenStorage->getToken()->getUser(), ThirdPartyVoter::SHOW ); $total = $this->count($centers, $terms); $paginator = $this->paginatorFactory->create($total); // replace types in terms by types in query $terms['types'] = $options[SearchInterface::REQUEST_QUERY_PARAMETERS]['t']; $terms['is_active'] = true; if ('json' === $format) { return [ 'results' => $this->thirdPartyRepository ->findByMemberOfCenters( $centers, $start, $limit, $terms, ['array', ['tp.id', 'tp.name AS text']] ), 'more' => $paginator->hasNextPage(), ]; } // format "html" throw new \UnexpectedValueException('format html not supported'); } public function supports($domain, $format): bool { return self::NAME === $domain && 'json' === $format; } protected function count($centers, $terms): int { return $this->thirdPartyRepository ->countByMemberOfCenters($centers, $terms); } }