You are here

public function ScanResultController::analyze in Upgrade Status 8.3

Same name and namespace in other branches
  1. 8.2 src/Controller/ScanResultController.php \Drupal\upgrade_status\Controller\ScanResultController::analyze()

Analyze a specific project in its own HTTP request.

Parameters

string $project_machine_name: The machine name of the project.

Return value

\Symfony\Component\HttpFoundation\JsonResponse Response object.

1 string reference to 'ScanResultController::analyze'
upgrade_status.routing.yml in ./upgrade_status.routing.yml
upgrade_status.routing.yml

File

src/Controller/ScanResultController.php, line 127

Class

ScanResultController

Namespace

Drupal\upgrade_status\Controller

Code

public function analyze(string $project_machine_name) {
  if ($project_machine_name == 'upgrade_status_request_test') {

    // Handle the special case of a request test which is testing the
    // HTTP sandboxing capability.
    return new JsonResponse([
      'message' => 'Request test success',
    ]);
  }
  else {

    // Dealing with a real project.
    $extension = $this->projectCollector
      ->loadProject($project_machine_name);
    \Drupal::service('upgrade_status.deprecation_analyzer')
      ->analyze($extension);
    return new JsonResponse([
      'message' => $this
        ->t('Scanned @project', [
        '@project' => $extension
          ->getName(),
      ]),
    ]);
  }
}