You are here

public function SocialPostPhotoConfigOverride::loadOverrides in Open Social 8.3

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()
  2. 8 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()
  3. 8.2 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()
  4. 8.4 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()
  5. 8.5 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()
  6. 8.6 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()
  7. 8.7 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()
  8. 8.8 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()
  9. 10.3.x modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()
  10. 10.0.x modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()
  11. 10.1.x modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()
  12. 10.2.x modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride::loadOverrides()

Returns config overrides.

@codingStandardsIgnoreStart

Parameters

array $names: A list of configuration names that are being loaded.

Return value

array An array keyed by configuration name of override data. Override data contains a nested array structure of overrides.

Overrides ConfigFactoryOverrideInterface::loadOverrides

File

modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php, line 25

Class

SocialPostPhotoConfigOverride
Example configuration override.

Namespace

Drupal\social_post_photo

Code

public function loadOverrides($names) {

  // @codingStandardsIgnoreEnd
  $overrides = [];
  $config_factory = \Drupal::service('config.factory');

  // Temporary override to allow only 1 photo.
  $config_name = 'field.storage.post.field_post_image';
  if (in_array($config_name, $names)) {
    $overrides[$config_name] = [
      'cardinality' => 1,
    ];
  }

  // Override postblocks on activity streams.
  $config_names = [
    'block.block.postblock' => 'post_photo_block',
    'block.block.postongroupblock' => 'post_photo_group_block',
    'block.block.postonprofileblock' => 'post_photo_profile_block',
  ];
  foreach ($config_names as $config_name => $plugin) {
    if (in_array($config_name, $names)) {
      $overrides[$config_name] = [
        'plugin' => $plugin,
      ];
    }
  }

  // Override message templates.
  $config_names = [
    'message.template.create_post_community',
    'message.template.create_post_group',
    'message.template.create_post_profile',
    'message.template.create_post_profile_stream',
  ];
  foreach ($config_names as $config_name) {
    if (in_array($config_name, $names)) {
      $config = $config_factory
        ->getEditable($config_name);
      $entities = $config
        ->get('third_party_settings.activity_logger.activity_bundle_entities');

      // Only override if the configuration for posts exist.
      if ($entities['post-post'] == 'post-post') {
        $entities['post-photo'] = 'post-photo';
        $overrides[$config_name] = [
          'third_party_settings' => [
            'activity_logger' => [
              'activity_bundle_entities' => $entities,
            ],
          ],
        ];
      }
    }
  }

  // Override like and dislike settings.
  $config_name = 'like_and_dislike.settings';
  if (in_array($config_name, $names)) {
    $config = $config_factory
      ->getEditable($config_name);

    // Get enabled post bundles.
    $post_types = $config
      ->get('enabled_types.post');
    $post_types['photo'] = 'photo';
    $overrides[$config_name] = [
      'enabled_types' => [
        'post' => $post_types,
      ],
    ];
  }
  return $overrides;
}