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
1 string reference to 'GetSettingsFromCoreConfig'
1 service uses GetSettingsFromCoreConfig
File
- src/
EventSubscriber/ GetSettings/ GetSettingsFromCoreConfig.php, line 14
Namespace
Drupal\acquia_contenthub\EventSubscriber\GetSettingsView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GetSettingsFromCoreConfig:: |
protected | property | The Config Factory. | |
GetSettingsFromCoreConfig:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
GetSettingsFromCoreConfig:: |
public | function | Extract settings from configuration and create a Settings object. | |
GetSettingsFromCoreConfig:: |
public | function | GetSettingsFromCoreConfig constructor. |