Issue #3130438 by stefanos.petrakis, andypost, longwave: Inject page_cache_kill_switch service to LanguageNegotiationBrowser
(cherry picked from commit b152620e2c
)
merge-requests/64/head
parent
e3c98f5588
commit
f520ad6c2a
|
@ -3,7 +3,9 @@
|
||||||
namespace Drupal\language\Plugin\LanguageNegotiation;
|
namespace Drupal\language\Plugin\LanguageNegotiation;
|
||||||
|
|
||||||
use Drupal\Component\Utility\UserAgent;
|
use Drupal\Component\Utility\UserAgent;
|
||||||
|
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||||
use Drupal\language\LanguageNegotiationMethodBase;
|
use Drupal\language\LanguageNegotiationMethodBase;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,13 +19,29 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
* config_route_name = "language.negotiation_browser"
|
* config_route_name = "language.negotiation_browser"
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
class LanguageNegotiationBrowser extends LanguageNegotiationMethodBase {
|
class LanguageNegotiationBrowser extends LanguageNegotiationMethodBase implements ContainerFactoryPluginInterface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The language negotiation method id.
|
* The language negotiation method id.
|
||||||
*/
|
*/
|
||||||
const METHOD_ID = 'language-browser';
|
const METHOD_ID = 'language-browser';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The page cache disabling policy.
|
||||||
|
*
|
||||||
|
* @var \Drupal\Core\PageCache\ResponsePolicy\KillSwitch
|
||||||
|
*/
|
||||||
|
protected $pageCacheKillSwitch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||||
|
$instance = new static();
|
||||||
|
$instance->pageCacheKillSwitch = $container->get('page_cache_kill_switch');
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -41,7 +59,7 @@ class LanguageNegotiationBrowser extends LanguageNegotiationMethodBase {
|
||||||
// could lead to wrong cached sites. Therefore disabling the internal page
|
// could lead to wrong cached sites. Therefore disabling the internal page
|
||||||
// cache.
|
// cache.
|
||||||
// @todo Solve more elegantly in https://www.drupal.org/node/2430335.
|
// @todo Solve more elegantly in https://www.drupal.org/node/2430335.
|
||||||
\Drupal::service('page_cache_kill_switch')->trigger();
|
$this->pageCacheKillSwitch->trigger();
|
||||||
|
|
||||||
return $langcode;
|
return $langcode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue