function RecipeRunner::toBatchOperationsRecipe

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

Helper method to convert a recipe to batch operations.

Parameters

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

string[] $recipes: The paths of the recipes that have already been converted 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::toBatchOperationsRecipe()
RecipeRunner::toBatchOperations in core/lib/Drupal/Core/Recipe/RecipeRunner.php
Converts a recipe into a series of batch operations.

File

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

Class

RecipeRunner
Applies a recipe.

Namespace

Drupal\Core\Recipe

Code

protected static function toBatchOperationsRecipe(Recipe $recipe, array $recipes, array &$modules, array &$themes) : array {
  if (in_array($recipe->path, $recipes, TRUE)) {
    return [];
  }
  $steps = [];
  $recipes[] = $recipe->path;
  foreach ($recipe->recipes->recipes as $sub_recipe) {
    $steps = array_merge($steps, static::toBatchOperationsRecipe($sub_recipe, $recipes, $modules, $themes));
  }
  $steps = array_merge($steps, static::toBatchOperationsInstall($recipe, $modules, $themes));
  if ($recipe->config
    ->hasTasks()) {
    $steps[] = [
      [
        RecipeRunner::class,
        'installConfig',
      ],
      [
        $recipe,
      ],
    ];
  }
  if (!empty($recipe->content->data)) {
    $steps[] = [
      [
        RecipeRunner::class,
        'installContent',
      ],
      [
        $recipe,
      ],
    ];
  }
  $steps[] = [
    [
      RecipeRunner::class,
      'triggerEvent',
    ],
    [
      $recipe,
    ],
  ];
  return $steps;
}

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