public function prepare(OptionList $objOptions = null): OptionList
    {
        if (is_null($objOptions)) {
            $objOptions = new OptionList;
        }

        // Page
        if ('post' == $this->options->get('method')) {
            $requestBody = $this->serverRequest->getParsedBody();

            if (is_array($requestBody) && !empty($requestBody[$this->getParam()])) {
                $this->page = intval($requestBody[$this->getParam()]);
            } else {
                $this->page = 1;
            }
        } else {
            $queryParams = $this->serverRequest->getQueryParams();

            if (is_array($queryParams) && !empty($queryParams[$this->getParam()])) {
                $this->page = intval($queryParams[$this->getParam()]);
            } else {
                $this->page = 1;
            }
        }

        // Nb per page
        $this->nb_per_page = $this->options->is_int('nb_per_page') ? $this->options->get('nb_per_page') : 20;

        // Obj _b_options
        $objOptions->set('limitStart', $this->nb_per_page * ($this->page - 1));
        $objOptions->set('limitEnd', $objOptions->get('limitStart') + $this->nb_per_page);
        $objOptions->set('limitNb', $this->nb_per_page);

        return $objOptions;
    }
public function prepare(OptionList $objOptions = null): OptionList
    {
        if (is_null($objOptions)) {
            $objOptions = new OptionList;
        }

        // Page
        if ('post' == $this->options->get('method')) {
            $requestBody = $this->serverRequest->getParsedBody();

            if (is_array($requestBody) && !empty($requestBody[$this->getParam()])) {
                $this->page = intval($requestBody[$this->getParam()]);
            } else {
                $this->page = 1;
            }
        } else {
            $queryParams = $this->serverRequest->getQueryParams();

            if (is_array($queryParams) && !empty($queryParams[$this->getParam()])) {
                $this->page = intval($queryParams[$this->getParam()]);
            } else {
                $this->page = 1;
            }
        }

        // Nb per page
        $this->nb_per_page = $this->options->is_int('nb_per_page') ? $this->options->get('nb_per_page') : 20;

        // Obj _b_options
        $objOptions->set('limitStart', $this->nb_per_page * ($this->page - 1));
        $objOptions->set('limitEnd', $objOptions->get('limitStart') + $this->nb_per_page);
        $objOptions->set('limitNb', $this->nb_per_page);

        return $objOptions;
    }
public function prepare ( OptionList $ objOptions = null ) : OptionList { if ( is_null ( $ objOptions ) ) { $ objOptions = new OptionList ; } // Page if ( 'post' == $ this -> options -> get ( 'method' ) ) { $ requestBody = $ this -> serverRequest -> getParsedBody ( ) ; if ( is_array ( $ requestBody ) && ! empty ( $ requestBody [ $ this -> getParam ( ) ] ) ) { $ this -> page = intval ( $ requestBody [ $ this -> getParam ( ) ] ) ; } else { $ this -> page = 1 ; } } else { $ queryParams = $ this -> serverRequest -> getQueryParams ( ) ; if ( is_array ( $ queryParams ) && ! empty ( $ queryParams [ $ this -> getParam ( ) ] ) ) { $ this -> page = intval ( $ queryParams [ $ this -> getParam ( ) ] ) ; } else { $ this -> page = 1 ; } } // Nb per page $ this -> nb_per_page = $ this -> options -> is_int ( 'nb_per_page' ) ? $ this -> options -> get ( 'nb_per_page' ) : 20 ; // Obj _b_options $ objOptions -> set ( 'limitStart' , $ this -> nb_per_page * ( $ this -> page - 1 ) ) ; $ objOptions -> set ( 'limitEnd' , $ objOptions -> get ( 'limitStart' ) + $ this -> nb_per_page ) ; $ objOptions -> set ( 'limitNb' , $ this -> nb_per_page ) ; return $ objOptions ; }
Prepare the OptionList for Collection.

This method complete OptionList for Collection with some
_b_options for SQL query like limitStart, limitEnd and limitNb.
This _b_options must be implemented in DB queries in Collection
get methods.

@param OptionList $objOptions OptionList object with _b_options for Collection object

@return OptionList OptionList given in param completed
Prepare the OptionList for Collection .