You are here

class SocialPostPhotoConfigOverride in Open Social 8.7

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
  2. 8 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride
  3. 8.2 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride
  4. 8.3 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride
  5. 8.4 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride
  6. 8.5 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride
  7. 8.6 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride
  8. 8.8 modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride
  9. 10.3.x modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride
  10. 10.0.x modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride
  11. 10.1.x modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride
  12. 10.2.x modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php \Drupal\social_post_photo\SocialPostPhotoConfigOverride

Example configuration override.

Hierarchy

Expanded class hierarchy of SocialPostPhotoConfigOverride

2 string references to 'SocialPostPhotoConfigOverride'
SocialPostPhotoConfigOverride::getCacheSuffix in modules/social_features/social_post/modules/social_post_photo/src/SocialPostPhotoConfigOverride.php
The string to append to the configuration static cache name.
social_post_photo.services.yml in modules/social_features/social_post/modules/social_post_photo/social_post_photo.services.yml
modules/social_features/social_post/modules/social_post_photo/social_post_photo.services.yml
1 service uses SocialPostPhotoConfigOverride
social_post_photo.override in modules/social_features/social_post/modules/social_post_photo/social_post_photo.services.yml
\Drupal\social_post_photo\SocialPostPhotoConfigOverride

File

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

Namespace

Drupal\social_post_photo
View source
class SocialPostPhotoConfigOverride implements ConfigFactoryOverrideInterface {

  /**
   * Returns config overrides.
   *
   * @param array $names
   *   A list of configuration names that are being loaded.
   *
   * @return array
   *   An array keyed by configuration name of override data. Override data
   *   contains a nested array structure of overrides.
   * @codingStandardsIgnoreStart
   */
  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;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheSuffix() {
    return 'SocialPostPhotoConfigOverride';
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata($name) {
    return new CacheableMetadata();
  }

  /**
   * {@inheritdoc}
   */
  public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
    return NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SocialPostPhotoConfigOverride::createConfigObject public function Creates a configuration object for use during install and synchronization. Overrides ConfigFactoryOverrideInterface::createConfigObject
SocialPostPhotoConfigOverride::getCacheableMetadata public function Gets the cacheability metadata associated with the config factory override. Overrides ConfigFactoryOverrideInterface::getCacheableMetadata
SocialPostPhotoConfigOverride::getCacheSuffix public function The string to append to the configuration static cache name. Overrides ConfigFactoryOverrideInterface::getCacheSuffix
SocialPostPhotoConfigOverride::loadOverrides public function Returns config overrides. Overrides ConfigFactoryOverrideInterface::loadOverrides