You are here

class DrupalDataCollector in Devel 8

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

Class DrupalDataCollector

Hierarchy

Expanded class hierarchy of DrupalDataCollector

1 string reference to 'DrupalDataCollector'
webprofiler.services.yml in webprofiler/webprofiler.services.yml
webprofiler/webprofiler.services.yml
1 service uses DrupalDataCollector
webprofiler.drupal in webprofiler/webprofiler.services.yml
Drupal\webprofiler\DataCollector\DrupalDataCollector

File

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

Namespace

Drupal\webprofiler\DataCollector
View source
class DrupalDataCollector extends DataCollector implements DrupalDataCollectorInterface {
  use StringTranslationTrait, DrupalDataCollectorTrait;

  /**
   * @var \Drupal\Core\Routing\RedirectDestinationInterface
   */
  private $redirectDestination;

  /**
   * @var \Drupal\Core\Routing\UrlGeneratorInterface
   */
  private $urlGenerator;

  /**
   * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirectDestination
   * @param \Drupal\Core\Routing\UrlGeneratorInterface $urlGenerator
   */
  public function __construct(RedirectDestinationInterface $redirectDestination, UrlGeneratorInterface $urlGenerator) {
    $this->redirectDestination = $redirectDestination;
    $this->urlGenerator = $urlGenerator;
  }

  /**
   * {@inheritdoc}
   */
  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;
    }
  }

  /**
   * @return string
   */
  public function getVersion() {
    return $this->data['version'];
  }

  /**
   * @return string
   */
  public function getProfile() {
    return $this->data['profile'];
  }

  /**
   * @return string
   */
  public function getConfigUrl() {
    return $this->data['config_url'];
  }

  /**
   * @return string
   */
  public function getGitCommit() {
    return $this->data['git_commit'];
  }

  /**
   * @return string
   */
  public function getAbbrGitCommit() {
    return $this->data['abbr_git_commit'];
  }

  /**
   * Returns the name of the collector.
   *
   * @return string The collector name
   *
   * @api
   */
  public function getName() {
    return 'drupal';
  }

  /**
   * {@inheritdoc}
   */
  public function getTitle() {
    return $this
      ->t('Drupal');
  }

  /**
   * {@inheritdoc}
   */
  public function hasPanel() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getIcon() {
    return 'iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnM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JBxZYnC+Xi/l4PL56T99uN/y8KDYCUpj2i2JRzONkWZYyGo0UXdeV4/GobDYb5Xw+J/obxv+mTqdT8rWTpND1ek3ihm3bRNO0F188O44T+UwmE+TQjBXNcDiciLD5fE7Shuu6xDTN0JdGgfi+//J9v98nA6EmqIoHYsJPxuFwIOKxiERDVxNQ4I4PNw1Ram6DIFAWiwUWG5uv+/2+E98V+IdOp7OiZzF6pitMhC2XyxDEfOKg1+t1ldnTtNtthxcB8sAGcgQRUbWGufM8LxQPfJBv3n+73Tq5qgVyibqWdYsASOUfLYyJJ679yKyHadDZbBYqkn8HMHaO3ydMl674rI8RayOACKUo/+l0SuAf12ZI9TRYLSZCJYk76GgbnyA9TxOlMpiqqrnuQhxk7igd8raJbKi/bvX/BBgANANSieJk+XMAAAAASUVORK5CYII=';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalDataCollector::$redirectDestination private property
DrupalDataCollector::$urlGenerator private property
DrupalDataCollector::collect public function Collects data for the given Request and Response.
DrupalDataCollector::getAbbrGitCommit public function
DrupalDataCollector::getConfigUrl public function
DrupalDataCollector::getGitCommit public function
DrupalDataCollector::getIcon public function Returns the collector icon in base64 format. Overrides DrupalDataCollectorInterface::getIcon
DrupalDataCollector::getName public function Returns the name of the collector. Overrides DrupalDataCollectorInterface::getName
DrupalDataCollector::getProfile public function
DrupalDataCollector::getTitle public function Returns the datacollector title. Overrides DrupalDataCollectorInterface::getTitle
DrupalDataCollector::getVersion public function
DrupalDataCollector::hasPanel public function Returns true if this datacollector has a detail panel. Overrides DrupalDataCollectorInterface::hasPanel
DrupalDataCollector::__construct public function
DrupalDataCollectorInterface::getData public function 8
DrupalDataCollectorInterface::getDrupalSettings public function 1
DrupalDataCollectorInterface::getLibraries public function Returns the libraries needed in detail panel. 2
DrupalDataCollectorInterface::getPanelSummary public function Returns the string used in vertical tab summary. 21
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.