You are here

public function UserDataCollector::collect in Devel 8

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

File

webprofiler/src/DataCollector/UserDataCollector.php, line 58

Class

UserDataCollector
Class UserDataCollector

Namespace

Drupal\webprofiler\DataCollector

Code

public function collect(Request $request, Response $response, \Exception $exception = NULL) {
  $this->data['name'] = $this->currentUser
    ->getDisplayName();
  $this->data['authenticated'] = $this->currentUser
    ->isAuthenticated();
  $this->data['roles'] = [];
  $storage = $this->entityManager
    ->getStorage('user_role');
  foreach ($this->currentUser
    ->getRoles() as $role) {
    $entity = $storage
      ->load($role);
    $this->data['roles'][] = $entity
      ->label();
  }
  foreach ($this->providerCollector
    ->getSortedProviders() as $provider_id => $provider) {
    if ($provider
      ->applies($request)) {
      $this->data['provider'] = $provider_id;
    }
  }
  $this->data['anonymous'] = $this->configFactory
    ->get('user.settings')
    ->get('anonymous');
}