<commit_before><?php

/*
 * This file is part of the Integrated package.
 *
 * (c) e-Active B.V. <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Integrated\Bundle\ContentBundle\EventListener;

use Integrated\Common\Content\Channel\ChannelContextInterface;
use Integrated\Common\Content\Channel\ChannelManagerInterface;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
 * @author <NAME> <<EMAIL>>
 */
class RequestChannelInjectionListener implements EventSubscriberInterface
{
	/**
	 * @var ChannelManagerInterface
	 */
	private $manager;

	/**
	 * @var ChannelContextInterface
	 */
	private $context;

	/**
	 * @param ChannelManagerInterface $manager
	 * @param ChannelContextInterface $context
	 */
	public function __construct(ChannelManagerInterface $manager, ChannelContextInterface $context)
	{
		$this->manager = $manager;
		$this->context = $context;
	}

	/**
	 * @inheritdoc
	 */
	public static function getSubscribedEvents()
	{
		return [
			KernelEvents::REQUEST => 'onRequest'
		];
	}

	/**
	 * @param GetResponseEvent $event
	 */
	public function onRequest(GetResponseEvent $event)
	{
		$this->getContext()->setChannel($this->getManager()->findByDomain($event->getRequest()->getHost()));
	}

	/**
	 * @return ChannelManagerInterface
	 */
	public function getManager()
	{
		return $this->manager;
	}

	/**
	 * @return ChannelContextInterface
	 */
	public function getContext()
	{
		return $this->context;
	}
}<commit_msg>Execute the request channel injection listener before the router listener<commit_after><?php

/*
 * This file is part of the Integrated package.
 *
 * (c) e-Active B.V. <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Integrated\Bundle\ContentBundle\EventListener;

use Integrated\Common\Content\Channel\ChannelContextInterface;
use Integrated\Common\Content\Channel\ChannelManagerInterface;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
 * @author <NAME> <<EMAIL>>
 */
class RequestChannelInjectionListener implements EventSubscriberInterface
{
	/**
	 * @var ChannelManagerInterface
	 */
	private $manager;

	/**
	 * @var ChannelContextInterface
	 */
	private $context;

	/**
	 * @param ChannelManagerInterface $manager
	 * @param ChannelContextInterface $context
	 */
	public function __construct(ChannelManagerInterface $manager, ChannelContextInterface $context)
	{
		$this->manager = $manager;
		$this->context = $context;
	}

	/**
	 * @inheritdoc
	 */
	public static function getSubscribedEvents()
	{
		return [
			KernelEvents::REQUEST => ['onRequest', 34]
		];
	}

	/**
	 * @param GetResponseEvent $event
	 */
	public function onRequest(GetResponseEvent $event)
	{
		$this->getContext()->setChannel($this->getManager()->findByDomain($event->getRequest()->getHost()));
	}

	/**
	 * @return ChannelManagerInterface
	 */
	public function getManager()
	{
		return $this->manager;
	}

	/**
	 * @return ChannelContextInterface
	 */
	public function getContext()
	{
		return $this->context;
	}
}
{'fraction_non_alphanumeric': 0.12338044758539458, 'fraction_numerical': 0.0005889281507656066, 'mean_word_length': 4.559738134206219, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 35, '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': '1684784', 'n_tokens_mistral': 1010, 'n_tokens_neox': 940, 'n_words': 220}