ThemeHandler::setDefault

public ThemeHandler::setDefault($name)

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 147

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;
}
doc_Drupal
2016-10-29 09:48:00
Comments
Leave a Comment

Please login to continue.