function ThemeManager::getDefaultTemplateVariables

Returns default template variables.

These are set for every template before template preprocessing hooks.

See the Default theme implementations topic for details.

@internal

Return value

array An array of default template variables.

1 call to ThemeManager::getDefaultTemplateVariables()
ThemeManager::render in core/lib/Drupal/Core/Theme/ThemeManager.php
Generates themed output.

File

core/lib/Drupal/Core/Theme/ThemeManager.php, line 487

Class

ThemeManager
Provides the default implementation of a theme manager.

Namespace

Drupal\Core\Theme

Code

public function getDefaultTemplateVariables() : array {
    if (!isset($this->defaultVariables)) {
        // Variables that don't depend on a database connection.
        $this->defaultVariables = [
            'attributes' => [],
            'title_attributes' => [],
            'content_attributes' => [],
            'title_prefix' => [],
            'title_suffix' => [],
            'db_is_active' => !defined('MAINTENANCE_MODE'),
            'is_admin' => FALSE,
            'logged_in' => FALSE,
        ];
        // Give modules a chance to alter default template variables.
        $this->moduleHandler
            ->alter('template_preprocess_default_variables', $this->defaultVariables);
        // Tell all templates where they are located.
        $this->defaultVariables['directory'] = $this->getActiveTheme()
            ->getPath();
    }
    return $this->defaultVariables;
}

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