src/Sulu/Bundle/PageBundle/Controller/SmartContentItemController.php
public function getItemsAction(Request $request)
    {
        // prepare filters and options
        $providerAlias = $this->getRequestParameter($request, 'provider', true);
        $filters = $request->query->all();
        $filters['excluded'] = array_filter(explode(',', $this->getRequestParameter($request, 'excluded')));
        if (isset($filters['categories'])) {
            $filters['categories'] = explode(',', $this->getRequestParameter($request, 'categories'));
        }
        if (isset($filters['tags'])) {
            $filters['tags'] = explode(',', $this->getRequestParameter($request, 'tags'));
        }
        if (isset($filters['sortBy'])) {
            $filters['sortBy'] = explode(',', $this->getRequestParameter($request, 'sortBy'));
        }
        $filters = array_filter($filters);
        $options = [
            'webspaceKey' => $this->getRequestParameter($request, 'webspace'),
            'locale' => $this->getLocale($request),
        ];

        // resolve tags if they exists in filters
        if (isset($filters['tags'])) {
            $filters['tags'] = $this->get('sulu_tag.tag_manager')->resolveTagNames($filters['tags']);
        }

        // prepare provider
        $dataProviderPool = $this->get('sulu_page.smart_content.data_provider_pool');
        $provider = $dataProviderPool->get($providerAlias);

        $params = array_merge(
            $provider->getDefaultPropertyParameter(),
            $this->getParams(json_decode($request->get('params', '{}'), true))
        );

        // resolve datasource and items
        $data = $provider->resolveDataItems(
            $filters,
            $params,
            $options,
            (isset($filters['limitResult']) ? $filters['limitResult'] : null)
        );
        $items = $data->getItems();
        $datasource = $provider->resolveDatasource($request->get('dataSource'), [], $options);

        return $this->handleView($this->view(new ItemCollectionRepresentation($items, $datasource)));
    }
public function getItemsAction(Request $request)
    {
        // prepare filters and options
        $providerAlias = $this->getRequestParameter($request, 'provider', true);
        $filters = $request->query->all();
        $filters['excluded'] = array_filter(explode(',', $this->getRequestParameter($request, 'excluded')));
        if (isset($filters['categories'])) {
            $filters['categories'] = explode(',', $this->getRequestParameter($request, 'categories'));
        }
        if (isset($filters['tags'])) {
            $filters['tags'] = explode(',', $this->getRequestParameter($request, 'tags'));
        }
        if (isset($filters['sortBy'])) {
            $filters['sortBy'] = explode(',', $this->getRequestParameter($request, 'sortBy'));
        }
        $filters = array_filter($filters);
        $options = [
            'webspaceKey' => $this->getRequestParameter($request, 'webspace'),
            'locale' => $this->getLocale($request),
        ];

        // resolve tags if they exists in filters
        if (isset($filters['tags'])) {
            $filters['tags'] = $this->get('sulu_tag.tag_manager')->resolveTagNames($filters['tags']);
        }

        // prepare provider
        $dataProviderPool = $this->get('sulu_page.smart_content.data_provider_pool');
        $provider = $dataProviderPool->get($providerAlias);

        $params = array_merge(
            $provider->getDefaultPropertyParameter(),
            $this->getParams(json_decode($request->get('params', '{}'), true))
        );

        // resolve datasource and items
        $data = $provider->resolveDataItems(
            $filters,
            $params,
            $options,
            (isset($filters['limitResult']) ? $filters['limitResult'] : null)
        );
        $items = $data->getItems();
        $datasource = $provider->resolveDatasource($request->get('dataSource'), [], $options);

        return $this->handleView($this->view(new ItemCollectionRepresentation($items, $datasource)));
    }
public function getItemsAction ( Request $ request ) { // prepare filters and options $ providerAlias = $ this -> getRequestParameter ( $ request , 'provider' , true ) ; $ filters = $ request -> query -> all ( ) ; $ filters [ 'excluded' ] = array_filter ( explode ( ',' , $ this -> getRequestParameter ( $ request , 'excluded' ) ) ) ; if ( isset ( $ filters [ 'categories' ] ) ) { $ filters [ 'categories' ] = explode ( ',' , $ this -> getRequestParameter ( $ request , 'categories' ) ) ; } if ( isset ( $ filters [ 'tags' ] ) ) { $ filters [ 'tags' ] = explode ( ',' , $ this -> getRequestParameter ( $ request , 'tags' ) ) ; } if ( isset ( $ filters [ 'sortBy' ] ) ) { $ filters [ 'sortBy' ] = explode ( ',' , $ this -> getRequestParameter ( $ request , 'sortBy' ) ) ; } $ filters = array_filter ( $ filters ) ; $ options = [ 'webspaceKey' => $ this -> getRequestParameter ( $ request , 'webspace' ) , 'locale' => $ this -> getLocale ( $ request ) , ] ; // resolve tags if they exists in filters if ( isset ( $ filters [ 'tags' ] ) ) { $ filters [ 'tags' ] = $ this -> get ( 'sulu_tag.tag_manager' ) -> resolveTagNames ( $ filters [ 'tags' ] ) ; } // prepare provider $ dataProviderPool = $ this -> get ( 'sulu_page.smart_content.data_provider_pool' ) ; $ provider = $ dataProviderPool -> get ( $ providerAlias ) ; $ params = array_merge ( $ provider -> getDefaultPropertyParameter ( ) , $ this -> getParams ( json_decode ( $ request -> get ( 'params' , '{}' ) , true ) ) ) ; // resolve datasource and items $ data = $ provider -> resolveDataItems ( $ filters , $ params , $ options , ( isset ( $ filters [ 'limitResult' ] ) ? $ filters [ 'limitResult' ] : null ) ) ; $ items = $ data -> getItems ( ) ; $ datasource = $ provider -> resolveDatasource ( $ request -> get ( 'dataSource' ) , [ ] , $ options ) ; return $ this -> handleView ( $ this -> view ( new ItemCollectionRepresentation ( $ items , $ datasource ) ) ) ; }
Resolves filter for smart-content UI.

@param Request $request

@return \Symfony\Component\HttpFoundation\Response

@throws \Sulu\Component\Rest\Exception\MissingParameterException
@throws \Sulu\Component\SmartContent\Exception\DataProviderNotExistsException
Resolves filter for smart - content UI .