function social_follow_content_event_enrollment_follow in Open Social 8
Same name and namespace in other branches
- 8.9 modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
- 8.2 modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
- 8.3 modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
- 8.4 modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
- 8.5 modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
- 8.6 modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
- 8.7 modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
- 8.8 modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
- 10.3.x modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
- 10.0.x modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
- 10.1.x modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
- 10.2.x modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_event_enrollment_follow()
Automatically follow content when user enrolls the event.
2 calls to social_follow_content_event_enrollment_follow()
- social_follow_content_event_enrollment_insert in modules/
social_features/ social_follow_content/ social_follow_content.module - Implements hook_ENTIT_YTYPE_insert().
- social_follow_content_event_enrollment_update in modules/
social_features/ social_follow_content/ social_follow_content.module - Implements hook_ENTIT_YTYPE_update().
File
- modules/
social_features/ social_follow_content/ social_follow_content.module, line 28 - The Social core module.
Code
function social_follow_content_event_enrollment_follow(EntityInterface $entity) {
if ($entity->field_enrollment_status->value) {
// Check if user already follow this content.
$account = \Drupal::currentUser();
$properties = [
'uid' => $account
->id(),
'entity_type' => 'node',
'entity_id' => $entity->field_event->target_id,
'flag_id' => 'follow_content',
];
$flaggings = \Drupal::entityTypeManager()
->getStorage('flagging')
->loadByProperties($properties);
$flagging = reset($flaggings);
if (empty($flagging)) {
$flagging = Flagging::create($properties);
if ($flagging) {
$flagging
->save();
$message = t('You have successfully enrolled to this event. Also you are now following the event, which means you will receive notifications when a new comment is placed.');
drupal_set_message($message);
}
}
}
}