You are here

class ContentTranslationDefaultsConfigOverride in Open Social 10.3.x

Same name in this branch
  1. 10.3.x modules/social_features/social_featured_content/src/ContentTranslationDefaultsConfigOverride.php \Drupal\social_featured_content\ContentTranslationDefaultsConfigOverride
  2. 10.3.x modules/social_features/social_content_block/src/ContentTranslationDefaultsConfigOverride.php \Drupal\social_content_block\ContentTranslationDefaultsConfigOverride
  3. 10.3.x modules/social_features/social_landing_page/src/ContentTranslationDefaultsConfigOverride.php \Drupal\social_landing_page\ContentTranslationDefaultsConfigOverride
  4. 10.3.x modules/social_features/social_page/src/ContentTranslationDefaultsConfigOverride.php \Drupal\social_page\ContentTranslationDefaultsConfigOverride
  5. 10.3.x modules/social_features/social_book/src/ContentTranslationDefaultsConfigOverride.php \Drupal\social_book\ContentTranslationDefaultsConfigOverride
  6. 10.3.x modules/social_features/social_topic/src/ContentTranslationDefaultsConfigOverride.php \Drupal\social_topic\ContentTranslationDefaultsConfigOverride
  7. 10.3.x modules/social_features/social_event/src/ContentTranslationDefaultsConfigOverride.php \Drupal\social_event\ContentTranslationDefaultsConfigOverride
  8. 10.3.x modules/social_features/social_featured_items/src/ContentTranslationDefaultsConfigOverride.php \Drupal\social_featured_items\ContentTranslationDefaultsConfigOverride
  9. 10.3.x modules/social_features/social_core/src/ContentTranslationDefaultsConfigOverride.php \Drupal\social_core\ContentTranslationDefaultsConfigOverride
  10. 10.3.x modules/social_features/social_follow_taxonomy/modules/social_follow_landing_page/src/ContentTranslationDefaultsConfigOverride.php \Drupal\social_follow_landing_page\ContentTranslationDefaultsConfigOverride
  11. 10.3.x modules/social_features/social_group/modules/social_group_flexible_group/src/ContentTranslationDefaultsConfigOverride.php \Drupal\social_group_flexible_group\ContentTranslationDefaultsConfigOverride

Provides content translation for the Social Core module.

@package Drupal\social_core

Hierarchy

Expanded class hierarchy of ContentTranslationDefaultsConfigOverride

1 string reference to 'ContentTranslationDefaultsConfigOverride'
social_core.services.yml in modules/social_features/social_core/social_core.services.yml
modules/social_features/social_core/social_core.services.yml
1 service uses ContentTranslationDefaultsConfigOverride
social_core.translation_defaults in modules/social_features/social_core/social_core.services.yml
Drupal\social_core\ContentTranslationDefaultsConfigOverride

File

modules/social_features/social_core/src/ContentTranslationDefaultsConfigOverride.php, line 15

Namespace

Drupal\social_core
View source
class ContentTranslationDefaultsConfigOverride implements ConfigFactoryOverrideInterface {

  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * Constructs the service with DI.
   *
   * @param \Drupal\Core\Extension\ModuleHandler $module_handler
   *   The module handler.
   */
  public function __construct(ModuleHandler $module_handler) {
    $this->moduleHandler = $module_handler;
  }

  /**
   * {@inheritdoc}
   */
  public function loadOverrides($names) {
    $overrides = [];

    // If the module "social_content_translation" is enabled let make translations
    // enabled for content provided by the module by default.
    $is_content_translations_enabled = $this->moduleHandler
      ->moduleExists('social_content_translation');
    if (!$is_content_translations_enabled) {
      return $overrides;
    }

    // Translations for "Basic block" custom block.
    $config_name = 'language.content_settings.block_content.basic';
    if (in_array($config_name, $names)) {
      $overrides[$config_name] = [
        'third_party_settings' => [
          'content_translation' => [
            'enabled' => TRUE,
          ],
        ],
      ];
    }
    $config_name = 'core.base_field_override.block_content.basic.info';
    if (in_array($config_name, $names)) {
      $overrides[$config_name] = [
        'translatable' => TRUE,
      ];
    }

    // Translations for "Hero call to action block" custom block.
    $config_name = 'language.content_settings.block_content.hero_call_to_action_block';
    if (in_array($config_name, $names)) {
      $overrides[$config_name] = [
        'third_party_settings' => [
          'content_translation' => [
            'enabled' => TRUE,
          ],
        ],
      ];
    }
    $config_name = 'core.base_field_override.block_content.hero_call_to_action_block.info';
    if (in_array($config_name, $names)) {
      $overrides[$config_name] = [
        'translatable' => TRUE,
      ];
    }
    $config_name = 'field.field.block_content.hero_call_to_action_block.field_hero_image';
    if (in_array($config_name, $names)) {
      $overrides[$config_name] = [
        'third_party_settings' => [
          'content_translation' => [
            'translation_sync' => [
              'file' => 'file',
              'alt' => '0',
              'title' => '0',
            ],
          ],
        ],
      ];
    }

    // Translations for "Platform introduction" custom block.
    $config_name = 'language.content_settings.block_content.platform_intro';
    if (in_array($config_name, $names)) {
      $overrides[$config_name] = [
        'third_party_settings' => [
          'content_translation' => [
            'enabled' => TRUE,
          ],
        ],
      ];
    }
    $config_name = 'core.base_field_override.block_content.platform_intro.info';
    if (in_array($config_name, $names)) {
      $overrides[$config_name] = [
        'translatable' => TRUE,
      ];
    }
    return $overrides;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheSuffix() {
    return 'social_core.content_translation_defaults_config_override';
  }

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

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

    // The interface says we should return an object here, but we don't care and
    // this does not seem to break anything?
    // @phpstan-ignore-next-line
    return NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentTranslationDefaultsConfigOverride::$moduleHandler protected property The module handler.
ContentTranslationDefaultsConfigOverride::createConfigObject public function Creates a configuration object for use during install and synchronization. Overrides ConfigFactoryOverrideInterface::createConfigObject
ContentTranslationDefaultsConfigOverride::getCacheableMetadata public function Gets the cacheability metadata associated with the config factory override. Overrides ConfigFactoryOverrideInterface::getCacheableMetadata
ContentTranslationDefaultsConfigOverride::getCacheSuffix public function The string to append to the configuration static cache name. Overrides ConfigFactoryOverrideInterface::getCacheSuffix
ContentTranslationDefaultsConfigOverride::loadOverrides public function Returns config overrides. Overrides ConfigFactoryOverrideInterface::loadOverrides
ContentTranslationDefaultsConfigOverride::__construct public function Constructs the service with DI.