You are here

class SocialProfileManagerNotesConfigOverride in Open Social 8.9

Same name and namespace in other branches
  1. 8.8 modules/social_features/social_profile/modules/social_profile_manager_notes/src/SocialProfileManagerNotesConfigOverride.php \Drupal\social_profile_manager_notes\SocialProfileManagerNotesConfigOverride
  2. 10.3.x modules/social_features/social_profile/modules/social_profile_manager_notes/src/SocialProfileManagerNotesConfigOverride.php \Drupal\social_profile_manager_notes\SocialProfileManagerNotesConfigOverride
  3. 10.0.x modules/social_features/social_profile/modules/social_profile_manager_notes/src/SocialProfileManagerNotesConfigOverride.php \Drupal\social_profile_manager_notes\SocialProfileManagerNotesConfigOverride
  4. 10.1.x modules/social_features/social_profile/modules/social_profile_manager_notes/src/SocialProfileManagerNotesConfigOverride.php \Drupal\social_profile_manager_notes\SocialProfileManagerNotesConfigOverride
  5. 10.2.x modules/social_features/social_profile/modules/social_profile_manager_notes/src/SocialProfileManagerNotesConfigOverride.php \Drupal\social_profile_manager_notes\SocialProfileManagerNotesConfigOverride

Class SocialProfileManagerNotesConfigOverride.

Example configuration override.

@package Drupal\social_profile_manager_notes

Hierarchy

Expanded class hierarchy of SocialProfileManagerNotesConfigOverride

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

File

modules/social_features/social_profile/modules/social_profile_manager_notes/src/SocialProfileManagerNotesConfigOverride.php, line 17

Namespace

Drupal\social_profile_manager_notes
View source
class SocialProfileManagerNotesConfigOverride implements ConfigFactoryOverrideInterface {

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

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

  /**
   * Returns config overrides.
   */
  public function loadOverrides($names) {
    $overrides = [];
    $config_names = [
      'core.entity_form_display.profile.profile.default',
      'core.entity_view_display.profile.profile.default',
    ];
    foreach ($config_names as $config_name) {
      if (in_array($config_name, $names)) {

        // Grab current configuration and push the new values.
        $config = $this->configFactory
          ->getEditable($config_name);

        // We have to add config dependencies to field storage.
        $dependencies = $config
          ->getOriginal('dependencies', FALSE)['config'];
        $dependencies[] = 'field.field.profile.profile.field_manager_notes';
        $overrides[$config_name]['dependencies']['config'] = $dependencies;

        // Add the manager note field to the profile.
        $overrides[$config_name]['content']['field_manager_notes'] = [
          'weight' => 6,
          'settings' => [
            'view_mode' => 'default',
            'placeholder' => '',
          ],
          'third_party_settings' => [],
          'type' => 'comment_default',
          'region' => 'content',
          'label' => 'visually_hidden',
        ];
      }
    }
    return $overrides;
  }

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

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