You are here

class SocialFilePrivateTextEditorConfigOverride in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride
  2. 8.2 modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride
  3. 8.3 modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride
  4. 8.4 modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride
  5. 8.5 modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride
  6. 8.6 modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride
  7. 8.7 modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride
  8. 8.8 modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride
  9. 10.3.x modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride
  10. 10.0.x modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride
  11. 10.1.x modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride
  12. 10.2.x modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php \Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride

Class SocialFilePrivateTextEditorConfigOverride.

Override the text editor configuration and set private scheme for files.

@package Drupal\social_file_private

Hierarchy

Expanded class hierarchy of SocialFilePrivateTextEditorConfigOverride

2 string references to 'SocialFilePrivateTextEditorConfigOverride'
SocialFilePrivateTextEditorConfigOverride::getCacheSuffix in modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php
The string to append to the configuration static cache name.
social_file_private.services.yml in modules/custom/social_file_private/social_file_private.services.yml
modules/custom/social_file_private/social_file_private.services.yml
1 service uses SocialFilePrivateTextEditorConfigOverride
social_file_private_text_editor.overrider in modules/custom/social_file_private/social_file_private.services.yml
\Drupal\social_file_private\SocialFilePrivateTextEditorConfigOverride

File

modules/custom/social_file_private/src/SocialFilePrivateTextEditorConfigOverride.php, line 17

Namespace

Drupal\social_file_private
View source
class SocialFilePrivateTextEditorConfigOverride implements ConfigFactoryOverrideInterface {

  /**
   * Get all the editors/input formats we need to protect.
   *
   * @TODO Retrieve the input formats programmatically.
   *
   * Note: this list is now fixed, but an error will be shown in the status
   * report when there are text editors using public scheme.
   *
   * @return array
   *   Returns an array containing config_names.
   */
  public function getTextEditorsToProtect() {
    $config_names = [
      'editor.editor.basic_html',
      'editor.editor.full_html',
    ];
    return $config_names;
  }

  /**
   * {@inheritdoc}
   */
  public function loadOverrides($names) {
    $overrides = [];
    if (PrivateStream::basePath()) {
      $config_names = $this
        ->getTextEditorsToProtect();
      foreach ($config_names as $config_name) {
        if (in_array($config_name, $names)) {
          $config = \Drupal::service('config.factory')
            ->getEditable($config_name);
          $scheme = $config
            ->get('image_upload.scheme');
          if ($scheme == 'public') {
            $overrides[$config_name]['image_upload']['scheme'] = 'private';
          }
        }
      }
    }
    return $overrides;
  }

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

  /**
   * {@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
SocialFilePrivateTextEditorConfigOverride::createConfigObject public function Creates a configuration object for use during install and synchronization. Overrides ConfigFactoryOverrideInterface::createConfigObject
SocialFilePrivateTextEditorConfigOverride::getCacheableMetadata public function Gets the cacheability metadata associated with the config factory override. Overrides ConfigFactoryOverrideInterface::getCacheableMetadata
SocialFilePrivateTextEditorConfigOverride::getCacheSuffix public function The string to append to the configuration static cache name. Overrides ConfigFactoryOverrideInterface::getCacheSuffix
SocialFilePrivateTextEditorConfigOverride::getTextEditorsToProtect public function Get all the editors/input formats we need to protect.
SocialFilePrivateTextEditorConfigOverride::loadOverrides public function Returns config overrides. Overrides ConfigFactoryOverrideInterface::loadOverrides