You are here

public function DeprecationAnalyser::logFatalError in Upgrade Status 8

Shutdown function to handle fatal errors in the parsing process.

Parameters

\Drupal\Core\Extension\Extension $extension: Failed extension.

File

src/DeprecationAnalyser.php, line 406

Class

DeprecationAnalyser

Namespace

Drupal\upgrade_status

Code

public function logFatalError(Extension $extension) {
  $project_name = $extension
    ->getName();
  $result = $this->scanResultStorage
    ->get($project_name);
  $message = error_get_last();
  if (empty($result)) {
    $this->logger
      ->error($this
      ->t("Fatal error occurred for @project_machine_name.", [
      '@project_machine_name' => $project_name,
    ]));
    $result = [];
    $result['date'] = REQUEST_TIME;
    $result['data'] = [
      'totals' => [
        'errors' => 0,
        'file_errors' => 1,
      ],
      'files' => [],
    ];
    $file_name = $message['file'];
    $result['data']['files'][$file_name] = [
      'errors' => 1,
      'messages' => [
        [
          'message' => $message['message'],
          'line' => $message['line'],
        ],
      ],
    ];
    $this->scanResultStorage
      ->set($project_name, json_encode($result));
  }
}