src/Controller/Component/ListFilterComponent.php
public function startup(\Cake\Event\Event $event)
    {
        $this->_controller = $event->subject();
        $controllerListFilters = $this->getFilters();

        if (empty($controllerListFilters)) {
            return;
        }
        // Redirect on Form Cookie or Form Session Data
        $this->_handlePersistedFilters();

        // Redirect POST to GET, include FormSession and FormCookie Data
        if ($this->_controller->request->is('post') && !empty($this->_controller->request->data['Filter'])) {
            $redirectUrl = $this->getRedirectUrlFromPostData($this->_controller->request->data);
            // Remove page param to paginate from the first page
            unset($redirectUrl['page']);
            // Save ListFilter Form Selection in Session
            if ($this->config['FormSession']['active']) {
                $this->_controller->request->session()->write(
                    $this->_getPersistendStorageKey('FormSession'),
                    $this->_controller->request->data['Filter']
                );
            }
            if ($this->config['FormCookie']['active']) {
                $this->Cookie->write(
                    $this->_getPersistendStorageKey('FormCookie'),
                    $this->_controller->request->data['Filter']
                );
            }

            return $this->_controller->redirect($redirectUrl);
        }

        // Do the ListFilter Job
        $filterConditions = [];
        if (!empty($this->_controller->request->query)) {
            $filterConditions = $this->_prepareFilterConditions($controllerListFilters);
            $conditions = isset($this->_controller->paginate['conditions']) ? $this->_controller->paginate['conditions'] : [];

            // Handle namespaced ListFilter
            if (isset($this->_controller->paginate[$this->_controller->name])) {
                $conditions = [
                    $this->_controller->name => [
                        'conditions' => Hash::merge($conditions, $filterConditions)
                    ]
                ];
            } else {
                $conditions = [
                    'conditions' => Hash::merge($conditions, $filterConditions)
                ];
            }
            $this->_controller->paginate = Hash::merge($this->_controller->paginate, $conditions);
        }
        foreach ($controllerListFilters['fields'] as $field => $options) {
            if (!empty($controllerListFilters['fields'][$field]['options'])) {
                $tmpOptions = $controllerListFilters['fields'][$field]['options'];
            }
            $controllerListFilters['fields'][$field] = Hash::merge($this->defaultListFilter, $options);
            if (isset($tmpOptions)) {
                $controllerListFilters['fields'][$field]['options'] = $tmpOptions;
            }
            unset($tmpOptions);
        }
        $this->_controller->set('filters', $controllerListFilters['fields']);
        $this->_controller->set('filterActive', !empty($filterConditions));
    }
public function startup(\Cake\Event\Event $event)
    {
        $this->_controller = $event->subject();
        $controllerListFilters = $this->getFilters();

        if (empty($controllerListFilters)) {
            return;
        }
        // Redirect on Form Cookie or Form Session Data
        $this->_handlePersistedFilters();

        // Redirect POST to GET, include FormSession and FormCookie Data
        if ($this->_controller->request->is('post') && !empty($this->_controller->request->data['Filter'])) {
            $redirectUrl = $this->getRedirectUrlFromPostData($this->_controller->request->data);
            // Remove page param to paginate from the first page
            unset($redirectUrl['page']);
            // Save ListFilter Form Selection in Session
            if ($this->config['FormSession']['active']) {
                $this->_controller->request->session()->write(
                    $this->_getPersistendStorageKey('FormSession'),
                    $this->_controller->request->data['Filter']
                );
            }
            if ($this->config['FormCookie']['active']) {
                $this->Cookie->write(
                    $this->_getPersistendStorageKey('FormCookie'),
                    $this->_controller->request->data['Filter']
                );
            }

            return $this->_controller->redirect($redirectUrl);
        }

        // Do the ListFilter Job
        $filterConditions = [];
        if (!empty($this->_controller->request->query)) {
            $filterConditions = $this->_prepareFilterConditions($controllerListFilters);
            $conditions = isset($this->_controller->paginate['conditions']) ? $this->_controller->paginate['conditions'] : [];

            // Handle namespaced ListFilter
            if (isset($this->_controller->paginate[$this->_controller->name])) {
                $conditions = [
                    $this->_controller->name => [
                        'conditions' => Hash::merge($conditions, $filterConditions)
                    ]
                ];
            } else {
                $conditions = [
                    'conditions' => Hash::merge($conditions, $filterConditions)
                ];
            }
            $this->_controller->paginate = Hash::merge($this->_controller->paginate, $conditions);
        }
        foreach ($controllerListFilters['fields'] as $field => $options) {
            if (!empty($controllerListFilters['fields'][$field]['options'])) {
                $tmpOptions = $controllerListFilters['fields'][$field]['options'];
            }
            $controllerListFilters['fields'][$field] = Hash::merge($this->defaultListFilter, $options);
            if (isset($tmpOptions)) {
                $controllerListFilters['fields'][$field]['options'] = $tmpOptions;
            }
            unset($tmpOptions);
        }
        $this->_controller->set('filters', $controllerListFilters['fields']);
        $this->_controller->set('filterActive', !empty($filterConditions));
    }
Startup callback

@param Event $event Controller::startup event
@return void