Chris@0: themeHandler = $theme_handler; Chris@0: } Chris@17: Chris@0: /** Chris@0: * Checks access to the theme for routing. Chris@0: * Chris@0: * @param string $theme Chris@0: * The name of a theme. Chris@0: * Chris@0: * @return \Drupal\Core\Access\AccessResultInterface Chris@0: * The access result. Chris@0: */ Chris@0: public function access($theme) { Chris@0: // Cacheable until the theme settings are modified. Chris@0: return AccessResult::allowedIf($this->checkAccess($theme))->addCacheTags(['config:' . $theme . '.settings']); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Indicates whether the theme is accessible based on whether it is installed. Chris@0: * Chris@0: * @param string $theme Chris@0: * The name of a theme. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE if the theme is installed, FALSE otherwise. Chris@0: */ Chris@0: public function checkAccess($theme) { Chris@0: $themes = $this->themeHandler->listInfo(); Chris@0: return !empty($themes[$theme]->status); Chris@0: } Chris@0: Chris@0: }