Commit 5d8b06a1 authored by katbailey's avatar katbailey

Making FinishResponseSubscriber dependent on the language_manager service

parent 33b5c4b6
......@@ -55,6 +55,8 @@ public function build(ContainerBuilder $container) {
$container->register('legacy_controller_subscriber', 'Drupal\Core\EventSubscriber\LegacyControllerSubscriber')
->addTag('kernel.event_subscriber');
$container->register('finish_response_subscriber', 'Drupal\Core\EventSubscriber\FinishResponseSubscriber')
->addArgument(new Reference('language_manager'))
->setScope('request')
->addTag('kernel.event_subscriber');
$container->register('request_close_subscriber', 'Drupal\Core\EventSubscriber\RequestCloseSubscriber')
->addTag('kernel.event_subscriber');
......
......@@ -7,6 +7,7 @@
namespace Drupal\Core\EventSubscriber;
use Drupal\Core\Language\LanguageManager;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
......@@ -16,6 +17,12 @@
*/
class FinishResponseSubscriber implements EventSubscriberInterface {
private $language_manager;
public function __construct(LanguageManager $language_manager) {
$this->language_manager = $language_manager;
}
/**
* Sets extra headers on successful responses.
*
......@@ -30,7 +37,7 @@ public function onRespond(FilterResponseEvent $event) {
$response->headers->set('X-UA-Compatible', 'IE=edge,chrome=1', false);
// Set the Content-language header.
$response->headers->set('Content-language', language_manager(LANGUAGE_TYPE_INTERFACE)->langcode);
$response->headers->set('Content-language', $this->language_manager->getLanguage(LANGUAGE_TYPE_INTERFACE)->langcode);
// Because pages are highly dynamic, set the last-modified time to now
// since the page is in fact being regenerated right now.
......
......@@ -10,8 +10,12 @@
use Symfony\Component\HttpFoundation\Request;
/**
* The LanguageManager service intializes the language types passing in the
* Request object, which can then be used for e.g. url-based language negotiation.
* Class responsible for initializing each language type.
*
* This service is dependent on the 'request' service and can therefore pass the
* Request object to the code that deals with each particular language type.
* This means the Request can be used directly for things like url-based language
* negotiation.
*/
class LanguageManager {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment