LanguageCookieConditionXMLHTTPRequest.php in Language Cookie 8
File
src/Plugin/LanguageCookieCondition/LanguageCookieConditionXMLHTTPRequest.php
View source
<?php
namespace Drupal\language_cookie\Plugin\LanguageCookieCondition;
use Drupal\language_cookie\LanguageCookieConditionBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
class LanguageCookieConditionXMLHTTPRequest extends LanguageCookieConditionBase {
protected $requestStack;
public function __construct(RequestStack $request_stack, array $configuration, $plugin_id, array $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->requestStack = $request_stack;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($container
->get('request_stack'), $configuration, $plugin_id, $plugin_definition);
}
public function evaluate() {
if ($this->requestStack
->getCurrentRequest()
->isXmlHttpRequest()) {
return $this
->block();
}
return $this
->pass();
}
}