function RecipeRunner::toBatchOperationsInstall

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Recipe/RecipeRunner.php \Drupal\Core\Recipe\RecipeRunner::toBatchOperationsInstall()
  2. 10 core/lib/Drupal/Core/Recipe/RecipeRunner.php \Drupal\Core\Recipe\RecipeRunner::toBatchOperationsInstall()

Converts a recipe's install tasks to batch operations.

Parameters

\Drupal\Core\Recipe\Recipe $recipe: The recipe to convert install tasks to batch operations.

string[] $modules: The modules that will already be installed due to previous recipes in the batch.

string[] $themes: The themes that will already be installed due to previous recipes in the batch.

Return value

array<int, array{0: callable, 1: array{mixed}}> The array of batch operations. Each value is an array with two values. The first value is a callable and the second value are the arguments to pass to the callable.

1 call to RecipeRunner::toBatchOperationsInstall()
RecipeRunner::toBatchOperationsRecipe in core/lib/Drupal/Core/Recipe/RecipeRunner.php
Helper method to convert a recipe to batch operations.

File

core/lib/Drupal/Core/Recipe/RecipeRunner.php, line 236

Class

RecipeRunner
Applies a recipe.

Namespace

Drupal\Core\Recipe

Code

protected static function toBatchOperationsInstall(Recipe $recipe, array &$modules, array &$themes) : array {
  $new_modules = [];
  foreach ($recipe->install->modules as $name) {
    if (in_array($name, $modules, TRUE)) {
      continue;
    }
    $new_modules[] = $name;
    $modules[] = $name;
  }
  $steps = [];
  if (!empty($new_modules)) {
    foreach (array_chunk($new_modules, Settings::get('core.multi_module_install_batch_size', 20)) as $modules_chunk) {
      $steps[] = [
        [
          RecipeRunner::class,
          'installModules',
        ],
        [
          $modules_chunk,
          $recipe,
        ],
      ];
    }
  }
  foreach ($recipe->install->themes as $name) {
    if (in_array($name, $themes, TRUE)) {
      continue;
    }
    $themes[] = $name;
    $steps[] = [
      [
        RecipeRunner::class,
        'installTheme',
      ],
      [
        $name,
        $recipe,
      ],
    ];
  }
  return $steps;
}

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