system_list

system_list($type)

Builds a list of installed themes.

Parameters

$type: The type of list to return:

  • theme: All installed themes.

Return value

An associative array of themes, keyed by name. For $type 'theme', the array values are objects representing the respective database row, with the 'info' property already unserialized.

See also

\Drupal\Core\Extension\ThemeHandler::listInfo()

File

core/includes/module.inc, line 24
API for loading and interacting with Drupal modules.

Code

function system_list($type) {
  $lists = &drupal_static(__FUNCTION__);
  if ($cached = \Drupal::cache('bootstrap')->get('system_list')) {
    $lists = $cached->data;
  }
  else {
    $lists = array(
      'theme' => array(),
      'filepaths' => array(),
    );
    // ThemeHandler maintains the 'system.theme.data' state record.
    $theme_data = \Drupal::state()->get('system.theme.data', array());
    foreach ($theme_data as $name => $theme) {
      $lists['theme'][$name] = $theme;
      $lists['filepaths'][] = array(
        'type' => 'theme',
        'name' => $name,
        'filepath' => $theme->getPathname(),
      );
    }
    \Drupal::cache('bootstrap')->set('system_list', $lists);
  }
  // To avoid a separate database lookup for the filepath, prime the
  // drupal_get_filename() static cache with all enabled themes.
  foreach ($lists['filepaths'] as $item) {
    system_register($item['type'], $item['name'], $item['filepath']);
  }

  return $lists[$type];
}
doc_Drupal
2016-10-29 09:45:56
Comments
Leave a Comment

Please login to continue.