function RecipeRunner::installTheme
Same name in other branches
- 10 core/lib/Drupal/Core/Recipe/RecipeRunner.php \Drupal\Core\Recipe\RecipeRunner::installTheme()
Installs a theme for a recipe.
Parameters
string $theme: The name of the theme to install.
\Drupal\Core\Config\StorageInterface|\Drupal\Core\Recipe\Recipe $recipeConfigStorage: The recipe or recipe's config storage.
array<mixed>|null $context: The batch context if called by a batch.
1 call to RecipeRunner::installTheme()
- RecipeRunner::processInstall in core/
lib/ Drupal/ Core/ Recipe/ RecipeRunner.php - Installs the extensions.
File
-
core/
lib/ Drupal/ Core/ Recipe/ RecipeRunner.php, line 278
Class
- RecipeRunner
- Applies a recipe.
Namespace
Drupal\Core\RecipeCode
public static function installTheme(string $theme, StorageInterface|Recipe $recipeConfigStorage, ?array &$context = NULL) : void {
if ($recipeConfigStorage instanceof Recipe) {
$recipeConfigStorage = $recipeConfigStorage->config
->getConfigStorage();
}
// Disable configuration entity install.
\Drupal::service('config.installer')->setSyncing(TRUE);
$default_install_path = \Drupal::service('extension.list.theme')->get($theme)
->getPath() . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
// Allow the recipe to override simple configuration from the theme.
$storage = new RecipeOverrideConfigStorage($recipeConfigStorage, new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION));
\Drupal::service('config.installer')->setSourceStorage($storage);
\Drupal::service('theme_installer')->install([
$theme,
]);
\Drupal::service('config.installer')->setSyncing(FALSE);
$context['message'] = t('Installed %theme theme.', [
'%theme' => \Drupal::service('extension.list.theme')->getName($theme),
]);
$context['results']['theme'][] = $theme;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.