Commit 42c4103c authored by lussoluca's avatar lussoluca Committed by lussoluca

Issue #2879214 by lussoluca, clemens.tolboom: Support for Drupal 8.4.x using...

Issue #2879214 by lussoluca, clemens.tolboom: Support for Drupal 8.4.x using Symfony 3 in webprofiler
parent d33784ce
......@@ -50,7 +50,6 @@ class ServicePass implements CompilerPassInterface {
$inEdges[] = [
'id' => $edge->getSourceNode()->getId(),
'invalidBehavior' => $edgeValue ? $edgeValue->getInvalidBehavior() : NULL,
'strict' => $edgeValue ? $edgeValue->isStrict() : NULL,
];
}
......@@ -63,7 +62,6 @@ class ServicePass implements CompilerPassInterface {
$outEdges[] = [
'id' => $edge->getDestNode()->getId(),
'invalidBehavior' => $edgeValue ? $edgeValue->getInvalidBehavior() : NULL,
'strict' => $edgeValue ? $edgeValue->isStrict() : NULL,
];
}
}
......
......@@ -5,7 +5,7 @@ namespace Drupal\webprofiler\DataCollector;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\webprofiler\DependencyInjection\TraceableContainer;
use Drupal\webprofiler\DrupalDataCollectorInterface;
use Symfony\Component\DependencyInjection\IntrospectableContainerInterface;
use Drupal\Core\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
......@@ -18,15 +18,15 @@ class ServicesDataCollector extends DataCollector implements DrupalDataCollector
use StringTranslationTrait, DrupalDataCollectorTrait;
/**
* @var \Symfony\Component\DependencyInjection\IntrospectableContainerInterface
* @var \Drupal\Core\DependencyInjection\Container
* $container
*/
private $container;
/**
* @param IntrospectableContainerInterface $container
* @param \Drupal\Core\DependencyInjection\Container $container
*/
public function __construct(IntrospectableContainerInterface $container) {
public function __construct(Container $container) {
$this->container = $container;
}
......
......@@ -43,9 +43,6 @@ class TraceableEventDispatcher extends ContainerAwareEventDispatcher implements
$event = new Event();
}
$event->setDispatcher($this);
$event->setName($event_name);
$this->preDispatch($event_name, $event);
$e = $this->stopwatch->start($event_name, 'section');
......
......@@ -19,7 +19,25 @@ class ThemeNegotiatorWrapper extends ThemeNegotiator {
* {@inheritdoc}
*/
public function determineActiveTheme(RouteMatchInterface $route_match) {
foreach ($this->getSortedNegotiators() as $negotiator) {
// This method has changed in Drupal 8.4.x, to maintain compatibility with
// Drupal 8.3.x we check the existence or not of the classResolver
// property.
// TODO: remove this logic when we decide to drop Drupal 8.3.x support.
if (property_exists($this, 'classResolver')) {
$classResolver = $this->classResolver;
$negotiators = $this->negotiators;
} else {
$classResolver = \Drupal::classResolver();
$negotiators = $this->getSortedNegotiators();
}
foreach ($negotiators as $negotiator_id) {
if (property_exists($this, 'classResolver')) {
$negotiator = $classResolver->getInstanceFromDefinition($negotiator_id);
} else {
$negotiator = $negotiator_id;
}
if ($negotiator->applies($route_match)) {
$theme = $negotiator->determineActiveTheme($route_match);
if ($theme !== NULL && $this->themeAccess->checkAccess($theme)) {
......@@ -36,4 +54,27 @@ class ThemeNegotiatorWrapper extends ThemeNegotiator {
public function getNegotiator() {
return $this->negotiator;
}
/**
* Returns the sorted array of theme negotiators.
*
* @return array|\Drupal\Core\Theme\ThemeNegotiatorInterface[]
* An array of theme negotiator objects.
*
* TODO: remove this method when we decide to drop Drupal 8.3.x support.
*/
protected function getSortedNegotiators() {
if (!isset($this->sortedNegotiators)) {
// Sort the negotiators according to priority.
krsort($this->negotiators);
// Merge nested negotiators from $this->negotiators into
// $this->sortedNegotiators.
$this->sortedNegotiators = [];
foreach ($this->negotiators as $builders) {
$this->sortedNegotiators = array_merge($this->sortedNegotiators, $builders);
}
}
return $this->sortedNegotiators;
}
}
......@@ -47,7 +47,7 @@ services:
# event subscribers
webprofiler.profiler_listener:
class: Symfony\Component\HttpKernel\EventListener\ProfilerListener
arguments: ['@profiler', '@?webprofiler.matcher', '%webprofiler.only_exceptions%', '%webprofiler.only_master_requests%', '@request_stack']
arguments: ['@profiler', '@request_stack', '@?webprofiler.matcher', '%webprofiler.only_exceptions%', '%webprofiler.only_master_requests%']
tags:
- { name: event_subscriber }
......
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