You are here

class GetSettingsFromCoreConfig in Acquia Content Hub 8.2

Gets the ContentHub Server settings from configuration.

Hierarchy

  • class \Drupal\acquia_contenthub\EventSubscriber\GetSettings\GetSettingsFromCoreConfig implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of GetSettingsFromCoreConfig

1 file declares its use of GetSettingsFromCoreConfig
AcquiaContentHubSettingsCommands.php in src/Commands/AcquiaContentHubSettingsCommands.php
1 string reference to 'GetSettingsFromCoreConfig'
acquia_contenthub.services.yml in ./acquia_contenthub.services.yml
acquia_contenthub.services.yml
1 service uses GetSettingsFromCoreConfig
acquia_contenthub.settings.config in ./acquia_contenthub.services.yml
Drupal\acquia_contenthub\EventSubscriber\GetSettings\GetSettingsFromCoreConfig

File

src/EventSubscriber/GetSettings/GetSettingsFromCoreConfig.php, line 14

Namespace

Drupal\acquia_contenthub\EventSubscriber\GetSettings
View source
class GetSettingsFromCoreConfig implements EventSubscriberInterface {

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

  /**
   * GetSettingsFromCoreConfig constructor.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
   *   The configuration factory.
   */
  public function __construct(ConfigFactoryInterface $configFactory) {
    $this->configFactory = $configFactory;
  }

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

  /**
   * Extract settings from configuration and create a Settings object.
   *
   * @param \Drupal\acquia_contenthub\Event\AcquiaContentHubSettingsEvent $event
   *   The dispatched event.
   *
   * @see \Acquia\ContentHubClient\Settings
   */
  public function onGetSettings(AcquiaContentHubSettingsEvent $event) {
    $config = $this->configFactory
      ->get('acquia_contenthub.admin_settings');
    $settings = new Settings($config
      ->get('client_name'), $config
      ->get('origin'), $config
      ->get('api_key'), $config
      ->get('secret_key'), $config
      ->get('hostname'), $config
      ->get('shared_secret'), $config
      ->get('webhook') ?: []);
    if ($settings) {
      $event
        ->setSettings($settings);
      $event
        ->setProvider('core_config');
      $event
        ->stopPropagation();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GetSettingsFromCoreConfig::$configFactory protected property The Config Factory.
GetSettingsFromCoreConfig::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
GetSettingsFromCoreConfig::onGetSettings public function Extract settings from configuration and create a Settings object.
GetSettingsFromCoreConfig::__construct public function GetSettingsFromCoreConfig constructor.