class ActiveTheme

Same name in other branches
  1. 9 core/lib/Drupal/Core/Theme/ActiveTheme.php \Drupal\Core\Theme\ActiveTheme
  2. 8.9.x core/lib/Drupal/Core/Theme/ActiveTheme.php \Drupal\Core\Theme\ActiveTheme
  3. 10 core/lib/Drupal/Core/Theme/ActiveTheme.php \Drupal\Core\Theme\ActiveTheme

Defines a theme and its information needed at runtime.

The theme manager will store the active theme object.

Hierarchy

Expanded class hierarchy of ActiveTheme

See also

\Drupal\Core\Theme\ThemeManager

\Drupal\Core\Theme\ThemeInitialization

6 files declare their use of ActiveTheme
ComponentNegotiator.php in core/modules/sdc/src/ComponentNegotiator.php
ElementInfoManagerTest.php in core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php
LibraryDiscoveryCollectorTest.php in core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php
LibraryDiscoveryParser.php in core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
LibraryDiscoveryParserTest.php in core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php

... See full list

File

core/lib/Drupal/Core/Theme/ActiveTheme.php, line 13

Namespace

Drupal\Core\Theme
View source
class ActiveTheme {
    
    /**
     * The machine name of the active theme.
     *
     * @var string
     */
    protected $name;
    
    /**
     * The path to the logo.
     *
     * @var string
     */
    protected $logo;
    
    /**
     * The path to the theme.
     *
     * @var string
     */
    protected $path;
    
    /**
     * The engine of the theme.
     *
     * @var string
     */
    protected $engine;
    
    /**
     * The path to the theme engine for root themes.
     *
     * @var string
     */
    protected $owner;
    
    /**
     * An array of base theme extension objects keyed by name.
     *
     * @var \Drupal\Core\Extension\Extension[]
     */
    protected $baseThemeExtensions = [];
    
    /**
     * The extension object.
     *
     * @var \Drupal\Core\Extension\Extension
     */
    protected $extension;
    
    /**
     * The libraries provided by the theme.
     *
     * @var array
     */
    protected $libraries;
    
    /**
     * The regions provided by the theme.
     *
     * @var array
     */
    protected $regions;
    
    /**
     * The libraries or library assets overridden by the theme.
     *
     * @var array
     */
    protected $librariesOverride;
    
    /**
     * The list of libraries-extend definitions.
     *
     * @var array
     */
    protected $librariesExtend;
    
    /**
     * Constructs an ActiveTheme object.
     *
     * @param array $values
     *   The properties of the object, keyed by the names.
     */
    public function __construct(array $values) {
        $values += [
            'path' => '',
            'engine' => 'twig',
            'owner' => 'twig',
            'logo' => '',
            'libraries' => [],
            'extension' => 'html.twig',
            'base_theme_extensions' => [],
            'regions' => [],
            'libraries_override' => [],
            'libraries_extend' => [],
        ];
        $this->name = $values['name'];
        $this->logo = $values['logo'];
        $this->path = $values['path'];
        $this->engine = $values['engine'];
        $this->owner = $values['owner'];
        $this->libraries = $values['libraries'];
        $this->extension = $values['extension'];
        $this->baseThemeExtensions = $values['base_theme_extensions'];
        $this->regions = $values['regions'];
        $this->librariesOverride = $values['libraries_override'];
        $this->librariesExtend = $values['libraries_extend'];
    }
    
    /**
     * Returns the machine name of the theme.
     *
     * @return string
     */
    public function getName() {
        return $this->name;
    }
    
    /**
     * Returns the path to the theme directory.
     *
     * @return string
     */
    public function getPath() {
        return $this->path;
    }
    
    /**
     * Returns the theme engine.
     *
     * @return string
     */
    public function getEngine() {
        return $this->engine;
    }
    
    /**
     * Returns the path to the theme engine for root themes.
     *
     * @see \Drupal\Core\Extension\ThemeExtensionList::doList()
     *
     * @return mixed
     */
    public function getOwner() {
        return $this->owner;
    }
    
    /**
     * Returns the extension object.
     *
     * @return \Drupal\Core\Extension\Extension
     */
    public function getExtension() {
        return $this->extension;
    }
    
    /**
     * Returns the libraries provided by the theme.
     *
     * @return mixed
     */
    public function getLibraries() {
        return $this->libraries;
    }
    
    /**
     * Returns an array of base theme extension objects keyed by name.
     *
     * The order starts with the base theme of $this and ends with the root of
     * the dependency chain. For most use cases, parent themes are expected to
     * be called first, so this order needs to be reversed with array_reverse()
     *
     * @return \Drupal\Core\Extension\Extension[]
     */
    public function getBaseThemeExtensions() {
        return $this->baseThemeExtensions;
    }
    
    /**
     * Returns the logo provided by the theme.
     *
     * @return string
     *   The logo path.
     */
    public function getLogo() {
        return $this->logo;
    }
    
    /**
     * The regions used by the theme.
     *
     * @return string[]
     *   The list of region machine names supported by the theme.
     *
     * @see system_region_list()
     */
    public function getRegions() {
        return array_keys($this->regions);
    }
    
    /**
     * Returns the libraries or library assets overridden by the active theme.
     *
     * @return array
     *   The list of libraries overrides.
     */
    public function getLibrariesOverride() {
        return $this->librariesOverride;
    }
    
    /**
     * Returns the libraries extended by the active theme.
     *
     * @return array
     *   The list of libraries-extend definitions.
     */
    public function getLibrariesExtend() {
        return $this->librariesExtend;
    }

}

Members

Title Sort descending Modifiers Object type Summary
ActiveTheme::$baseThemeExtensions protected property An array of base theme extension objects keyed by name.
ActiveTheme::$engine protected property The engine of the theme.
ActiveTheme::$extension protected property The extension object.
ActiveTheme::$libraries protected property The libraries provided by the theme.
ActiveTheme::$librariesExtend protected property The list of libraries-extend definitions.
ActiveTheme::$librariesOverride protected property The libraries or library assets overridden by the theme.
ActiveTheme::$logo protected property The path to the logo.
ActiveTheme::$name protected property The machine name of the active theme.
ActiveTheme::$owner protected property The path to the theme engine for root themes.
ActiveTheme::$path protected property The path to the theme.
ActiveTheme::$regions protected property The regions provided by the theme.
ActiveTheme::getBaseThemeExtensions public function Returns an array of base theme extension objects keyed by name.
ActiveTheme::getEngine public function Returns the theme engine.
ActiveTheme::getExtension public function Returns the extension object.
ActiveTheme::getLibraries public function Returns the libraries provided by the theme.
ActiveTheme::getLibrariesExtend public function Returns the libraries extended by the active theme.
ActiveTheme::getLibrariesOverride public function Returns the libraries or library assets overridden by the active theme.
ActiveTheme::getLogo public function Returns the logo provided by the theme.
ActiveTheme::getName public function Returns the machine name of the theme.
ActiveTheme::getOwner public function Returns the path to the theme engine for root themes.
ActiveTheme::getPath public function Returns the path to the theme directory.
ActiveTheme::getRegions public function The regions used by the theme.
ActiveTheme::__construct public function Constructs an ActiveTheme object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.