class ProfileLabelSubscriber in Open Social 8.9
Same name and namespace in other branches
- 8 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber
- 8.2 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber
- 8.3 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber
- 8.4 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber
- 8.5 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber
- 8.6 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber
- 8.7 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber
- 8.8 modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber
- 10.3.x modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber
- 10.0.x modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber
- 10.1.x modules/social_features/social_profile/src/EventSubscriber/ProfileLabelSubscriber.php \Drupal\social_profile\EventSubscriber\ProfileLabelSubscriber
- 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\EventSubscriberView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ProfileLabelSubscriber:: |
public static | function | Get the label event. | |
ProfileLabelSubscriber:: |
public | function | Subscriber Callback for the event. |