You are here

public function ThemeHandler::setDefault in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Extension/ThemeHandler.php \Drupal\Core\Extension\ThemeHandler::setDefault()

Sets a new default theme.

Parameters

string $theme: The new default theme.

Return value

$this

Overrides ThemeHandlerInterface::setDefault

File

core/lib/Drupal/Core/Extension/ThemeHandler.php, line 149
Contains \Drupal\Core\Extension\ThemeHandler.

Class

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

Namespace

Drupal\Core\Extension

Code

public function setDefault($name) {
  $list = $this
    ->listInfo();
  if (!isset($list[$name])) {
    throw new \InvalidArgumentException("{$name} theme is not installed.");
  }
  $this->configFactory
    ->getEditable('system.theme')
    ->set('default', $name)
    ->save();
  return $this;
}