Same filename and directory in other branches
- 8.9.x core/modules/user/src/Theme/AdminNegotiator.php
- 9 core/modules/user/src/Theme/AdminNegotiator.php
Namespace
Drupal\user\Theme
File
core/modules/user/src/Theme/AdminNegotiator.php
View source
<?php
namespace Drupal\user\Theme;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\AdminContext;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Theme\ThemeNegotiatorInterface;
class AdminNegotiator implements ThemeNegotiatorInterface {
protected $user;
protected $configFactory;
protected $entityTypeManager;
protected $adminContext;
public function __construct(AccountInterface $user, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, AdminContext $admin_context) {
$this->user = $user;
$this->configFactory = $config_factory;
$this->entityTypeManager = $entity_type_manager;
$this->adminContext = $admin_context;
}
public function applies(RouteMatchInterface $route_match) {
return $this->entityTypeManager
->hasHandler('user_role', 'storage') && $this->user
->hasPermission('view the administration theme') && $this->adminContext
->isAdminRoute($route_match
->getRouteObject());
}
public function determineActiveTheme(RouteMatchInterface $route_match) {
return $this->configFactory
->get('system.theme')
->get('admin') ?: NULL;
}
}
Classes