function 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');
}