function _social_private_message_set_private_message_inbox_view_settings in Open Social 8.9
Same name and namespace in other branches
- 8.8 modules/social_features/social_private_message/social_private_message.install \_social_private_message_set_private_message_inbox_view_settings()
- 10.3.x modules/social_features/social_private_message/social_private_message.install \_social_private_message_set_private_message_inbox_view_settings()
- 10.0.x modules/social_features/social_private_message/social_private_message.install \_social_private_message_set_private_message_inbox_view_settings()
- 10.1.x modules/social_features/social_private_message/social_private_message.install \_social_private_message_set_private_message_inbox_view_settings()
- 10.2.x modules/social_features/social_private_message/social_private_message.install \_social_private_message_set_private_message_inbox_view_settings()
Set the Open Social specific settings for the private message inbox view.
1 call to _social_private_message_set_private_message_inbox_view_settings()
- social_private_message_install in modules/
social_features/ social_private_message/ social_private_message.install - Implements hook_uninstall().
File
- modules/
social_features/ social_private_message/ social_private_message.install, line 96 - The Social Private Message (de)installation file.
Code
function _social_private_message_set_private_message_inbox_view_settings() {
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $pm_view_display */
$pm_view_display = \Drupal::service('entity_type.manager')
->getStorage('entity_view_display')
->load('private_message.private_message.inbox');
$created_field = $pm_view_display
->getComponent('created');
$created_field['type'] = 'timestamp_ago';
$created_field['settings'] = [
'granularity' => 1,
'future_format' => '@interval hence',
'past_format' => '@interval ago',
];
$owner_field = $pm_view_display
->getComponent('owner');
$owner_field['type'] = 'entity_reference_label';
$owner_field['label'] = 'hidden';
$owner_field['settings'] = [
'link' => FALSE,
];
$pm_view_display
->setComponent('created', $created_field)
->setComponent('owner', $owner_field)
->save();
}