You are here

class OverwriteContentHubAdminSettings in Acquia Content Hub 8.2

Overrides acquia_contenthub.admin_settings.

Use ::overwrite static method inside a test case to overwrite the Settings.

@package Drupal\acquia_contenthub_s3_test\EventSubscriber\GetSettings

Hierarchy

  • class \Drupal\acquia_contenthub_s3_test\EventSubscriber\GetSettings\OverwriteContentHubAdminSettings implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of OverwriteContentHubAdminSettings

1 file declares its use of OverwriteContentHubAdminSettings
S3FileOriginLocatorTest.php in modules/acquia_contenthub_s3/tests/src/Kernel/S3FileOriginLocatorTest.php
1 string reference to 'OverwriteContentHubAdminSettings'
acquia_contenthub_s3_test.services.yml in modules/acquia_contenthub_s3/tests/modules/acquia_contenthub_s3_test/acquia_contenthub_s3_test.services.yml
modules/acquia_contenthub_s3/tests/modules/acquia_contenthub_s3_test/acquia_contenthub_s3_test.services.yml
1 service uses OverwriteContentHubAdminSettings
acquia_contenthub_s3_test.ch_settings_override in modules/acquia_contenthub_s3/tests/modules/acquia_contenthub_s3_test/acquia_contenthub_s3_test.services.yml
Drupal\acquia_contenthub_s3_test\EventSubscriber\GetSettings\OverwriteContentHubAdminSettings

File

modules/acquia_contenthub_s3/tests/modules/acquia_contenthub_s3_test/src/EventSubscriber/GetSettings/OverwriteContentHubAdminSettings.php, line 17

Namespace

Drupal\acquia_contenthub_s3_test\EventSubscriber\GetSettings
View source
class OverwriteContentHubAdminSettings implements EventSubscriberInterface {

  /**
   * Settings object containing Content Hub Client configuration.
   *
   * @var \Acquia\ContentHubClient\Settings
   */
  protected static $chSettings;

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      AcquiaContentHubEvents::GET_SETTINGS => [
        'onGetSettings',
        100000,
      ],
    ];
  }

  /**
   * Implicitly overwrites acquia_contenthub.admin_settings.
   *
   * @param \Drupal\acquia_contenthub\Event\AcquiaContentHubSettingsEvent $event
   *   The settings altering event.
   */
  public function onGetSettings(AcquiaContentHubSettingsEvent $event) {
    $event
      ->setSettings($this
      ->getSettings());
    $event
      ->stopPropagation();
  }

  /**
   * Returns the Settings object.
   *
   * @return \Acquia\ContentHubClient\Settings
   *   The Content Hub settings.
   */
  public function getSettings() {
    return static::$chSettings ?? new Settings(...array_fill(0, 5, NULL));
  }

  /**
   * Overwrite Content Hub Settings completely.
   *
   * @param \Acquia\ContentHubClient\Settings $settings
   *   The Settings to overwrite with.
   */
  public static function overwrite(Settings $settings) {
    static::$chSettings = $settings;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
OverwriteContentHubAdminSettings::$chSettings protected static property Settings object containing Content Hub Client configuration.
OverwriteContentHubAdminSettings::getSettings public function Returns the Settings object.
OverwriteContentHubAdminSettings::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
OverwriteContentHubAdminSettings::onGetSettings public function Implicitly overwrites acquia_contenthub.admin_settings.
OverwriteContentHubAdminSettings::overwrite public static function Overwrite Content Hub Settings completely.