class UserDataCollector in Devel 4.x
Same name and namespace in other branches
- 8.3 webprofiler/src/DataCollector/UserDataCollector.php \Drupal\webprofiler\DataCollector\UserDataCollector
- 8 webprofiler/src/DataCollector/UserDataCollector.php \Drupal\webprofiler\DataCollector\UserDataCollector
- 8.2 webprofiler/src/DataCollector/UserDataCollector.php \Drupal\webprofiler\DataCollector\UserDataCollector
Class UserDataCollector.
Hierarchy
- class \Drupal\webprofiler\DataCollector\UserDataCollector extends \Symfony\Component\HttpKernel\DataCollector\DataCollector implements DrupalDataCollectorInterface uses StringTranslationTrait
Expanded class hierarchy of UserDataCollector
1 string reference to 'UserDataCollector'
- webprofiler.services.yml in webprofiler/
webprofiler.services.yml - webprofiler/webprofiler.services.yml
1 service uses UserDataCollector
File
- webprofiler/
src/ DataCollector/ UserDataCollector.php, line 18
Namespace
Drupal\webprofiler\DataCollectorView source
class UserDataCollector extends DataCollector implements DrupalDataCollectorInterface {
use StringTranslationTrait, DrupalDataCollectorTrait;
/**
* @var \Drupal\Core\Session\AccountInterface
*/
private $currentUser;
/**
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
private $entityTypeManager;
/**
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
private $configFactory;
/**
* @var \Drupal\Core\Authentication\AuthenticationCollectorInterface
*/
private $providerCollector;
/**
* @param \Drupal\Core\Session\AccountInterface $current_user
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* @param \Drupal\Core\Authentication\AuthenticationCollectorInterface $provider_collector
*/
public function __construct(AccountInterface $current_user, EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory, AuthenticationCollectorInterface $provider_collector) {
$this->currentUser = $current_user;
$this->entityTypeManager = $entity_type_manager;
$this->configFactory = $config_factory;
$this->providerCollector = $provider_collector;
}
/**
* {@inheritdoc}
*/
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');
}
/**
* @return \Drupal\Core\Session\AccountInterface
*/
public function getUserName() {
return $this->data['name'];
}
/**
* @return bool
*/
public function getAuthenticated() {
return $this->data['authenticated'];
}
/**
* @return array
*/
public function getRoles() {
return $this->data['roles'];
}
/**
* @return string
*/
public function getProvider() {
return $this->data['provider'];
}
/**
* @return string
*/
public function getAnonymous() {
return $this->data['anonymous'];
}
/**
* {@inheritdoc}
*/
public function getName() {
return 'user';
}
/**
* {@inheritdoc}
*/
public function getTitle() {
return $this
->t('User');
}
/**
* {@inheritdoc}
*/
public function getPanelSummary() {
return $this
->getUserName();
}
/**
* {@inheritdoc}
*/
public function getIcon() {
return 'iVBORw0KGgoAAAANSUhEUgAAABgAAAAcCAYAAAB75n/uAAAC70lEQVR42u2V3UtTYRzHu+mFwCwK+gO6CEryPlg7yiYx50vDqUwjFIZDSYUk2ZTmCysHvg9ZVggOQZiRScsR4VwXTjEwdKZWk8o6gd5UOt0mbev7g/PAkLONIOkiBx+25/v89vuc85zn2Q5Fo9F95UDwnwhS5HK5TyqVRv8m1JN6k+AiC+fn54cwbgFNIrTQ/J9IqDcJJDGBHsgDgYBSq9W6ysvLPf39/SSUUU7zsQ1yc3MjmN90OBzfRkZG1umzQqGIxPSTkIBjgdDkaGNjoza2kcFgUCE/QvMsq6io2PV6vQu1tbV8Xl7etkql2qqvr/+MbDE/Pz8s9OP2Cjhwwmw29+4R3Kec1WZnZ4fn5uamc3Jyttra2qbH8ero6JgdHh5+CvFHq9X6JZHgzODgoCVW0NPTY0N+ltU2Nzdv4GqXsYSrPp+vDw80aLFYxru6uhyQ/rDb7a8TCVJDodB1jUazTVlxcXGQ5/mbyE+z2u7u7veY38BVT3Z2djopm5qa6isrK/tQWVn5qb29fSGR4DC4PDAwMEsZHuArjGnyGKutq6v7ajQaF6urq9/MzMz0QuSemJiwQDwGkR0POhhXgILjNTU1TaWlpTxlOp1uyWQyaUjMajMzM8Nut/tJQUHBOpZppbCwkM/KytrBznuL9xDVxBMo8KXHYnu6qKjIivmrbIy67x6Px4Yd58W672ApfzY0NCyNjo7OZmRkiAv8fr+O47iwmABXtoXaG3uykF6vX7bZbF6cgZWqqiqezYkKcNtmjO+CF2AyhufgjsvlMiU7vXEF+4C4ALf9CwdrlVAqlcFkTdRqdQSHLUDgBEeSCrArAsiGwENs0XfJBE6ncxm1D8Aj/B6tigkkJSUlmxSwLYhMDeRsyyUCd+lHrWxtbe2aTCbbZTn1ZD92F0Cr8GBfgnsgDZwDt8EzMBmHMXBLqD0PDMAh9Gql3iRIESQSIAXp4CRIBZeEjIvDFZAm1J4C6UK9ROiZcvCn/+8FvwHtDdJEaRY+oQAAAABJRU5ErkJggg==';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalDataCollectorInterface:: |
public | function | 8 | |
DrupalDataCollectorInterface:: |
public | function | 1 | |
DrupalDataCollectorInterface:: |
public | function | Returns the libraries needed in detail panel. | 2 |
DrupalDataCollectorInterface:: |
public | function | Returns true if this datacollector has a detail panel. | 2 |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UserDataCollector:: |
private | property | ||
UserDataCollector:: |
private | property | ||
UserDataCollector:: |
private | property | ||
UserDataCollector:: |
private | property | ||
UserDataCollector:: |
public | function | ||
UserDataCollector:: |
public | function | ||
UserDataCollector:: |
public | function | ||
UserDataCollector:: |
public | function |
Returns the collector icon in base64 format. Overrides DrupalDataCollectorInterface:: |
|
UserDataCollector:: |
public | function |
Returns the name of the collector. Overrides DrupalDataCollectorInterface:: |
|
UserDataCollector:: |
public | function |
Returns the string used in vertical tab summary. Overrides DrupalDataCollectorInterface:: |
|
UserDataCollector:: |
public | function | ||
UserDataCollector:: |
public | function | ||
UserDataCollector:: |
public | function |
Returns the datacollector title. Overrides DrupalDataCollectorInterface:: |
|
UserDataCollector:: |
public | function | ||
UserDataCollector:: |
public | function |