src/Sulu/Bundle/CategoryBundle/Controller/KeywordController.php
public function cgetAction($categoryId, Request $request)
    {
        /** @var RestHelperInterface $restHelper */
        $restHelper = $this->get('sulu_core.doctrine_rest_helper');

        /** @var DoctrineListBuilderFactory $factory */
        $factory = $this->get('sulu_core.doctrine_list_builder_factory');

        /** @var CategoryInterface $category */
        $category = $this->getCategoryRepository()->find($categoryId);

        $fieldDescriptor = $this->getFieldDescriptors();

        $listBuilder = $factory->create($this->getParameter('sulu.model.keyword.class'));
        $restHelper->initializeListBuilder($listBuilder, $fieldDescriptor);

        $listBuilder->where($fieldDescriptor['locale'], $request->get('locale'));
        $listBuilder->where(
            $fieldDescriptor['categoryTranslationIds'],
            $category->findTranslationByLocale($request->get('locale'))
        );

        // should eliminate duplicates
        $listBuilder->distinct(true);
        $listBuilder->addGroupBy($fieldDescriptor['id']);

        $listResponse = $listBuilder->execute();

        $list = new ListRepresentation(
            $listResponse,
            self::$entityKey,
            'get_category_keywords',
            array_merge(['categoryId' => $categoryId], $request->query->all()),
            $listBuilder->getCurrentPage(),
            $listBuilder->getLimit(),
            $listBuilder->count()
        );

        return $this->handleView($this->view($list, 200));
    }
public function cgetAction($categoryId, Request $request)
    {
        /** @var RestHelperInterface $restHelper */
        $restHelper = $this->get('sulu_core.doctrine_rest_helper');

        /** @var DoctrineListBuilderFactory $factory */
        $factory = $this->get('sulu_core.doctrine_list_builder_factory');

        /** @var CategoryInterface $category */
        $category = $this->getCategoryRepository()->find($categoryId);

        $fieldDescriptor = $this->getFieldDescriptors();

        $listBuilder = $factory->create($this->getParameter('sulu.model.keyword.class'));
        $restHelper->initializeListBuilder($listBuilder, $fieldDescriptor);

        $listBuilder->where($fieldDescriptor['locale'], $request->get('locale'));
        $listBuilder->where(
            $fieldDescriptor['categoryTranslationIds'],
            $category->findTranslationByLocale($request->get('locale'))
        );

        // should eliminate duplicates
        $listBuilder->distinct(true);
        $listBuilder->addGroupBy($fieldDescriptor['id']);

        $listResponse = $listBuilder->execute();

        $list = new ListRepresentation(
            $listResponse,
            self::$entityKey,
            'get_category_keywords',
            array_merge(['categoryId' => $categoryId], $request->query->all()),
            $listBuilder->getCurrentPage(),
            $listBuilder->getLimit(),
            $listBuilder->count()
        );

        return $this->handleView($this->view($list, 200));
    }
public function cgetAction ( $ categoryId , Request $ request ) { /** @var RestHelperInterface $restHelper */ $ restHelper = $ this -> get ( 'sulu_core.doctrine_rest_helper' ) ; /** @var DoctrineListBuilderFactory $factory */ $ factory = $ this -> get ( 'sulu_core.doctrine_list_builder_factory' ) ; /** @var CategoryInterface $category */ $ category = $ this -> getCategoryRepository ( ) -> find ( $ categoryId ) ; $ fieldDescriptor = $ this -> getFieldDescriptors ( ) ; $ listBuilder = $ factory -> create ( $ this -> getParameter ( 'sulu.model.keyword.class' ) ) ; $ restHelper -> initializeListBuilder ( $ listBuilder , $ fieldDescriptor ) ; $ listBuilder -> where ( $ fieldDescriptor [ 'locale' ] , $ request -> get ( 'locale' ) ) ; $ listBuilder -> where ( $ fieldDescriptor [ 'categoryTranslationIds' ] , $ category -> findTranslationByLocale ( $ request -> get ( 'locale' ) ) ) ; // should eliminate duplicates $ listBuilder -> distinct ( true ) ; $ listBuilder -> addGroupBy ( $ fieldDescriptor [ 'id' ] ) ; $ listResponse = $ listBuilder -> execute ( ) ; $ list = new ListRepresentation ( $ listResponse , self :: $ entityKey , 'get_category_keywords' , array_merge ( [ 'categoryId' => $ categoryId ] , $ request -> query -> all ( ) ) , $ listBuilder -> getCurrentPage ( ) , $ listBuilder -> getLimit ( ) , $ listBuilder -> count ( ) ) ; return $ this -> handleView ( $ this -> view ( $ list , 200 ) ) ; }
Returns list of keywords filtered by the category.

@param int $categoryId
@param Request $request

@return Response
Returns list of keywords filtered by the category .