DbUpdateNegotiator.php in Drupal 10
Same filename and directory in other branches
Namespace
Drupal\system\ThemeFile
core/modules/system/src/Theme/DbUpdateNegotiator.phpView source
<?php
namespace Drupal\system\Theme;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\Theme\ThemeNegotiatorInterface;
/**
* Sets the active theme for the database update pages.
*/
class DbUpdateNegotiator implements ThemeNegotiatorInterface {
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* The theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
/**
* Constructs a DbUpdateNegotiator.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* The theme handler.
*/
public function __construct(ConfigFactoryInterface $config_factory, ThemeHandlerInterface $theme_handler) {
$this->configFactory = $config_factory;
$this->themeHandler = $theme_handler;
}
/**
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
return $route_match
->getRouteName() == 'system.db_update';
}
/**
* {@inheritdoc}
*/
public function determineActiveTheme(RouteMatchInterface $route_match) {
$custom_theme = Settings::get('maintenance_theme');
if (!$custom_theme) {
$custom_theme = $this->themeHandler
->themeExists('claro') ? 'claro' : 'seven';
}
return $custom_theme;
}
}
Classes
Name![]() |
Description |
---|---|
DbUpdateNegotiator | Sets the active theme for the database update pages. |