You are here

class ProfileLabelSubscriber in Open Social 8.9

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

Class ProfileLabelSubscriber.

@package Drupal\social_profile\EventSubscriber

Hierarchy

  • class \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of ProfileLabelSubscriber

1 string reference to 'ProfileLabelSubscriber'
social_profile.services.yml in modules/social_features/social_profile/social_profile.services.yml
modules/social_features/social_profile/social_profile.services.yml
1 service uses ProfileLabelSubscriber
social_profile.profilelabel_subscriber in modules/social_features/social_profile/social_profile.services.yml
Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber

File

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

Namespace

Drupal\social_profile\EventSubscriber
View source
class ProfileLabelSubscriber implements EventSubscriberInterface {

  /**
   * Get the label event.
   *
   * @return mixed
   *   Returns request events.
   */
  public static function getSubscribedEvents() {
    $events[ProfileEvents::PROFILE_LABEL][] = [
      'overrideProfileLabel',
    ];
    return $events;
  }

  /**
   * Subscriber Callback for the event.
   *
   * @param \Drupal\profile\Event\ProfileLabelEvent $event
   *   The event.
   */
  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);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ProfileLabelSubscriber::getSubscribedEvents public static function Get the label event.
ProfileLabelSubscriber::overrideProfileLabel public function Subscriber Callback for the event.