You are here

public function EventMaxEnrollOverride::loadOverrides in Open Social 8.9

Same name and namespace in other branches
  1. 8.5 modules/social_features/social_event/modules/social_event_max_enroll/src/EventMaxEnrollOverride.php \Drupal\social_event_max_enroll\EventMaxEnrollOverride::loadOverrides()
  2. 8.6 modules/social_features/social_event/modules/social_event_max_enroll/src/EventMaxEnrollOverride.php \Drupal\social_event_max_enroll\EventMaxEnrollOverride::loadOverrides()
  3. 8.7 modules/social_features/social_event/modules/social_event_max_enroll/src/EventMaxEnrollOverride.php \Drupal\social_event_max_enroll\EventMaxEnrollOverride::loadOverrides()
  4. 8.8 modules/social_features/social_event/modules/social_event_max_enroll/src/EventMaxEnrollOverride.php \Drupal\social_event_max_enroll\EventMaxEnrollOverride::loadOverrides()
  5. 10.3.x modules/social_features/social_event/modules/social_event_max_enroll/src/EventMaxEnrollOverride.php \Drupal\social_event_max_enroll\EventMaxEnrollOverride::loadOverrides()
  6. 10.0.x modules/social_features/social_event/modules/social_event_max_enroll/src/EventMaxEnrollOverride.php \Drupal\social_event_max_enroll\EventMaxEnrollOverride::loadOverrides()
  7. 10.1.x modules/social_features/social_event/modules/social_event_max_enroll/src/EventMaxEnrollOverride.php \Drupal\social_event_max_enroll\EventMaxEnrollOverride::loadOverrides()
  8. 10.2.x modules/social_features/social_event/modules/social_event_max_enroll/src/EventMaxEnrollOverride.php \Drupal\social_event_max_enroll\EventMaxEnrollOverride::loadOverrides()

Returns config overrides.

Overrides ConfigFactoryOverrideInterface::loadOverrides

File

modules/social_features/social_event/modules/social_event_max_enroll/src/EventMaxEnrollOverride.php, line 53

Class

EventMaxEnrollOverride
Class EventMaxEnrollOverride.

Namespace

Drupal\social_event_max_enroll

Code

public function loadOverrides($names) {
  $overrides = [];

  // Add field_event_max_enroll to event form.
  $config_name = 'core.entity_form_display.node.event.default';
  if (in_array($config_name, $names)) {
    if ($this->socialEventAnEnrollOverrider instanceof ConfigFactoryOverrideInterface) {
      $parent_overrides = $this->socialEventAnEnrollOverrider
        ->loadOverrides([
        $config_name,
      ]);
      $children = $parent_overrides[$config_name]['third_party_settings']['field_group']['group_enrollment']['children'];
      $content = $parent_overrides[$config_name]['content'];
    }
    else {
      $config = $this->configFactory
        ->getEditable($config_name);
      $children = $config
        ->get('third_party_settings.field_group.group_enrollment.children');
      $content = $config
        ->get('content');
    }

    // Add a field group.
    $children[] = 'field_event_max_enroll';
    $children[] = 'field_event_max_enroll_num';

    // Add the field to the content.
    $content['field_event_max_enroll'] = [
      'weight' => 100,
      'settings' => [
        'placeholder' => '',
      ],
      'third_party_settings' => [],
      'type' => 'number',
      'region' => 'content',
    ];
    $content['field_event_max_enroll_num'] = [
      'weight' => 101,
      'settings' => [
        'display_label' => TRUE,
      ],
      'third_party_settings' => [],
      'type' => 'boolean_checkbox',
      'region' => 'content',
    ];
    $overrides[$config_name] = [
      'third_party_settings' => [
        'field_group' => [
          'group_enrollment' => [
            'children' => $children,
          ],
        ],
      ],
      'content' => $content,
    ];
  }
  return $overrides;
}