public function SocialEventInviteRecipientField::render in Open Social 10.0.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::render()
- 10.3.x modules/social_features/social_event/modules/social_event_invite/src/Plugin/views/field/SocialEventInviteRecipientField.php \Drupal\social_event_invite\Plugin\views\field\SocialEventInviteRecipientField::render()
- 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::render()
- 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::render()
Renders the field.
Parameters
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
Overrides FieldPluginBase::render
File
- modules/
social_features/ social_event/ modules/ social_event_invite/ src/ Plugin/ views/ field/ SocialEventInviteRecipientField.php, line 77
Class
- SocialEventInviteRecipientField
- Displays the invited email or user if there is an account.
Namespace
Drupal\social_event_invite\Plugin\views\fieldCode
public function render(ResultRow $values) {
// If the row result values for the profile id is empty we should check
// and get the event_enrollment__field_email value.
$build = [];
// Check the database for the email and account.
$recipient = $this
->checkEmailAndAccount($values->id, $values->users_field_data_event_enrollment__field_account_uid);
// Set the email already.
if (!empty($recipient['email'])) {
$build = $recipient['email'];
}
// If we have an account then we should load the
// profile and render it instead of the email.
if (!empty($recipient['account'])) {
// Load the account profile.
/** @var \Drupal\Core\Session\AccountInterface $account */
$account = $recipient['account'];
$storage = $this->entityTypeManager
->getStorage('profile');
$profile = $storage
->loadByUser($account, 'profile');
// Build the rendered entity for this profile.
$entity = $this
->getEntity($values);
if ($entity && $profile) {
$build = [];
$entity = $this
->getEntityTranslation($entity, $values);
$view_builder = $this->entityTypeManager
->getViewBuilder('profile');
$build += $view_builder
->view($profile, 'table', $entity
->language()
->getId());
return $build;
}
}
return $build;
}