<commit_before><?php
namespace Grav\Plugin;

use Grav\Common\Grav;
use Grav\Common\Page\Collection;
use Grav\Common\Plugin;
use Grav\Common\Registry;

class PaginationPlugin extends Plugin
{
    /**
     * @var PaginationHelper
     */
    protected $pagination;

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

    /**
     * Add current directory to twig lookup paths.
     */
    public function onAfterTwigTemplatesPaths()
    {
        Registry::get('Twig')->twig_paths[] = __DIR__ . '/templates';
    }

    /**
     * Enable pagination if page has params.pagination = true.
     */
    public function onAfterGetPage()
    {
        /** @var Grav $grav */
        $grav = Registry::get('Grav');

        if ($grav->page) {
            $this->active = $grav->page->value('header.pagination');
        }
    }

    /**
     * Create pagination object for the page.
     *
     * @param Collection $collection
     */
    public function onAfterCollectionProcessed(Collection $collection)
    {
        $params = $collection->params();

        // Only add pagination if it has been enabled for the collection.
        if (!$this->active || empty($params['pagination'])) {
            return;
        }

        if (!empty($params['limit']) && $collection->count() > $params['limit']) {
            require_once __DIR__ . '/classes/paginationhelper.php';
            $this->pagination = new PaginationHelper($collection);
            $collection->setParams(['pagination' => $this->pagination]);
        }
    }

    /**
     * Set needed variables to display pagination.
     */
    public function onAfterSiteTwigVars()
    {
        if (!$this->active) {
            return;
        }

        $twig = Registry::get('Twig');

        if ($this->config->get('plugins.pagination.built_in_css')) {
            $twig->twig_vars['stylesheets'][] = 'user/plugins/pagination/pagination.css';
        }
    }
}
<commit_msg>Refactored some Twig event names for consistency<commit_after><?php
namespace Grav\Plugin;

use Grav\Common\Grav;
use Grav\Common\Page\Collection;
use Grav\Common\Plugin;
use Grav\Common\Registry;

class PaginationPlugin extends Plugin
{
    /**
     * @var PaginationHelper
     */
    protected $pagination;

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

    /**
     * Add current directory to twig lookup paths.
     */
    public function onAfterTwigTemplatesPaths()
    {
        Registry::get('Twig')->twig_paths[] = __DIR__ . '/templates';
    }

    /**
     * Enable pagination if page has params.pagination = true.
     */
    public function onAfterGetPage()
    {
        /** @var Grav $grav */
        $grav = Registry::get('Grav');

        if ($grav->page) {
            $this->active = $grav->page->value('header.pagination');
        }
    }

    /**
     * Create pagination object for the page.
     *
     * @param Collection $collection
     */
    public function onAfterCollectionProcessed(Collection $collection)
    {
        $params = $collection->params();

        // Only add pagination if it has been enabled for the collection.
        if (!$this->active || empty($params['pagination'])) {
            return;
        }

        if (!empty($params['limit']) && $collection->count() > $params['limit']) {
            require_once __DIR__ . '/classes/paginationhelper.php';
            $this->pagination = new PaginationHelper($collection);
            $collection->setParams(['pagination' => $this->pagination]);
        }
    }

    /**
     * Set needed variables to display pagination.
     */
    public function onAfterTwigSiteVars()
    {
        if (!$this->active) {
            return;
        }

        $twig = Registry::get('Twig');

        if ($this->config->get('plugins.pagination.built_in_css')) {
            $twig->twig_vars['stylesheets'][] = 'user/plugins/pagination/pagination.css';
        }
    }
}

{'fraction_non_alphanumeric': 0.1431858859626694, 'fraction_numerical': 0.0, 'mean_word_length': 2.19869174161897, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '1403026', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1099, 'n_words': 238}