public function UserDataCdfAttribute::onPopulateAttributes in Acquia Content Hub 8.2
Method called on the POPULATE_CDF_ATTRIBUTES event.
Extracts user specific data for identifying duplicate and anonymous users.
Parameters
\Drupal\acquia_contenthub\Event\CdfAttributesEvent $event: The CdfAttributesEvent object.
Throws
\Exception
File
- src/
EventSubscriber/ CdfAttributes/ UserDataCdfAttribute.php, line 34
Class
- UserDataCdfAttribute
- Extracts user specific data for identifying duplicate and anonymous users.
Namespace
Drupal\acquia_contenthub\EventSubscriber\CdfAttributesCode
public function onPopulateAttributes(CdfAttributesEvent $event) {
$entity = $event
->getEntity();
if ($entity
->getEntityTypeId() !== 'user') {
return;
}
/** @var \Drupal\user\Entity\User $entity */
$cdf = $event
->getCdf();
$cdf
->addAttribute('username', CDFAttribute::TYPE_STRING, $entity
->label());
if ($entity
->isAnonymous()) {
$cdf
->addAttribute('is_anonymous', CDFAttribute::TYPE_BOOLEAN, TRUE);
}
elseif ($entity
->getEmail()) {
$cdf
->addAttribute('mail', CDFAttribute::TYPE_STRING, $entity
->getEmail());
}
}