<commit_before><?php

/*
 * This file is part of the Helthe Turbolinks package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Helthe\Component\Turbolinks\EventListener;

use Helthe\Component\Turbolinks\Turbolinks;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
 * Event listener that modifies the kernel response for the turbolinks javascript.
 *
 * @author <NAME> <<EMAIL>>
 */
class TurbolinksListener implements EventSubscriberInterface
{
    /**
     * @var Turbolinks
     */
    private $turbolinks;

    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        return array(
            KernelEvents::RESPONSE => array('onKernelResponse', -128),
        );
    }

    /**
     * Constructor.
     *
     * @param Turbolinks $turbolinks
     */
    public function __construct(Turbolinks $turbolinks)
    {
        $this->turbolinks = $turbolinks;
    }

    /**
     * Filters the Response.
     *
     * @param FilterResponseEvent $event
     */
    public function onKernelResponse(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $this->turbolinks->decorateResponse($event->getRequest(), $event->getResponse());
    }
}<commit_msg>`isMasterRequest` API function not available in Symfony 2.3<commit_after><?php

/*
 * This file is part of the Helthe Turbolinks package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Helthe\Component\Turbolinks\EventListener;

use Helthe\Component\Turbolinks\Turbolinks;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;

/**
 * Event listener that modifies the kernel response for the turbolinks javascript.
 *
 * @author <NAME> <<EMAIL>>
 */
class TurbolinksListener implements EventSubscriberInterface
{
    /**
     * @var Turbolinks
     */
    private $turbolinks;

    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        return array(
            KernelEvents::RESPONSE => array('onKernelResponse', -128),
        );
    }

    /**
     * Constructor.
     *
     * @param Turbolinks $turbolinks
     */
    public function __construct(Turbolinks $turbolinks)
    {
        $this->turbolinks = $turbolinks;
    }

    /**
     * Filters the Response.
     *
     * @param FilterResponseEvent $event
     */
    public function onKernelResponse(FilterResponseEvent $event)
    {
        if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
            return;
        }

        $this->turbolinks->decorateResponse($event->getRequest(), $event->getResponse());
    }
}
{'fraction_non_alphanumeric': 0.11114649681528663, 'fraction_numerical': 0.0025477707006369425, 'mean_word_length': 2.9759493670886075, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 29, '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': '2997954', 'n_tokens_mistral': 918, 'n_tokens_neox': 913, 'n_words': 208}