function DrupalKernel::initializeSettings

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::initializeSettings()
  2. 10 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::initializeSettings()
  3. 11.x 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.

2 calls to DrupalKernel::initializeSettings()
DrupalKernel::handle in core/lib/Drupal/Core/DrupalKernel.php
UpdateKernel::handle in core/lib/Drupal/Core/Update/UpdateKernel.php

File

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

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.');
        }
    }
}

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