function ThemeInstallController::installTheme

Same name in other branches
  1. 10 core/modules/system/tests/modules/nightwatch_theme_install_utility/src/Controller/ThemeInstallController.php \Drupal\nightwatch_theme_install_utility\Controller\ThemeInstallController::installTheme()

Installs a theme.

Parameters

string $theme: The theme to install.

string $default_or_admin: Which type of theme to install, can be `default` or `admin`.

Return value

array A render array confirming installation.

2 calls to ThemeInstallController::installTheme()
ThemeInstallController::installAdmin in core/modules/system/tests/modules/nightwatch_theme_install_utility/src/Controller/ThemeInstallController.php
Install a theme as the admin theme.
ThemeInstallController::installDefault in core/modules/system/tests/modules/nightwatch_theme_install_utility/src/Controller/ThemeInstallController.php
Install a theme as default.

File

core/modules/system/tests/modules/nightwatch_theme_install_utility/src/Controller/ThemeInstallController.php, line 83

Class

ThemeInstallController
Provides an easier way for Nightwatch tests to install themes.

Namespace

Drupal\nightwatch_theme_install_utility\Controller

Code

private function installTheme($theme, $default_or_admin) : array {
    assert(in_array($default_or_admin, [
        'default',
        'admin',
    ]), 'The $default_or_admin parameter must be `default` or `admin`');
    $config = $this->configFactory
        ->getEditable('system.theme');
    $this->themeInstaller
        ->install([
        $theme,
    ]);
    $config->set($default_or_admin, $theme)
        ->save();
    return [
        '#type' => 'container',
        '#attributes' => [
            'id' => 'theme-installed',
        ],
        '#markup' => "Installed {$theme} as {$default_or_admin} theme",
    ];
}

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