public function getAllProfilesAction()
    {
        $profiles = [];
        /** @var Repository $repo */
        $repo = $this->get($this->getParameter('ongr_settings.repo'));

        $search = $repo->createSearch();
        $search->addAggregation(new TermsAggregation('profiles', 'profile'));

        /** @var DocumentIterator $result */
        $result = $repo->findDocuments($search);

        /** @var AggregationValue $agg */
        foreach ($result->getAggregation('profiles') as $agg) {
            $profiles[] = $agg->getValue('key');
        }

        if (empty($profiles) || !in_array('default', $profiles)) {
            array_unshift($profiles, 'default');
        }

        return new JsonResponse($profiles);
    }
public function getAllProfilesAction()
    {
        $profiles = [];
        /** @var Repository $repo */
        $repo = $this->get($this->getParameter('ongr_settings.repo'));

        $search = $repo->createSearch();
        $search->addAggregation(new TermsAggregation('profiles', 'profile'));

        /** @var DocumentIterator $result */
        $result = $repo->findDocuments($search);

        /** @var AggregationValue $agg */
        foreach ($result->getAggregation('profiles') as $agg) {
            $profiles[] = $agg->getValue('key');
        }

        if (empty($profiles) || !in_array('default', $profiles)) {
            array_unshift($profiles, 'default');
        }

        return new JsonResponse($profiles);
    }
public function getAllProfilesAction ( ) { $ profiles = [ ] ; /** @var Repository $repo */ $ repo = $ this -> get ( $ this -> getParameter ( 'ongr_settings.repo' ) ) ; $ search = $ repo -> createSearch ( ) ; $ search -> addAggregation ( new TermsAggregation ( 'profiles' , 'profile' ) ) ; /** @var DocumentIterator $result */ $ result = $ repo -> findDocuments ( $ search ) ; /** @var AggregationValue $agg */ foreach ( $ result -> getAggregation ( 'profiles' ) as $ agg ) { $ profiles [ ] = $ agg -> getValue ( 'key' ) ; } if ( empty ( $ profiles ) || ! in_array ( 'default' , $ profiles ) ) { array_unshift ( $ profiles , 'default' ) ; } return new JsonResponse ( $ profiles ) ; }
Returns a json list of profiles

@return JsonResponse
Returns a json list of profiles