You are here

class SocialContentBlockOverride in Open Social 8.7

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_content_block/src/SocialContentBlockOverride.php \Drupal\social_content_block\SocialContentBlockOverride
  2. 8.6 modules/social_features/social_content_block/src/SocialContentBlockOverride.php \Drupal\social_content_block\SocialContentBlockOverride
  3. 8.8 modules/social_features/social_content_block/src/SocialContentBlockOverride.php \Drupal\social_content_block\SocialContentBlockOverride
  4. 10.3.x modules/social_features/social_content_block/src/SocialContentBlockOverride.php \Drupal\social_content_block\SocialContentBlockOverride
  5. 10.0.x modules/social_features/social_content_block/src/SocialContentBlockOverride.php \Drupal\social_content_block\SocialContentBlockOverride
  6. 10.1.x modules/social_features/social_content_block/src/SocialContentBlockOverride.php \Drupal\social_content_block\SocialContentBlockOverride
  7. 10.2.x modules/social_features/social_content_block/src/SocialContentBlockOverride.php \Drupal\social_content_block\SocialContentBlockOverride

Class SocialContentBlockOverride.

Override content block form.

@package Drupal\social_content_block

Hierarchy

Expanded class hierarchy of SocialContentBlockOverride

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

File

modules/social_features/social_content_block/src/SocialContentBlockOverride.php, line 18

Namespace

Drupal\social_content_block
View source
class SocialContentBlockOverride implements ConfigFactoryOverrideInterface {

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Constructs the configuration override.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The configuration factory.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * Load overrides.
   */
  public function loadOverrides($names) {
    $overrides = [];
    $config_name = 'field.field.paragraph.block.field_block_reference_secondary';
    if (in_array($config_name, $names)) {
      $config = $this->configFactory
        ->getEditable($config_name);
      $settings = $config
        ->getOriginal('settings', FALSE)['plugin_ids'];

      // Get all the blocks from this custom block type.
      $query = \Drupal::entityQuery('block_content')
        ->condition('type', 'custom_content_list');
      $ids = $query
        ->execute();
      foreach ($ids as $id) {
        $block = BlockContent::load($id);
        if ($block) {
          $plugin_ids[] = 'block_content:' . $block
            ->uuid();
        }
      }

      // Add the blocks to the landing page.
      if (isset($plugin_ids)) {
        foreach ($plugin_ids as $plugin_id) {
          $settings[$plugin_id] = $plugin_id;
        }
      }
      $overrides[$config_name]['settings']['plugin_ids'] = $settings;
    }
    return $overrides;
  }

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

  /**
   * {@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
SocialContentBlockOverride::$configFactory protected property The config factory.
SocialContentBlockOverride::createConfigObject public function Creates a configuration object for use during install and synchronization. Overrides ConfigFactoryOverrideInterface::createConfigObject
SocialContentBlockOverride::getCacheableMetadata public function Gets the cacheability metadata associated with the config factory override. Overrides ConfigFactoryOverrideInterface::getCacheableMetadata
SocialContentBlockOverride::getCacheSuffix public function The string to append to the configuration static cache name. Overrides ConfigFactoryOverrideInterface::getCacheSuffix
SocialContentBlockOverride::loadOverrides public function Load overrides. Overrides ConfigFactoryOverrideInterface::loadOverrides
SocialContentBlockOverride::__construct public function Constructs the configuration override.