public function RectorResultController::resultExport in Upgrade Rector 8
Generates single project export.
Parameters
string $type: Type of the extension, it can be either 'module' or 'theme' or 'profile'.
string $project_machine_name: The machine name of the project.
Return value
\Symfony\Component\HttpFoundation\Response Response object.
1 string reference to 'RectorResultController::resultExport'
File
- src/
Controller/ RectorResultController.php, line 99
Class
Namespace
Drupal\upgrade_rector\ControllerCode
public function resultExport(string $type, string $project_machine_name) {
$extension = $this->projectCollector
->loadProject($type, $project_machine_name);
$raw_rector_result = $this->rectorResults
->get($project_machine_name);
$processed_result = $this->rectorProcessor
->processResults($raw_rector_result, $extension);
if ($processed_result['state'] === 'fail') {
$extension = '-errors.txt';
$content = $raw_rector_result;
}
elseif ($processed_result['state'] === 'success' && empty($processed_result['patch'])) {
$extension = '-results.txt';
$content = 'Nothing to patch in ' . $project_machine_name;
}
else {
$extension = '-upgrade-rector.patch';
$content = $processed_result['patch'];
}
$filename = $project_machine_name . $extension;
$response = new Response($content);
$response->headers
->set('Content-Disposition', 'attachment; filename="' . $filename . '"');
return $response;
}