You are here

public function ThemeController::install in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Controller/ThemeController.php \Drupal\system\Controller\ThemeController::install()

Installs a theme.

Parameters

\Symfony\Component\HttpFoundation\Request $request: A request object containing a theme name and a valid token.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse Redirects back to the appearance admin page.

Throws

\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException Throws access denied when no theme or token is set in the request or when the token is invalid.

1 string reference to 'ThemeController::install'
system.routing.yml in core/modules/system/system.routing.yml
core/modules/system/system.routing.yml

File

core/modules/system/src/Controller/ThemeController.php, line 110
Contains \Drupal\system\Controller\ThemeController.

Class

ThemeController
Controller for theme handling.

Namespace

Drupal\system\Controller

Code

public function install(Request $request) {
  $theme = $request
    ->get('theme');
  if (isset($theme)) {
    try {
      if ($this->themeHandler
        ->install(array(
        $theme,
      ))) {
        $themes = $this->themeHandler
          ->listInfo();
        drupal_set_message($this
          ->t('The %theme theme has been installed.', array(
          '%theme' => $themes[$theme]->info['name'],
        )));
      }
      else {
        drupal_set_message($this
          ->t('The %theme theme was not found.', array(
          '%theme' => $theme,
        )), 'error');
      }
    } catch (PreExistingConfigException $e) {
      $config_objects = $e
        ->flattenConfigObjects($e
        ->getConfigObjects());
      drupal_set_message($this
        ->formatPlural(count($config_objects), 'Unable to install @extension, %config_names already exists in active configuration.', 'Unable to install @extension, %config_names already exist in active configuration.', array(
        '%config_names' => implode(', ', $config_objects),
        '@extension' => $theme,
      )), 'error');
    } catch (UnmetDependenciesException $e) {
      drupal_set_message($e
        ->getTranslatedMessage($this
        ->getStringTranslation(), $theme), 'error');
    }
    return $this
      ->redirect('system.themes_page');
  }
  throw new AccessDeniedHttpException();
}