ThemeNegotiatorWrapper.php in Devel 8.3
File
webprofiler/src/Theme/ThemeNegotiatorWrapper.php
View source
<?php
namespace Drupal\webprofiler\Theme;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Theme\ThemeNegotiator;
class ThemeNegotiatorWrapper extends ThemeNegotiator {
private $negotiator;
public function determineActiveTheme(RouteMatchInterface $route_match) {
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)) {
$this->negotiator = $negotiator;
return $theme;
}
}
}
}
public function getNegotiator() {
return $this->negotiator;
}
protected function getSortedNegotiators() {
if (!isset($this->sortedNegotiators)) {
krsort($this->negotiators);
$this->sortedNegotiators = [];
foreach ($this->negotiators as $builders) {
$this->sortedNegotiators = array_merge($this->sortedNegotiators, $builders);
}
}
return $this->sortedNegotiators;
}
}