You are here

protected function DrupalKernel::initializeSettings in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::initializeSettings()
  2. 9 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::initializeSettings()

Locate site path and initialize settings singleton.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request.

Throws

\Symfony\Component\HttpKernel\Exception\BadRequestHttpException In case the host name in the request is not trusted.

1 call to DrupalKernel::initializeSettings()
DrupalKernel::handle in core/lib/Drupal/Core/DrupalKernel.php

File

core/lib/Drupal/Core/DrupalKernel.php, line 1022

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

protected function initializeSettings(Request $request) {
  $site_path = static::findSitePath($request);
  $this
    ->setSitePath($site_path);
  Settings::initialize($this->root, $site_path, $this->classLoader);

  // Initialize our list of trusted HTTP Host headers to protect against
  // header attacks.
  $host_patterns = Settings::get('trusted_host_patterns', []);
  if (PHP_SAPI !== 'cli' && !empty($host_patterns)) {
    if (static::setupTrustedHosts($request, $host_patterns) === FALSE) {
      throw new BadRequestHttpException('The provided host name is not valid for this server.');
    }
  }
}