You are here

public function ConfigurationUpdateGenerator::generate in Update helper 8

Same name in this branch
  1. 8 src/Generator/ConfigurationUpdateGenerator.php \Drupal\update_helper\Generator\ConfigurationUpdateGenerator::generate()
  2. 8 modules/update_helper_checklist/src/Generator/ConfigurationUpdateGenerator.php \Drupal\update_helper_checklist\Generator\ConfigurationUpdateGenerator::generate()

Generate Checklist entry for configuration update.

Parameters

string $module: Module name where update will be generated.

string $update_number: Update number that will be used.

string $update_version: Update version for module.

string $description: Checklist entry title.

string $update_description: Checklist update description.

string $success_message: Checklist success message.

string $failure_message: Checklist failed message.

File

modules/update_helper_checklist/src/Generator/ConfigurationUpdateGenerator.php, line 76

Class

ConfigurationUpdateGenerator
Update hook generator for generate:configuration:update console command.

Namespace

Drupal\update_helper_checklist\Generator

Code

public function generate($module, $update_number, $update_version, $description, $update_description, $success_message, $failure_message) {
  $module_path = $this->moduleHandler
    ->getModule($module)
    ->getPath();
  $checklist_file = $module_path . DIRECTORY_SEPARATOR . UpdateChecklist::$updateChecklistFileName;
  $update_versions = $this->updateChecklist
    ->getUpdateVersions($module);
  end($update_versions);
  $last_update_version = current($update_versions);
  $parameters = [
    'update_hook_name' => $module . '_update_' . $update_number,
    'file_exists' => file_exists($checklist_file),
    'checklist_title' => $description,
    'checklist_description' => $update_description,
    'checklist_success' => $success_message,
    'checklist_failed' => $failure_message,
    'update_version' => $update_version === $last_update_version ? '' : $update_version,
  ];
  $this
    ->renderFile('configuration_update_checklist.yml.twig', $checklist_file, $parameters, FILE_APPEND);
}