class PreviewSettings in Acquia Content Hub 8.2
Gets the ContentHub Server settings from configuration.
Hierarchy
- class \Drupal\acquia_contenthub_preview\EventSubscriber\PreviewSettings implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of PreviewSettings
1 string reference to 'PreviewSettings'
- acquia_contenthub_preview.services.yml in modules/
acquia_contenthub_preview/ acquia_contenthub_preview.services.yml - modules/acquia_contenthub_preview/acquia_contenthub_preview.services.yml
1 service uses PreviewSettings
- acquia_contenthub_preview.settings.preview in modules/
acquia_contenthub_preview/ acquia_contenthub_preview.services.yml - Drupal\acquia_contenthub_preview\EventSubscriber\PreviewSettings
File
- modules/
acquia_contenthub_preview/ src/ EventSubscriber/ PreviewSettings.php, line 14
Namespace
Drupal\acquia_contenthub_preview\EventSubscriberView source
class PreviewSettings 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',
10001,
];
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');
$hostname = 'preview-only-do-not-register';
$settings = new Settings($config
->get('client_name'), $config
->get('origin'), $config
->get('api_key'), $config
->get('secret_key'), $hostname, $config
->get('shared_secret'), $config
->get('webhook') ?? []);
if ($settings) {
$event
->setSettings($settings);
$event
->setProvider('preview_site');
$event
->stopPropagation();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PreviewSettings:: |
protected | property | The Config Factory. | |
PreviewSettings:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
PreviewSettings:: |
public | function | Extract settings from configuration and create a Settings object. | |
PreviewSettings:: |
public | function | GetSettingsFromCoreConfig constructor. |