public function UserDataCollector::collect in Devel 4.x
Same name and namespace in other branches
- 8.3 webprofiler/src/DataCollector/UserDataCollector.php \Drupal\webprofiler\DataCollector\UserDataCollector::collect()
- 8 webprofiler/src/DataCollector/UserDataCollector.php \Drupal\webprofiler\DataCollector\UserDataCollector::collect()
- 8.2 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\DataCollectorCode
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->entityTypeManager
->getStorage('user_role');
foreach ($this->currentUser
->getRoles() as $role) {
$entity = $storage
->load($role);
if ($entity) {
$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');
}