function ThemeHandler::addTheme

Same name in other branches
  1. 9 core/lib/Drupal/Core/Extension/ThemeHandler.php \Drupal\Core\Extension\ThemeHandler::addTheme()
  2. 10 core/lib/Drupal/Core/Extension/ThemeHandler.php \Drupal\Core\Extension\ThemeHandler::addTheme()
  3. 11.x core/lib/Drupal/Core/Extension/ThemeHandler.php \Drupal\Core\Extension\ThemeHandler::addTheme()

Overrides ThemeHandlerInterface::addTheme

File

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

Class

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

Namespace

Drupal\Core\Extension

Code

public function addTheme(Extension $theme) {
    // Register the namespaces of installed themes.
    // @todo Implement proper theme registration
    // https://www.drupal.org/project/drupal/issues/2941757
    \Drupal::service('class_loader')->addPsr4('Drupal\\' . $theme->getName() . '\\', $this->root . '/' . $theme->getPath() . '/src');
    if (!empty($theme->info['libraries'])) {
        foreach ($theme->info['libraries'] as $library => $name) {
            $theme->libraries[$library] = $name;
        }
    }
    if (isset($theme->info['engine'])) {
        $theme->engine = $theme->info['engine'];
    }
    if (isset($theme->info['base theme'])) {
        $theme->base_theme = $theme->info['base theme'];
    }
    $this->list[$theme->getName()] = $theme;
}

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