You are here

public function ProfileLabelSubscriber::overrideProfileLabel in Open Social 10.2.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()
  2. 8 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()
  3. 8.2 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()
  4. 8.3 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()
  5. 8.4 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()
  6. 8.5 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()
  7. 8.6 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()
  8. 8.7 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()
  9. 8.8 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()
  10. 10.3.x modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()
  11. 10.0.x modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()
  12. 10.1.x modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber::overrideProfileLabel()

Subscriber Callback for the event.

Parameters

\Drupal\profile\Event\ProfileLabelEvent $event: The event.

File

modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php, line 35

Class

ProfileLabelSubscriber
Class ProfileLabelSubscriber.

Namespace

Drupal\social_profile\EventSubscriber

Code

public function overrideProfileLabel(ProfileLabelEvent $event) {
  $profile = $event
    ->getProfile();
  if ($profile instanceof Profile) {
    $account = User::load($profile
      ->getOwnerId());
    if ($account instanceof User) {
      $label = t('Profile of @name', [
        '@name' => $account
          ->getDisplayName(),
      ]);
      $event
        ->setLabel($label);
    }
  }
}