function ReviewForm::prepareOutput

Same name in other branches
  1. 9 core/modules/migrate_drupal_ui/src/Form/ReviewForm.php \Drupal\migrate_drupal_ui\Form\ReviewForm::prepareOutput()
  2. 10 core/modules/migrate_drupal_ui/src/Form/ReviewForm.php \Drupal\migrate_drupal_ui\Form\ReviewForm::prepareOutput()

Prepare the migration state data for output.

Each source and destination module_name is changed to the human-readable name, the destination modules are put into a CSV format, and everything is sorted.

Parameters

string[] $migration_state: An array where the keys are machine names of modules on the source site. Values are lists of machine names of modules on the destination site, in CSV format.

Return value

string[][] An indexed array of arrays that contain module data, sorted by the source module name. Each sub-array contains the source module name, the source module machine name, and the destination module names in a sorted CSV format.

1 call to ReviewForm::prepareOutput()
ReviewForm::buildForm in core/modules/migrate_drupal_ui/src/Form/ReviewForm.php
Form constructor.

File

core/modules/migrate_drupal_ui/src/Form/ReviewForm.php, line 284

Class

ReviewForm
Migrate Upgrade review form.

Namespace

Drupal\migrate_drupal_ui\Form

Code

protected function prepareOutput(array $migration_state) {
    $output = [];
    foreach ($migration_state as $source_machine_name => $destination_modules) {
        $data = NULL;
        if (isset($this->systemData['module'][$source_machine_name]['info'])) {
            $data = unserialize($this->systemData['module'][$source_machine_name]['info']);
        }
        $source_module_name = $data['name'] ?? $source_machine_name;
        // Get the names of all the destination modules.
        $destination_module_names = [];
        if (!empty($destination_modules)) {
            $destination_modules = explode(', ', $destination_modules);
            foreach ($destination_modules as $destination_module) {
                if ($destination_module === 'core') {
                    $destination_module_names[] = 'Core';
                }
                else {
                    try {
                        $destination_module_names[] = $this->moduleExtensionList
                            ->getName($destination_module);
                    } catch (UnknownExtensionException) {
                        $destination_module_names[] = $destination_module;
                    }
                }
            }
        }
        sort($destination_module_names);
        $output[$source_machine_name] = [
            'source_module_name' => $source_module_name,
            'source_machine_name' => $source_machine_name,
            'destination' => implode(', ', $destination_module_names),
        ];
    }
    usort($output, function ($a, $b) {
        return strcmp($a['source_module_name'], $b['source_module_name']);
    });
    return $output;
}

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