class Theme
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Updater/Theme.php \Drupal\Core\Updater\Theme
- 10 core/lib/Drupal/Core/Updater/Theme.php \Drupal\Core\Updater\Theme
- 9 core/lib/Drupal/Core/Updater/Theme.php \Drupal\Core\Updater\Theme
- 8.9.x core/lib/Drupal/Core/Updater/Theme.php \Drupal\Core\Updater\Theme
- 11.x core/lib/Drupal/Core/Extension/Theme.php \Drupal\Core\Extension\Theme
The Theme extension object.
Extending this class is not supported and no BC is provided for subclasses.
@todo https://www.drupal.org/project/drupal/issues/3026232 Replace public and dynamic properties with methods.
@final
Hierarchy
- class \Drupal\Core\Extension\Extension
- class \Drupal\Core\Extension\Theme extends \Drupal\Core\Extension\Extension
Expanded class hierarchy of Theme
See also
\Drupal\Core\Extension\ThemeExtensionList::doList()
3 files declare their use of Theme
- EnabledExtensionsValidatorTest.php in core/
modules/ package_manager/ tests/ src/ Kernel/ EnabledExtensionsValidatorTest.php - system.module in core/
modules/ system/ system.module - ThemeHandlerTest.php in core/
tests/ Drupal/ Tests/ Core/ Extension/ ThemeHandlerTest.php
257 string references to 'Theme'
- admin.info.yml in core/
themes/ admin/ admin.info.yml - core/themes/admin/admin.info.yml
- AdminDemoNegotiator::determineActiveTheme in core/
modules/ block/ src/ Theme/ AdminDemoNegotiator.php - Determine the active theme for the request.
- AssertPageCacheContextsAndTagsTrait::assertCacheContexts in core/
modules/ system/ tests/ src/ Functional/ Cache/ AssertPageCacheContextsAndTagsTrait.php - Ensures that some cache contexts are present in the current response.
- AssetControllerBase::deliver in core/
modules/ system/ src/ Controller/ AssetControllerBase.php - Generates an aggregate, given a filename.
- big_pipe_test_theme.info.yml in core/
modules/ big_pipe/ tests/ themes/ big_pipe_test_theme/ big_pipe_test_theme.info.yml - core/modules/big_pipe/tests/themes/big_pipe_test_theme/big_pipe_test_theme.info.yml
File
-
core/
lib/ Drupal/ Core/ Extension/ Theme.php, line 21
Namespace
Drupal\Core\ExtensionView source
class Theme extends Extension {
/**
* Constructs a new Theme object.
*
* @param string $root
* The app root.
* @param string $pathname
* The relative path and filename of the extension's info file; e.g.,
* 'core/themes/olivero/olivero.info.yml'.
* @param array $info
* The info array parsed from the theme's .info.yml file.
* @param string|null $filename
* (optional) The filename of the main extension file; e.g., olivero.theme.
*/
public function __construct(string $root, string $pathname, array $info, ?string $filename = NULL) {
parent::__construct($root, 'theme', $pathname, $filename);
$this->info = $info;
}
/**
* Lists all the theme's regions.
*
* @return \Drupal\Core\StringTranslation\TranslatableMarkup[]
* An array of human-readable region names keyed by machine names.
*/
public function listAllRegions() : array {
return array_map(static function ($label) {
// phpcs:ignore Drupal.Semantics.FunctionT.NotLiteralString
return new TranslatableMarkup($label);
}, $this->info['regions']);
}
/**
* Lists all the theme's visible regions.
*
* @return \Drupal\Core\StringTranslation\TranslatableMarkup[]
* An array of human-readable region names keyed by machine names.
*/
public function listVisibleRegions() : array {
// List only regions that do not appear in the 'regions_hidden' key.
return array_diff_key($this->listAllRegions(), array_flip($this->info['regions_hidden']));
}
/**
* Gets the name of the default region for the theme.
*
* @return string
* The machine name of the default region.
*/
public function getDefaultRegion() : string {
return (string) key($this->listVisibleRegions());
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
|---|---|---|---|---|---|
| Extension::$filename | protected | property | The filename of the main extension file (e.g., 'node.module'). | ||
| Extension::$info | public | property | The extension info array. | ||
| Extension::$pathname | protected | property | The relative pathname of the extension. | ||
| Extension::$root | protected | property | The app root. | ||
| Extension::$splFileInfo | protected | property | An SplFileInfo instance for the extension's info file. | ||
| Extension::$type | protected | property | The type of the extension (e.g., 'module'). | ||
| Extension::getExtensionFilename | public | function | Returns the name of the main extension file, if any. | 1 | |
| Extension::getExtensionPathname | public | function | Returns the relative path of the main extension file, if any. | 1 | |
| Extension::getFileInfo | public | function | Returns SplFileInfo instance for the extension's info file. | ||
| Extension::getFilename | public | function | Returns the filename of the extension's info file. | 1 | |
| Extension::getName | public | function | Returns the internal name of the extension. | 1 | |
| Extension::getPath | public | function | Returns the relative path of the extension. | 1 | |
| Extension::getPathname | public | function | Returns the relative path and filename of the extension's info file. | 1 | |
| Extension::getType | public | function | Returns the type of the extension. | ||
| Extension::isExperimental | public | function | Checks if an extension is marked as experimental. | 1 | |
| Extension::isObsolete | public | function | Checks if an extension is marked as obsolete. | 1 | |
| Extension::load | public | function | Loads the main extension file, if any. | 1 | |
| Extension::__sleep | public | function | Magic method implementation to serialize the extension object. | ||
| Extension::__wakeup | public | function | Magic method implementation to unserialize the extension object. | ||
| Theme::getDefaultRegion | public | function | Gets the name of the default region for the theme. | ||
| Theme::listAllRegions | public | function | Lists all the theme's regions. | ||
| Theme::listVisibleRegions | public | function | Lists all the theme's visible regions. | ||
| Theme::__construct | public | function | Constructs a new Theme object. | Overrides Extension::__construct |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.