You are here

public function SocialCommentUploadConfigOverride::loadOverrides in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()
  2. 8.2 modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()
  3. 8.3 modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()
  4. 8.4 modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()
  5. 8.5 modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()
  6. 8.6 modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()
  7. 8.7 modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()
  8. 8.8 modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()
  9. 10.3.x modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()
  10. 10.0.x modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()
  11. 10.1.x modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()
  12. 10.2.x modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php \Drupal\social_comment_upload\SocialCommentUploadConfigOverride::loadOverrides()

Returns config overrides.

Overrides ConfigFactoryOverrideInterface::loadOverrides

File

modules/social_features/social_comment_upload/src/SocialCommentUploadConfigOverride.php, line 21

Class

SocialCommentUploadConfigOverride
Class SocialCommentUploadConfigOverride.

Namespace

Drupal\social_comment_upload

Code

public function loadOverrides($names) {
  $overrides = [];
  $config_factory = \Drupal::service('config.factory');

  // Check the settings first and leave.
  if ($config_factory
    ->getEditable('social_comment_upload.settings')
    ->get('allow_upload_comments') == FALSE) {
    return $overrides;
  }

  // Add field_group and field_comment_files.
  $config_name = 'core.entity_form_display.comment.comment.default';
  if (in_array($config_name, $names)) {
    $config = $config_factory
      ->getEditable($config_name);
    $third_party = $config
      ->get('third_party_settings');
    $third_party = [
      'field_group' => [
        'group_add_attachment' => [
          'children' => [
            'field_comment_files',
          ],
          'parent_name' => '',
          'weight' => 20,
          'format_type' => 'details',
          'format_settings' => [
            'label' => 'Add attachment',
            'required_fields' => TRUE,
            'id' => '',
            'classes' => 'comment-attachments',
            'open' => FALSE,
          ],
          'label' => 'Add attachment',
        ],
      ],
    ];
    $content = $config
      ->get('content');
    $content['field_comment_files'] = [
      'weight' => 1,
      'settings' => [
        'progress_indicator' => 'throbber',
      ],
      'third_party_settings' => [],
      'type' => 'file_generic',
      'region' => 'content',
    ];
    $overrides[$config_name]['third_party_settings'] = $third_party;
    $overrides[$config_name]['content'] = $content;
  }

  // Add field_comment_files.
  $config_name = 'core.entity_view_display.comment.comment.default';
  if (in_array($config_name, $names)) {
    $config = $config_factory
      ->getEditable($config_name);
    $content = $config
      ->get('content');
    $content['field_comment_files'] = [
      'weight' => 1,
      'label' => 'hidden',
      'settings' => [],
      'third_party_settings' => [],
      'type' => 'file_default',
      'region' => 'content',
    ];
    $overrides[$config_name] = [
      'content' => $content,
    ];
  }
  return $overrides;
}