You are here

function _theme_load_registry in Drupal 7

Same name and namespace in other branches
  1. 6 includes/theme.inc \_theme_load_registry()

Gets the theme_registry cache; if it doesn't exist, builds it.

Parameters

$theme: The loaded $theme object as returned by list_themes().

$base_theme: An array of loaded $theme objects representing the ancestor themes in oldest first order.

$theme_engine: The name of the theme engine.

$complete: Whether to load the complete theme registry or an instance of the ThemeRegistry class.

Return value

The theme registry array, or an instance of the ThemeRegistry class.

File

includes/theme.inc, line 316
The theme system, which controls the output of Drupal.

Code

function _theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL, $complete = TRUE) {
  if ($complete) {

    // Check the theme registry cache; if it exists, use it.
    $cached = cache_get("theme_registry:{$theme->name}");
    if (isset($cached->data)) {
      $registry = $cached->data;
    }
    else {

      // If not, build one and cache it.
      $registry = _theme_build_registry($theme, $base_theme, $theme_engine);

      // Only persist this registry if all modules are loaded. This assures a
      // complete set of theme hooks.
      if (module_load_all(NULL)) {
        _theme_save_registry($theme, $registry);
      }
    }
    return $registry;
  }
  else {
    return new ThemeRegistry('theme_registry:runtime:' . $theme->name, 'cache');
  }
}