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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 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 ]; } |
Please login to continue.