class ThemeAccessCheck
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Theme/ThemeAccessCheck.php \Drupal\Core\Theme\ThemeAccessCheck
- 10 core/lib/Drupal/Core/Theme/ThemeAccessCheck.php \Drupal\Core\Theme\ThemeAccessCheck
- 9 core/lib/Drupal/Core/Theme/ThemeAccessCheck.php \Drupal\Core\Theme\ThemeAccessCheck
- 8.9.x core/lib/Drupal/Core/Theme/ThemeAccessCheck.php \Drupal\Core\Theme\ThemeAccessCheck
Provides access checking for themes for routing and theme negotiation.
Hierarchy
- class \Drupal\Core\Theme\ThemeAccessCheck implements \Drupal\Core\Routing\Access\AccessInterface
Expanded class hierarchy of ThemeAccessCheck
2 files declare their use of ThemeAccessCheck
- SystemController.php in core/
modules/ system/ src/ Controller/ SystemController.php - ThemeNegotiatorTest.php in core/
tests/ Drupal/ Tests/ Core/ Theme/ ThemeNegotiatorTest.php
1 string reference to 'ThemeAccessCheck'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses ThemeAccessCheck
File
-
core/
lib/ Drupal/ Core/ Theme/ ThemeAccessCheck.php, line 11
Namespace
Drupal\Core\ThemeView source
class ThemeAccessCheck implements AccessInterface {
public function __construct(protected array $themes) {
}
/**
* Checks access to the theme for routing.
*
* @param string $theme
* The name of a theme.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function access($theme) {
// Cacheable until the theme settings are modified.
return AccessResult::allowedIf($this->checkAccess($theme))
->addCacheTags([
'config:' . $theme . '.settings',
]);
}
/**
* Indicates whether the theme is accessible based on whether it is installed.
*
* @param string $theme
* The name of a theme.
*
* @return bool
* TRUE if the theme is installed, FALSE otherwise.
*/
public function checkAccess($theme) {
return isset($this->themes[$theme]);
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary |
|---|---|---|---|
| ThemeAccessCheck::access | public | function | Checks access to the theme for routing. |
| ThemeAccessCheck::checkAccess | public | function | Indicates whether the theme is accessible based on whether it is installed. |
| ThemeAccessCheck::__construct | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.