You are here

public function Contact::getFullName in RedHen CRM 8

Gets the full Contact name.

Return value

string Name of the Contact.

Overrides ContactInterface::getFullName

1 call to Contact::getFullName()
Contact::label in modules/redhen_contact/src/Entity/Contact.php
Gets the label of the entity.

File

modules/redhen_contact/src/Entity/Contact.php, line 86

Class

Contact
Defines the Contact entity.

Namespace

Drupal\redhen_contact\Entity

Code

public function getFullName() {
  $first_name = $this
    ->get('first_name')->value;
  $middle_name = $this
    ->get('middle_name')->value;
  $last_name = $this
    ->get('last_name')->value;
  $name = $first_name . (empty($middle_name) ? '' : ' ') . $middle_name . (empty($first_name) ? '' : ' ') . $last_name;

  // Allow other modules to alter the full name of the contact.
  \Drupal::moduleHandler()
    ->alter('redhen_contact_name', $name, $this);
  return $name;
}