Get the theme_registry cache; if it doesn't exist, build it.
$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 Drupal\Core\Utility\ThemeRegistry class.
The theme registry array, or an instance of the Drupal\Core\Utility\ThemeRegistry class.
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', array(
'theme_registry' => TRUE,
));
}
}