class DbUpdateNegotiator

Same name and namespace in other branches
  1. 8.9.x core/modules/system/src/Theme/DbUpdateNegotiator.php \Drupal\system\Theme\DbUpdateNegotiator
  2. 10 core/modules/system/src/Theme/DbUpdateNegotiator.php \Drupal\system\Theme\DbUpdateNegotiator
  3. 11.x core/modules/system/src/Theme/DbUpdateNegotiator.php \Drupal\system\Theme\DbUpdateNegotiator

Sets the active theme for the database update pages.

Hierarchy

Expanded class hierarchy of DbUpdateNegotiator

1 string reference to 'DbUpdateNegotiator'
system.services.yml in core/modules/system/system.services.yml
core/modules/system/system.services.yml
1 service uses DbUpdateNegotiator
theme.negotiator.system.db_update in core/modules/system/system.services.yml
Drupal\system\Theme\DbUpdateNegotiator

File

core/modules/system/src/Theme/DbUpdateNegotiator.php, line 14

Namespace

Drupal\system\Theme
View source
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|null $theme_handler
   *   The theme handler.
   */
  public function __construct(ConfigFactoryInterface $config_factory, ThemeHandlerInterface $theme_handler = NULL) {
    $this->configFactory = $config_factory;
    if ($theme_handler === NULL) {
      @trigger_error('Calling ' . __METHOD__ . '() without the $theme_handler argument is deprecated in drupal:9.4.0 and $theme_handler argument will be required in drupal:10.0.0. See https://www.drupal.org/node/3279699', E_USER_DEPRECATED);
      $theme_handler = \Drupal::service('theme_handler');
    }
    $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;
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
DbUpdateNegotiator::$configFactory protected property The config factory.
DbUpdateNegotiator::$themeHandler protected property The theme handler.
DbUpdateNegotiator::applies public function Whether this theme negotiator should be used to set the theme. Overrides ThemeNegotiatorInterface::applies
DbUpdateNegotiator::determineActiveTheme public function Determine the active theme for the request. Overrides ThemeNegotiatorInterface::determineActiveTheme
DbUpdateNegotiator::__construct public function Constructs a DbUpdateNegotiator.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.