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'];
  }
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'];
  }
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' ] ; }
Returns modified entity label.

@param \Drupal\Core\Entity\EntityInterface $entity
The entity.

@return string
The label text.
Returns modified entity label .