<commit_before><?php
namespace Nayjest\Grids;

use Event;
use Cache;
use View;

class Grid
{

    const SORT_ASC = 'ASC';
    const SORT_DESC = 'DESC';

    const EVENT_PREPARE  = 'grid.prepare';
    const EVENT_CREATE = 'grid.create';

    /** @var GridConfig */
    protected $config;

    /** @var bool  */
    protected $prepared = false;

    /** @var  Sorter */
    protected $sorter;

    /** @var  GridInputProcessor */
    protected $input_processor;

    protected $filtering;

    public function __construct(GridConfig $config)
    {
        $this->config = $config;
        $this->initializeComponents();
        Event::fire(self::EVENT_CREATE, $this);
    }

    /**
     * @return string
     */
    protected function getMainTemplate()
    {
        return $this->config->getMainTemplate();
    }


    protected function prepare()
    {
        if ($this->prepared === true) {
            return;
        }
        $cfg = $this->config;

        if ($cfg->getName() === null) {
            $this->provideName();
        }

        $cfg->getDataProvider()
            ->setPageSize($cfg->getPageSize());
        $this->getConfig()->prepare();
        //$this->getInputProcessor()->applyChanges();
        $this->getFiltering()->apply();
        $this->prepareColumns();
        $this->getSorter()->apply();
        Event::fire(self::EVENT_PREPARE, $this);
        $this->prepared = true;
    }<commit_msg>default grid name bugfix (must be ininialized before components)<commit_after><?php
namespace Nayjest\Grids;

use Event;
use Cache;
use View;

class Grid
{

    const SORT_ASC = 'ASC';
    const SORT_DESC = 'DESC';

    const EVENT_PREPARE  = 'grid.prepare';
    const EVENT_CREATE = 'grid.create';

    /** @var GridConfig */
    protected $config;

    /** @var bool  */
    protected $prepared = false;

    /** @var  Sorter */
    protected $sorter;

    /** @var  GridInputProcessor */
    protected $input_processor;

    protected $filtering;

    public function __construct(GridConfig $config)
    {
        $this->config = $config;
        if ($config->getName() === null) {
            $this->provideName();
        }

        $this->initializeComponents();
        Event::fire(self::EVENT_CREATE, $this);
    }

    /**
     * @return string
     */
    protected function getMainTemplate()
    {
        return $this->config->getMainTemplate();
    }


    protected function prepare()
    {
        if ($this->prepared === true) {
            return;
        }
        $cfg = $this->config;
        $cfg->getDataProvider()
            ->setPageSize($cfg->getPageSize());
        $this->getConfig()->prepare();
        //$this->getInputProcessor()->applyChanges();
        $this->getFiltering()->apply();
        $this->prepareColumns();
        $this->getSorter()->apply();
        Event::fire(self::EVENT_PREPARE, $this);
        $this->prepared = true;
    }
{'fraction_non_alphanumeric': 0.15613126079447323, 'fraction_numerical': 0.0, 'mean_word_length': 2.2466367713004485, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '2198036', 'n_tokens_mistral': 863, 'n_tokens_neox': 834, 'n_words': 172}