You are here

function social_activity_update_8803 in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_activity/social_activity.install \social_activity_update_8803()
  2. 10.3.x modules/social_features/social_activity/social_activity.install \social_activity_update_8803()
  3. 10.0.x modules/social_features/social_activity/social_activity.install \social_activity_update_8803()
  4. 10.1.x modules/social_features/social_activity/social_activity.install \social_activity_update_8803()
  5. 10.2.x modules/social_features/social_activity/social_activity.install \social_activity_update_8803()

Create "Featured" view mode/display for post.

@todo: should be moved into social_post module.

File

modules/social_features/social_activity/social_activity.install, line 206
The Social activity install.

Code

function social_activity_update_8803() {

  // Create a new post featured entity view mode.
  EntityViewMode::create([
    'targetEntityType' => 'post',
    'id' => 'post.featured',
    'status' => TRUE,
    'label' => t('Featured'),
  ])
    ->save();

  // Create view display for post bundle of Post entity.
  $display = EntityViewDisplay::load('post.post.default')
    ->toArray();
  unset($display['content']['field_post_comments'], $display['hidden']['like_and_dislike']);
  $display['content']['like_and_dislike'] = [
    'weight' => 3,
    'region' => 'content',
  ];
  $display = array_merge($display, [
    'uuid' => NULL,
    '_core' => NULL,
    'targetEntityType' => 'post',
    'mode' => 'featured',
  ]);
  EntityViewDisplay::create($display)
    ->save();

  // Create view display for photo bundle of Post entity.
  $display = EntityViewDisplay::load('post.photo.default')
    ->toArray();
  $display = array_merge($display, [
    'uuid' => NULL,
    '_core' => NULL,
    'targetEntityType' => 'post',
    'mode' => 'featured',
  ]);
  EntityViewDisplay::create($display)
    ->save();
}