You are here

function social_activity_update_8802 in Open Social 10.2.x

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

Create "Featured" view mode/display for activity.

File

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

Code

function social_activity_update_8802() {

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

  // Create the corresponding entity view display for activity entity type.
  $display = EntityViewDisplay::load('activity.activity.default')
    ->toArray();
  $display['content']['field_activity_entity']['settings']['node'] = [
    'view_mode' => 'featured',
  ];
  $display = array_merge($display, [
    'uuid' => NULL,
    'targetEntityType' => 'activity',
    'bundle' => 'activity',
    'mode' => 'featured',
  ]);
  EntityViewDisplay::create($display)
    ->save();
}