function _template_preprocess_default_variables

Same name in other branches
  1. 7.x includes/theme.inc \_template_preprocess_default_variables()
  2. 9 core/includes/theme.inc \_template_preprocess_default_variables()
  3. 10 core/includes/theme.inc \_template_preprocess_default_variables()
  4. 11.x core/includes/theme.inc \_template_preprocess_default_variables()

Returns hook-independent variables to template_preprocess().

1 call to _template_preprocess_default_variables()
template_preprocess in core/includes/theme.inc
Adds a default set of helper variables for preprocessors and templates.

File

core/includes/theme.inc, line 1254

Code

function _template_preprocess_default_variables() {
    // Variables that don't depend on a database connection.
    $variables = [
        '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 the default template variables.
    \Drupal::moduleHandler()->alter('template_preprocess_default_variables', $variables);
    // Tell all templates where they are located.
    $variables['directory'] = \Drupal::theme()->getActiveTheme()
        ->getPath();
    return $variables;
}

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