You are here

public function DrupalDataCollector::collect in Devel 8

Same name and namespace in other branches
  1. 8.3 webprofiler/src/DataCollector/DrupalDataCollector.php \Drupal\webprofiler\DataCollector\DrupalDataCollector::collect()
  2. 8.2 webprofiler/src/DataCollector/DrupalDataCollector.php \Drupal\webprofiler\DataCollector\DrupalDataCollector::collect()
  3. 4.x webprofiler/src/DataCollector/DrupalDataCollector.php \Drupal\webprofiler\DataCollector\DrupalDataCollector::collect()

File

webprofiler/src/DataCollector/DrupalDataCollector.php, line 46

Class

DrupalDataCollector
Class DrupalDataCollector

Namespace

Drupal\webprofiler\DataCollector

Code

public function collect(Request $request, Response $response, \Exception $exception = NULL) {
  $this->data['version'] = Drupal::VERSION;
  $this->data['profile'] = drupal_get_profile();
  $this->data['config_url'] = (new Drupal\Core\Url('webprofiler.settings', [], [
    'query' => $this->redirectDestination
      ->getAsArray(),
  ]))
    ->toString();
  try {
    $process = new Process("git log -1 --pretty=format:'%H - %s (%ci)' --abbrev-commit");
    $process
      ->setTimeout(3600);
    $process
      ->mustRun();
    $this->data['git_commit'] = $process
      ->getOutput();
    $process = new Process("git log -1 --pretty=format:'%h' --abbrev-commit");
    $process
      ->setTimeout(3600);
    $process
      ->mustRun();
    $this->data['abbr_git_commit'] = $process
      ->getOutput();
  } catch (ProcessFailedException $e) {
    $this->data['git_commit'] = $this->data['git_commit_abbr'] = NULL;
  } catch (RuntimeException $e) {
    $this->data['git_commit'] = $this->data['git_commit_abbr'] = NULL;
  }
}