function social_follow_content_modules_installed in Open Social 10.3.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_modules_installed()
- 8.8 modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_modules_installed()
- 10.0.x modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_modules_installed()
- 10.1.x modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_modules_installed()
- 10.2.x modules/social_features/social_follow_content/social_follow_content.module \social_follow_content_modules_installed()
Implements hook_modules_installed().
File
- modules/
social_features/ social_follow_content/ social_follow_content.module, line 20 - The Social Follow Content module.
Code
function social_follow_content_modules_installed($modules) {
// Check if the topic, flag or this module is being installed in which case
// the follow content field needs to be hidden for topic small teaser view
// modes. All these modules are checked because the order is not guaranteed
// and it's not quite known when the `flag_follow_content` field is added.
if (!empty(array_intersect([
'social_topic',
'flag',
'social_follow_content',
], $modules))) {
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entityDisplayRepository */
$entityDisplayRepository = \Drupal::service('entity_display.repository');
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_mode */
$view_mode = $entityDisplayRepository
->getViewDisplay('node', 'topic', 'small_teaser');
// The getViewDisplay returns a new view mode entity if one didn't already
// exist but only existing view modes should be edited.
if ($view_mode
->isNew()) {
return;
}
// When a field gets moved to the hidden region its component just gets
// removed.
$view_mode
->removeComponent('flag_follow_content')
->save();
}
}