public function EventAnEnrollManager::getGuestName in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php \Drupal\social_event_an_enroll\EventAnEnrollManager::getGuestName()
- 8.5 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php \Drupal\social_event_an_enroll\EventAnEnrollManager::getGuestName()
- 8.6 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php \Drupal\social_event_an_enroll\EventAnEnrollManager::getGuestName()
- 8.7 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php \Drupal\social_event_an_enroll\EventAnEnrollManager::getGuestName()
- 10.3.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php \Drupal\social_event_an_enroll\EventAnEnrollManager::getGuestName()
- 10.0.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php \Drupal\social_event_an_enroll\EventAnEnrollManager::getGuestName()
- 10.1.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php \Drupal\social_event_an_enroll\EventAnEnrollManager::getGuestName()
- 10.2.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php \Drupal\social_event_an_enroll\EventAnEnrollManager::getGuestName()
Returns guest name.
Parameters
\Drupal\social_event\EventEnrollmentInterface $entity: The event enrollment.
bool $email: TRUE if can show E-mail address when first and last names is not set.
Return value
string Full name or E-mail address.
File
- modules/
social_features/ social_event/ modules/ social_event_an_enroll/ src/ EventAnEnrollManager.php, line 26
Class
- EventAnEnrollManager
- Class EventAnEnrollManager.
Namespace
Drupal\social_event_an_enrollCode
public function getGuestName(EventEnrollmentInterface $entity, $email = TRUE) {
$parts = [];
// If user doesn't have access to see the first/last/email value.
// Lets return guest.
if (!social_event_manager_or_organizer()) {
return $this
->t('Guest');
}
if (!$entity->field_first_name
->isEmpty()) {
$parts[] = $entity->field_first_name->value;
}
if (!$entity->field_last_name
->isEmpty()) {
$parts[] = $entity->field_last_name->value;
}
if (!$parts && $email) {
$parts[] = $entity->field_email->value;
}
return implode(' ', $parts);
}