You are here

public function SocialEventManagersViewsBulkOperationsBulkForm::getEntityLabel in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::getEntityLabel()
  2. 8.5 modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::getEntityLabel()
  3. 8.6 modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::getEntityLabel()
  4. 8.7 modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::getEntityLabel()
  5. 8.8 modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::getEntityLabel()
  6. 10.3.x modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::getEntityLabel()
  7. 10.0.x modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::getEntityLabel()
  8. 10.2.x modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php \Drupal\social_event_managers\Plugin\views\field\SocialEventManagersViewsBulkOperationsBulkForm::getEntityLabel()

Returns modified entity label.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity.

Return value

string The label text.

2 calls to SocialEventManagersViewsBulkOperationsBulkForm::getEntityLabel()
SocialEventAnEnrollViewsBulkOperationsBulkForm::getEntityLabel in modules/social_features/social_event/modules/social_event_an_enroll/src/Plugin/views/field/SocialEventAnEnrollViewsBulkOperationsBulkForm.php
Returns modified entity label.
SocialEventManagersViewsBulkOperationsBulkForm::viewsForm in modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php
Form constructor for the bulk form.
1 method overrides SocialEventManagersViewsBulkOperationsBulkForm::getEntityLabel()
SocialEventAnEnrollViewsBulkOperationsBulkForm::getEntityLabel in modules/social_features/social_event/modules/social_event_an_enroll/src/Plugin/views/field/SocialEventAnEnrollViewsBulkOperationsBulkForm.php
Returns modified entity label.

File

modules/social_features/social_event/modules/social_event_managers/src/Plugin/views/field/SocialEventManagersViewsBulkOperationsBulkForm.php, line 330

Class

SocialEventManagersViewsBulkOperationsBulkForm
Defines the Enrollments Views Bulk Operations field plugin.

Namespace

Drupal\social_event_managers\Plugin\views\field

Code

public function getEntityLabel(EntityInterface $entity) {
  $profiles = $this->entityTypeManager
    ->getStorage('profile')
    ->loadByProperties([
    'uid' => $entity->field_account->target_id,
  ]);

  /** @var \Drupal\profile\Entity\ProfileInterface $profile */
  $profile = reset($profiles);

  // It must be a Guest so we pick the name values we can get.
  if (!$profile) {
    $name = '';
    $first_name = $entity
      ->get('field_first_name')
      ->getValue()[0]['value'];
    $last_name = $entity
      ->get('field_last_name')
      ->getValue()[0]['value'];
    if (!empty($first_name)) {
      $name .= $first_name;
      $name .= ' ';
    }
    if (!empty($last_name)) {
      $name .= $last_name;
    }
    return $name;
  }

  /** @var \Drupal\Core\StringTranslation\TranslatableMarkup $label */
  $label = $profile
    ->label();
  return $label
    ->getArguments()['@name'];
}