function DrupalRuntime::__construct
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Runtime/DrupalRuntime.php \Drupal\Core\Runtime\DrupalRuntime::__construct()
File
-
core/
lib/ Drupal/ Core/ Runtime/ DrupalRuntime.php, line 18
Class
- DrupalRuntime
- The custom Drupal framework runtime.
Namespace
Drupal\Core\RuntimeCode
public function __construct(array $options = []) {
// Unless explicitly opted-in, we disable Symfony's runtime handler.
// Drupal has its own error handlers.
$options['error_handler'] ??= FALSE;
// We disable dotenv by default. Drupal applications may already have this
// as dependency in their project for other reasons but may not be expecting
// Drupal to read this file.
$options['disable_dotenv'] ??= TRUE;
// Although accessing the autoloader through globals is discouraged. It is
// possible at the time of introducing symfony/runtime, so we must keep this
// available for backwards compatibility.
$GLOBALS['autoloader'] = new DeprecatedAutoloadAccess();
// Symfony's default runtime is `dev`, but Drupal expects this to be `prod`
// if nothing is set so we must overwrite it.
$envKey = $options['env_var_name'] ??= 'APP_ENV';
// If people opted into dotenv then this is not explicitly set by Symfony.
if ($options['disable_dotenv'] || class_exists(MissingDotenv::class, FALSE)) {
$_SERVER[$envKey] ??= $_ENV[$envKey] ?? 'prod';
}
parent::__construct($options);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.