public function getParams($namespace, $defaults, $params = null)
    {
        $session        = new Container($namespace);
        $sessionParams  = $session->params ?: array();
        $params         = $params ?: clone $this->getController()->getRequest()->getQuery();
        
        if ($params->get('clear')) {
            $sessionParams = array();
            unset($params['clear']);
        }
        
        $changed = false;
        foreach ($defaults as $key => $default) {
            if (is_numeric($key)) {
                $key = $default;
                $default = null;
            }
            $value = $params->get($key);
            if (null === $value) {
                if (isset($sessionParams[$key])) {
                    $params->set($key, $sessionParams[$key]);
                } elseif (null !== $default) {
                    $params->set($key, $default);
                    $sessionParams[$key] = $default;
                    $changed = true;
                }
            } else {
                if (!isset($sessionParams[$key]) || $sessionParams[$key] != $value) {
                    $changed = true;
                    $sessionParams[$key] = $value;
                }
            }
        }
        
        if ($changed) {
            unset($session->list);
            $session->params = $sessionParams;
        }
        
        return $params;
    }
public function getParams($namespace, $defaults, $params = null)
    {
        $session        = new Container($namespace);
        $sessionParams  = $session->params ?: array();
        $params         = $params ?: clone $this->getController()->getRequest()->getQuery();
        
        if ($params->get('clear')) {
            $sessionParams = array();
            unset($params['clear']);
        }
        
        $changed = false;
        foreach ($defaults as $key => $default) {
            if (is_numeric($key)) {
                $key = $default;
                $default = null;
            }
            $value = $params->get($key);
            if (null === $value) {
                if (isset($sessionParams[$key])) {
                    $params->set($key, $sessionParams[$key]);
                } elseif (null !== $default) {
                    $params->set($key, $default);
                    $sessionParams[$key] = $default;
                    $changed = true;
                }
            } else {
                if (!isset($sessionParams[$key]) || $sessionParams[$key] != $value) {
                    $changed = true;
                    $sessionParams[$key] = $value;
                }
            }
        }
        
        if ($changed) {
            unset($session->list);
            $session->params = $sessionParams;
        }
        
        return $params;
    }
public function getParams ( $ namespace , $ defaults , $ params = null ) { $ session = new Container ( $ namespace ) ; $ sessionParams = $ session -> params ? : array ( ) ; $ params = $ params ? : clone $ this -> getController ( ) -> getRequest ( ) -> getQuery ( ) ; if ( $ params -> get ( 'clear' ) ) { $ sessionParams = array ( ) ; unset ( $ params [ 'clear' ] ) ; } $ changed = false ; foreach ( $ defaults as $ key => $ default ) { if ( is_numeric ( $ key ) ) { $ key = $ default ; $ default = null ; } $ value = $ params -> get ( $ key ) ; if ( null === $ value ) { if ( isset ( $ sessionParams [ $ key ] ) ) { $ params -> set ( $ key , $ sessionParams [ $ key ] ) ; } elseif ( null !== $ default ) { $ params -> set ( $ key , $ default ) ; $ sessionParams [ $ key ] = $ default ; $ changed = true ; } } else { if ( ! isset ( $ sessionParams [ $ key ] ) || $ sessionParams [ $ key ] != $ value ) { $ changed = true ; $ sessionParams [ $ key ] = $ value ; } } } if ( $ changed ) { unset ( $ session -> list ) ; $ session -> params = $ sessionParams ; } return $ params ; }
Retrieves pagination params.

Automatically merges parameters stored in the session according to specs
provided.

@param string $namespace Session namespace
@param array $defaults
1. [paramName] => [defaultValue],
Set default value if paramName is not present in params
2. [paramName]
Store paramName if it is present, do nothing if not.
@param Parameters $params

@return Parameters
Retrieves pagination params .