You are here

public function AcquiaContentHubSettingsCommands::getContentHubSettings in Acquia Content Hub 8.2

Get Content Hub settings.

@command acquia:contenthub-settings @aliases ach-chs,acquia-contenthub-settings

File

src/Commands/AcquiaContentHubSettingsCommands.php, line 77

Class

AcquiaContentHubSettingsCommands
Drush commands for getting the Settings used for Acquia Content Hub.

Namespace

Drupal\acquia_contenthub\Commands

Code

public function getContentHubSettings() : void {
  $this->output
    ->writeln('Content Hub Credentials:');
  $in_use_provider = $this->clientFactory
    ->getProvider();
  $config_settings = $this
    ->getSettingsFromCoreConfig();
  $core_settings = $this
    ->getSettingsFromCoreSettings();
  $env_var_settings = $this
    ->getSettingsFromEnvVar();
  $content = [];
  foreach ([
    $config_settings,
    $core_settings,
    $env_var_settings,
  ] as $setting_obj) {
    $settings = $setting_obj['settings'];
    $provider = $setting_obj['provider'];
    if ($settings instanceof Settings && !empty($provider)) {
      $content[] = [
        $settings
          ->getUrl() ?? '',
        $settings
          ->getName() ?? '',
        $settings
          ->getApiKey() ?? '',
        $settings
          ->getSecretKey() ?? '',
        $settings
          ->getUuid() ?? '',
        $settings
          ->getSharedSecret() ?? '',
        $provider ?? '',
        $in_use_provider === $provider ? 'Yes' : 'No',
      ];
    }
  }
  (new Table($this->output))
    ->setHeaders([
    'Hostname',
    'Name',
    'API Key',
    'Secret Key',
    'Origin UUID',
    'Shared Secret',
    'Settings Provider',
    'In Use',
  ])
    ->setRows($content)
    ->render();
}