You are here

public function SettingsFactory::getSettings in Lockr 4.x

Same name and namespace in other branches
  1. 8.4 src/SettingsFactory.php \Drupal\Lockr\SettingsFactory::getSettings()
  2. 8.3 src/SettingsFactory.php \Drupal\Lockr\SettingsFactory::getSettings()

Creates a new Lockr settings object from Drupal settings.

Return value

\Lockr\SettingsInterface The created Lockr settings object.

File

src/SettingsFactory.php, line 63

Class

SettingsFactory
Creates settings objects for lockr clients.

Namespace

Drupal\lockr

Code

public function getSettings() {
  $config = $this->configFactory
    ->get('lockr.settings');
  if ($config
    ->get('custom')) {
    $cert_path = $this->fileSystem
      ->realpath($config
      ->get('cert_path'));
  }
  else {
    $partner = $this
      ->getPartner();
    $cert_path = isset($partner['cert']) ? $partner['cert'] : NULL;
  }
  switch ($config
    ->get('region')) {
    case 'us':
      $host = 'us.api.lockr.io';
      break;
    case 'eu':
      $host = 'eu.api.lockr.io';
      break;
    default:
      $host = 'api.lockr.io';
      break;
  }
  $client_config = $this->settings
    ->get('lockr_http_client_config');
  if (is_array($client_config)) {
    $opts = $client_config;
  }
  else {
    $opts = [];
  }
  return new LockrSettings($cert_path, $host, null, $opts);
}