EventAnEnrollManager.php in Open Social 8.5
Same filename and directory in other branches
- 8.9 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php
- 8.6 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php
- 8.7 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php
- 8.8 modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php
- 10.3.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php
- 10.0.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php
- 10.1.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php
- 10.2.x modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.php
Namespace
Drupal\social_event_an_enrollFile
modules/social_features/social_event/modules/social_event_an_enroll/src/EventAnEnrollManager.phpView source
<?php
namespace Drupal\social_event_an_enroll;
use Drupal\social_event\EventEnrollmentInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Class EventAnEnrollManager.
*/
class EventAnEnrollManager {
use StringTranslationTrait;
/**
* Returns guest name.
*
* @param \Drupal\social_event\EventEnrollmentInterface $entity
* The event enrollment.
* @param bool $email
* TRUE if can show E-mail address when first and last names is not set.
*
* @return string
* Full name or E-mail address.
*/
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);
}
/**
* Check if enrollment user is guest.
*
* @param \Drupal\social_event\EventEnrollmentInterface $entity
* The event enrollment.
*
* @return bool
* TRUE if it is guest.
*/
public function isGuest(EventEnrollmentInterface $entity) {
return !$entity->field_account->target_id;
}
}
Classes
Name | Description |
---|---|
EventAnEnrollManager | Class EventAnEnrollManager. |