You are here

class DefaultNegotiator in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Theme/DefaultNegotiator.php \Drupal\Core\Theme\DefaultNegotiator

Determines the default theme of the site.

Hierarchy

Expanded class hierarchy of DefaultNegotiator

1 string reference to 'DefaultNegotiator'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses DefaultNegotiator
theme.negotiator.default in core/core.services.yml
Drupal\Core\Theme\DefaultNegotiator

File

core/lib/Drupal/Core/Theme/DefaultNegotiator.php, line 11

Namespace

Drupal\Core\Theme
View source
class DefaultNegotiator implements ThemeNegotiatorInterface {

  /**
   * The system theme config object.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Constructs a DefaultNegotiator object.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function determineActiveTheme(RouteMatchInterface $route_match) {
    return $this->configFactory
      ->get('system.theme')
      ->get('default');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DefaultNegotiator::$configFactory protected property The system theme config object.
DefaultNegotiator::applies public function Whether this theme negotiator should be used to set the theme. Overrides ThemeNegotiatorInterface::applies
DefaultNegotiator::determineActiveTheme public function Determine the active theme for the request. Overrides ThemeNegotiatorInterface::determineActiveTheme
DefaultNegotiator::__construct public function Constructs a DefaultNegotiator object.