<commit_before><?php

/*
 * This file is part of staccato listable component
 *
 * (c) <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Staccato\Component\Listable;

use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

class ListStateProvider implements ListStateProviderInterface
{
    /**
     * @var ListRequestInterface
     */
    private $request;

    /**
     * @var SessionInterface
     */
    private $session;

    /**
     * ListStateProvider constructor.
     */
    public function __construct(?ListRequestInterface $listRequest = null, ?SessionInterface $session = null)
    {
        $this->session = $session ?? new Session();
        $this->request = $listRequest ?? new ListRequest();
    }

    public function getState(ListConfigInterface $config): ListState
    {
        if ($config->getPersistState()) {
            $state = $this->getSessionState($config);
        } else {
            $page = $config->getPageParam() ? $this->request->getPage($config->getPageParam(), $config->getPage()) : $config->getPage();
            $limit = $config->getLimitParam() ? $this->request->getLimit($config->getLimitParam(), $config->getLimit()) : $config->getLimit();

            $state = new ListState($page, $limit);
        }

        $requestFilters = $this->request->getFilters($config->getFiltersParam(), $state->getFilters());
        $filters = [];

        foreach ($config->getFilters() as $name => $filter) {
            $value = $filter->isLocked() ? $filter->getData() : ($requestFilters[$name] ?? $filter->getData());
            if ($value && $filter->isValid($value)) {
                $filters[$name] = $requestFilters[$name];
            }
        }<commit_msg>Fix filter data not working<commit_after><?php

/*
 * This file is part of staccato listable component
 *
 * (c) <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Staccato\Component\Listable;

use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

class ListStateProvider implements ListStateProviderInterface
{
    /**
     * @var ListRequestInterface
     */
    private $request;

    /**
     * @var SessionInterface
     */
    private $session;

    /**
     * ListStateProvider constructor.
     */
    public function __construct(?ListRequestInterface $listRequest = null, ?SessionInterface $session = null)
    {
        $this->session = $session ?? new Session();
        $this->request = $listRequest ?? new ListRequest();
    }

    public function getState(ListConfigInterface $config): ListState
    {
        if ($config->getPersistState()) {
            $state = $this->getSessionState($config);
        } else {
            $page = $config->getPageParam() ? $this->request->getPage($config->getPageParam(), $config->getPage()) : $config->getPage();
            $limit = $config->getLimitParam() ? $this->request->getLimit($config->getLimitParam(), $config->getLimit()) : $config->getLimit();

            $state = new ListState($page, $limit);
        }

        $requestFilters = $this->request->getFilters($config->getFiltersParam(), $state->getFilters());
        $filters = [];

        foreach ($config->getFilters() as $name => $filter) {
            $value = $filter->isLocked() ? $filter->getData() : ($requestFilters[$name] ?? $filter->getData());
            if ($value && $filter->isValid($value)) {
                $filters[$name] = $value;
            }
        }
{'fraction_non_alphanumeric': 0.1518338727076591, 'fraction_numerical': 0.0, 'mean_word_length': 2.949946751863685, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4408361', 'n_tokens_mistral': 1006, 'n_tokens_neox': 1009, 'n_words': 226}