protected function applyPassedResultsPerPage(SearchRequest $searchRequest)
    {
        $requestedPerPage = $searchRequest->getResultsPerPage();

        $perPageSwitchOptions = $this->typoScriptConfiguration->getSearchResultsPerPageSwitchOptionsAsArray();
        if (isset($requestedPerPage) && in_array($requestedPerPage, $perPageSwitchOptions)) {
            $this->session->setPerPage($requestedPerPage);
            $searchRequest->setPage(0);
        }

        $defaultResultsPerPage = $this->typoScriptConfiguration->getSearchResultsPerPage();
        $currentNumberOfResultsShown = $defaultResultsPerPage;
        if ($this->session->getHasPerPage()) {
            $sessionResultPerPage = $this->session->getPerPage();
            if (in_array($sessionResultPerPage, $perPageSwitchOptions)) {
                $currentNumberOfResultsShown = (int)$sessionResultPerPage;
            }
        }

        if ($this->shouldHideResultsFromInitialSearch($searchRequest)) {
            // initialize search with an empty query, which would by default return all documents
            // anyway, tell Solr to not return any result documents
            // Solr will still return facets though
            $currentNumberOfResultsShown = 0;
        }

        $searchRequest->setResultsPerPage($currentNumberOfResultsShown);

        return $searchRequest;
    }
protected function applyPassedResultsPerPage(SearchRequest $searchRequest)
    {
        $requestedPerPage = $searchRequest->getResultsPerPage();

        $perPageSwitchOptions = $this->typoScriptConfiguration->getSearchResultsPerPageSwitchOptionsAsArray();
        if (isset($requestedPerPage) && in_array($requestedPerPage, $perPageSwitchOptions)) {
            $this->session->setPerPage($requestedPerPage);
            $searchRequest->setPage(0);
        }

        $defaultResultsPerPage = $this->typoScriptConfiguration->getSearchResultsPerPage();
        $currentNumberOfResultsShown = $defaultResultsPerPage;
        if ($this->session->getHasPerPage()) {
            $sessionResultPerPage = $this->session->getPerPage();
            if (in_array($sessionResultPerPage, $perPageSwitchOptions)) {
                $currentNumberOfResultsShown = (int)$sessionResultPerPage;
            }
        }

        if ($this->shouldHideResultsFromInitialSearch($searchRequest)) {
            // initialize search with an empty query, which would by default return all documents
            // anyway, tell Solr to not return any result documents
            // Solr will still return facets though
            $currentNumberOfResultsShown = 0;
        }

        $searchRequest->setResultsPerPage($currentNumberOfResultsShown);

        return $searchRequest;
    }
protected function applyPassedResultsPerPage ( SearchRequest $ searchRequest ) { $ requestedPerPage = $ searchRequest -> getResultsPerPage ( ) ; $ perPageSwitchOptions = $ this -> typoScriptConfiguration -> getSearchResultsPerPageSwitchOptionsAsArray ( ) ; if ( isset ( $ requestedPerPage ) && in_array ( $ requestedPerPage , $ perPageSwitchOptions ) ) { $ this -> session -> setPerPage ( $ requestedPerPage ) ; $ searchRequest -> setPage ( 0 ) ; } $ defaultResultsPerPage = $ this -> typoScriptConfiguration -> getSearchResultsPerPage ( ) ; $ currentNumberOfResultsShown = $ defaultResultsPerPage ; if ( $ this -> session -> getHasPerPage ( ) ) { $ sessionResultPerPage = $ this -> session -> getPerPage ( ) ; if ( in_array ( $ sessionResultPerPage , $ perPageSwitchOptions ) ) { $ currentNumberOfResultsShown = ( int ) $ sessionResultPerPage ; } } if ( $ this -> shouldHideResultsFromInitialSearch ( $ searchRequest ) ) { // initialize search with an empty query, which would by default return all documents // anyway, tell Solr to not return any result documents // Solr will still return facets though $ currentNumberOfResultsShown = 0 ; } $ searchRequest -> setResultsPerPage ( $ currentNumberOfResultsShown ) ; return $ searchRequest ; }
Checks if the passed resultsPerPageValue is valid and applies it. If the perPage value was changed it is stored in
the session and the current page is set to 0, since the pagination should start from the beginning then.

@param SearchRequest $searchRequest
@return SearchRequest
Checks if the passed resultsPerPageValue is valid and applies it . If the perPage value was changed it is stored in the session and the current page is set to 0 since the pagination should start from the beginning then .