private function SocialEventInviteRecipientField::checkEmailAndAccount in Open Social 10.3.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/modules/social_event_invite/src/Plugin/views/field/SocialEventInviteRecipientField.php \Drupal\social_event_invite\Plugin\views\field\SocialEventInviteRecipientField::checkEmailAndAccount()
- 10.0.x modules/social_features/social_event/modules/social_event_invite/src/Plugin/views/field/SocialEventInviteRecipientField.php \Drupal\social_event_invite\Plugin\views\field\SocialEventInviteRecipientField::checkEmailAndAccount()
- 10.1.x modules/social_features/social_event/modules/social_event_invite/src/Plugin/views/field/SocialEventInviteRecipientField.php \Drupal\social_event_invite\Plugin\views\field\SocialEventInviteRecipientField::checkEmailAndAccount()
- 10.2.x modules/social_features/social_event/modules/social_event_invite/src/Plugin/views/field/SocialEventInviteRecipientField.php \Drupal\social_event_invite\Plugin\views\field\SocialEventInviteRecipientField::checkEmailAndAccount()
Get the recipient by enrollment id.
Parameters
string $enrollment_id: The enrollment id.
int $account_id: The account id.
Return value
array Return the fetched values.
1 call to SocialEventInviteRecipientField::checkEmailAndAccount()
- SocialEventInviteRecipientField::render in modules/
social_features/ social_event/ modules/ social_event_invite/ src/ Plugin/ views/ field/ SocialEventInviteRecipientField.php - Renders the field.
File
- modules/
social_features/ social_event/ modules/ social_event_invite/ src/ Plugin/ views/ field/ SocialEventInviteRecipientField.php, line 123
Class
- SocialEventInviteRecipientField
- Displays the invited email or user if there is an account.
Namespace
Drupal\social_event_invite\Plugin\views\fieldCode
private function checkEmailAndAccount($enrollment_id, $account_id) {
$email = NULL;
$account = NULL;
// If we already have a given profile, load the profile.
if ($account_id) {
$account = $this->entityTypeManager
->getStorage('user')
->load($account_id);
return [
'email' => $account
->getEmail(),
'account' => $account,
];
}
// Otherwise, see if we have an recipient email.
$emailQuery = $this->database
->select('event_enrollment__field_event', 'eefev');
$emailQuery
->join('event_enrollment__field_email', 'eefem', 'eefem.entity_id = ' . $enrollment_id);
$emailQuery
->addField('eefem', 'field_email_value');
$email = $emailQuery
->execute()
->fetchField();
// Check if there is an user registered with this email.
$userQuery = \Drupal::database()
->select('users_field_data', 'ufd');
$userQuery
->condition('mail', $email);
$userQuery
->addField('ufd', 'uid');
$userId = $userQuery
->execute()
->fetchField();
$account = NULL;
if ($userId) {
$account = $this->entityTypeManager
->getStorage('user')
->load($userId);
}
return [
'email' => $email,
'account' => $account,
];
}