You are here

class EventMaxEnrollOverride in Open Social 10.2.x

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

Class EventMaxEnrollOverride.

Override event form.

@package Drupal\social_event_max_enroll

Hierarchy

Expanded class hierarchy of EventMaxEnrollOverride

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

File

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

Namespace

Drupal\social_event_max_enroll
View source
class EventMaxEnrollOverride implements ConfigFactoryOverrideInterface {

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

  /**
   * The Social Event AN Enroll config overrider.
   *
   * @var \Drupal\social_event_an_enroll\EventAnEnrollOverride|null
   */
  protected $socialEventAnEnrollOverrider;

  /**
   * Constructs the configuration override.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The Drupal configuration factory.
   * @param \Drupal\social_event_an_enroll\EventAnEnrollOverride|null $social_event_an_enroll_overrider
   *   The Social Event AN Enroll config overrider.
   */
  public function __construct(ConfigFactoryInterface $config_factory, EventAnEnrollOverride $social_event_an_enroll_overrider = NULL) {
    $this->configFactory = $config_factory;
    $this->socialEventAnEnrollOverrider = $social_event_an_enroll_overrider;
  }

  /**
   * Returns config overrides.
   */
  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_methods']['children'];
        $content = $parent_overrides[$config_name]['content'];
      }
      else {
        $config = $this->configFactory
          ->getEditable($config_name);
        $children = $config
          ->get('third_party_settings.field_group.group_enrollment_methods.children');
        $content = $config
          ->get('content');
      }

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

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

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