You are here

public function ThemeHandler::listInfo in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Extension/ThemeHandler.php \Drupal\Core\Extension\ThemeHandler::listInfo()
  2. 9 core/lib/Drupal/Core/Extension/ThemeHandler.php \Drupal\Core\Extension\ThemeHandler::listInfo()

Returns a list of currently installed themes.

Return value

\Drupal\Core\Extension\Extension[] An associative array of the currently installed themes. The keys are the themes' machine names and the values are Extension objects having the following properties:

  • filename: The filepath and name of the .info.yml file.
  • name: The machine name of the theme.
  • status: 1 for installed, 0 for uninstalled themes.
  • info: The contents of the .info.yml file.
  • stylesheets: A two dimensional array, using the first key for the media attribute (e.g. 'all'), the second for the name of the file (e.g. style.css). The value is a complete filepath (e.g. themes/bartik/style.css). Not set if no stylesheets are defined in the .info.yml file.
  • scripts: An associative array of JavaScripts, using the filename as key and the complete filepath as value. Not set if no scripts are defined in the .info.yml file.
  • prefix: The base theme engine prefix.
  • engine: The machine name of the theme engine.
  • base_theme: If this is a sub-theme, the machine name of the base theme defined in the .info.yml file. Otherwise, the element is not set.
  • base_themes: If this is a sub-theme, an associative array of the base-theme ancestors of this theme, starting with this theme's base theme, then the base theme's own base theme, etc. Each entry has an array key equal to the theme's machine name, and a value equal to the human-readable theme name; if a theme with matching machine name does not exist in the system, the value will instead be NULL (and since the system would not know whether that theme itself has a base theme, that will end the array of base themes). This is not set if the theme is not a sub-theme.
  • sub_themes: An associative array of themes on the system that are either direct sub-themes (that is, they declare this theme to be their base theme), direct sub-themes of sub-themes, etc. The keys are the themes' machine names, and the values are the themes' human-readable names. This element is not set if there are no themes on the system that declare this theme as their base theme.

Overrides ThemeHandlerInterface::listInfo

4 calls to ThemeHandler::listInfo()
ThemeHandler::getTheme in core/lib/Drupal/Core/Extension/ThemeHandler.php
Returns a theme extension object from the currently active theme list.
ThemeHandler::getThemeDirectories in core/lib/Drupal/Core/Extension/ThemeHandler.php
Returns an array of directories for all installed themes.
ThemeHandler::hasUi in core/lib/Drupal/Core/Extension/ThemeHandler.php
Determines if a theme should be shown in the user interface.
ThemeHandler::themeExists in core/lib/Drupal/Core/Extension/ThemeHandler.php
Determines whether a given theme is installed.

File

core/lib/Drupal/Core/Extension/ThemeHandler.php, line 67

Class

ThemeHandler
Default theme handler using the config system to store installation statuses.

Namespace

Drupal\Core\Extension

Code

public function listInfo() {
  if (!isset($this->list)) {
    $this->list = [];
    $installed_themes = $this->configFactory
      ->get('core.extension')
      ->get('theme');
    if (!empty($installed_themes)) {
      $installed_themes = array_intersect_key($this->themeList
        ->getList(), $installed_themes);
      array_map([
        $this,
        'addTheme',
      ], $installed_themes);
    }
  }
  return $this->list;
}