OverwriteContentHubAdminSettings.php in Acquia Content Hub 8.2
File
modules/acquia_contenthub_s3/tests/modules/acquia_contenthub_s3_test/src/EventSubscriber/GetSettings/OverwriteContentHubAdminSettings.php
View source
<?php
namespace Drupal\acquia_contenthub_s3_test\EventSubscriber\GetSettings;
use Acquia\ContentHubClient\Settings;
use Drupal\acquia_contenthub\AcquiaContentHubEvents;
use Drupal\acquia_contenthub\Event\AcquiaContentHubSettingsEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class OverwriteContentHubAdminSettings implements EventSubscriberInterface {
protected static $chSettings;
public static function getSubscribedEvents() {
return [
AcquiaContentHubEvents::GET_SETTINGS => [
'onGetSettings',
100000,
],
];
}
public function onGetSettings(AcquiaContentHubSettingsEvent $event) {
$event
->setSettings($this
->getSettings());
$event
->stopPropagation();
}
public function getSettings() {
return static::$chSettings ?? new Settings(...array_fill(0, 5, NULL));
}
public static function overwrite(Settings $settings) {
static::$chSettings = $settings;
}
}