system_list($type)
Builds a list of installed themes.
$type: The type of list to return:
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.
\Drupal\Core\Extension\ThemeHandler::listInfo()
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]; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!module.inc/function/system_list/8.1.x