public function Profile::label in Profile 8
Gets the label of the entity.
Return value
string|null The label of the entity, or NULL if there is no label defined.
Overrides ContentEntityBase::label
File
- src/
Entity/ Profile.php, line 89
Class
- Profile
- Defines the profile entity class.
Namespace
Drupal\profile\EntityCode
public function label() {
$profile_type = ProfileType::load($this
->bundle());
$label = $this
->t('@type #@id', [
'@type' => $profile_type
->getDisplayLabel() ?: $profile_type
->label(),
'@id' => $this
->id(),
]);
// Allow the label to be overridden.
$event = new ProfileLabelEvent($this, $label);
$event_dispatcher = \Drupal::service('event_dispatcher');
$event_dispatcher
->dispatch(ProfileEvents::PROFILE_LABEL, $event);
$label = $event
->getLabel();
return $label;
}