You are here

class LingotekFakeConfigWrapper in Lingotek Translation 3.8.x

Same name and namespace in other branches
  1. 3.3.x tests/modules/lingotek_test/src/LingotekFakeConfigWrapper.php \Drupal\lingotek_test\LingotekFakeConfigWrapper
  2. 3.4.x tests/modules/lingotek_test/src/LingotekFakeConfigWrapper.php \Drupal\lingotek_test\LingotekFakeConfigWrapper
  3. 3.5.x tests/modules/lingotek_test/src/LingotekFakeConfigWrapper.php \Drupal\lingotek_test\LingotekFakeConfigWrapper
  4. 3.6.x tests/modules/lingotek_test/src/LingotekFakeConfigWrapper.php \Drupal\lingotek_test\LingotekFakeConfigWrapper
  5. 3.7.x tests/modules/lingotek_test/src/LingotekFakeConfigWrapper.php \Drupal\lingotek_test\LingotekFakeConfigWrapper

Hierarchy

Expanded class hierarchy of LingotekFakeConfigWrapper

File

tests/modules/lingotek_test/src/LingotekFakeConfigWrapper.php, line 11

Namespace

Drupal\lingotek_test
View source
class LingotekFakeConfigWrapper extends Config {
  public $config;
  public function __construct($name, StorageInterface $storage, EventDispatcherInterface $event_dispatcher, TypedConfigManagerInterface $typed_config, Config $config) {
    parent::__construct($name, $storage, $event_dispatcher, $typed_config);
    $this->config = $config;
  }
  public function get($key = '') {
    switch ($key) {
      case 'account':
        if (\Drupal::state()
          ->get('lingotek_fake.logged_in', FALSE) === FALSE || \Drupal::state()
          ->get('lingotek_fake.setup_completed', FALSE) === FALSE) {
          return [];
        }
        else {
          $host = \Drupal::request()
            ->getSchemeAndHttpHost();
          return [
            'host' => $host,
            'authorize_path' => $this
              ->get('account.authorize_path'),
            'default_client_id' => $this
              ->get('account.default_client_id'),
            'access_token' => $this
              ->get('account.access_token'),
            'login_id' => $this
              ->get('account.login_id'),
            'use_production' => TRUE,
          ];
        }
      case 'account.login_id':
        if (\Drupal::state()
          ->get('must_remain_disconnected', FALSE)) {
          return $this->config
            ->get($key);
        }
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : 'testUser@example.com';
      case 'account.access_token':
        if (\Drupal::state()
          ->get('must_remain_disconnected', FALSE)) {
          return $this->config
            ->get($key);
        }
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : 'test_token';
      case 'account.sandbox_host':
      case 'account.host':
        return \Drupal::request()
          ->getSchemeAndHttpHost() . \Drupal::request()
          ->getBasePath();
      case 'account.authorize_path':
        if (\Drupal::state()
          ->get('authorize_no_redirect', FALSE)) {
          return '/lingofake/authorize_no_redirect';
        }
        return '/lingofake/authorize';
      case 'account.default_client_id':
        return 'test_default_client_id';
      case 'default':
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : [
          'project' => 'test_project',
          'vault' => 'test_vault',
          'filter' => 'drupal_default',
          'subfilter' => 'drupal_default',
          'community' => 'test_community',
          'workflow' => 'machine_translation',
        ];
      case 'default.community':
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : 'test_community';
      case 'default.project':
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : 'test_project';
      case 'default.vault':
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : 'test_vault';
      case 'default.filter':
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : 'drupal_default';
      case 'default.subfilter':
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : 'drupal_default';
      case 'default.workflow':
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : 'machine_translation';
      case 'account.resources.project':
        if (!$this->config
          ->get($key)) {
          $projects = [
            'test_project' => 'Test project',
            'test_project2' => 'Test project 2',
          ];
          $this
            ->set($key, $projects)
            ->save();
        }
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : [];
      case 'account.resources.workflow':
        if (!$this->config
          ->get($key)) {
          $workflows = [
            'machine_translation' => 'Machine Translation',
            'test_workflow' => 'Test workflow',
            'test_workflow2' => 'Test workflow 2',
          ];
          $this
            ->set($key, $workflows)
            ->save();
        }
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : [];
      case 'account.resources.community':
        if (!$this->config
          ->get($key)) {
          $communities = [
            'test_community' => 'Test community',
            'test_community2' => 'Test community 2',
          ];
          if (!$this->config instanceof ImmutableConfig) {
            $this
              ->set($key, $communities)
              ->save();
          }
        }
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : [];
      case 'account.resources.vault':
        if (!$this->config
          ->get($key)) {
          $vaults = [
            'test_vault' => 'Test vault',
            'test_vault2' => 'Test vault 2',
          ];
          $this
            ->set($key, $vaults)
            ->save();
        }
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : [];
      case 'account.resources.filter':
        if (!$this->config
          ->get($key)) {
          $default_filters = [
            'test_filter' => 'Test filter',
            'test_filter2' => 'Test filter 2',
            'test_filter3' => 'Test filter 3',
          ];
          $filters = [];
          if (!\Drupal::state()
            ->get('lingotek.no_filters', FALSE)) {
            $filters = $default_filters;
          }
          $this
            ->set($key, $filters)
            ->save();
        }
        return $this->config
          ->get($key) ? $this->config
          ->get($key) : [];
      default:
        return $this->config
          ->get($key);
    }
  }
  public function set($key, $value) {
    if (!$this->config instanceof ImmutableConfig) {
      parent::set($key, $value);
      $this->config
        ->set($key, $value);
    }
    return $this;
  }
  public function save($has_trusted_data = FALSE) {
    if (!$this->config instanceof ImmutableConfig) {
      parent::save($has_trusted_data);
      $this->config
        ->save($has_trusted_data);
    }
    return $this;
  }
  public function getRawData() {
    return $this->config
      ->getRawData();
  }
  public function clear($key) {
    if (!$this->config instanceof ImmutableConfig) {
      parent::clear($key);
      $this->config
        ->clear($key);
    }
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
Config::$eventDispatcher protected property An event dispatcher instance to use for configuration events.
Config::$moduleOverrides protected property The current module overrides.
Config::$overriddenData protected property The current runtime data.
Config::$settingsOverrides protected property The current settings overrides.
Config::delete public function Deletes the configuration object. Overrides StorableConfigBase::delete 1
Config::getOriginal public function Gets original data from this configuration object.
Config::hasOverrides public function Determines if overrides are applied to a key for this configuration object.
Config::initWithData public function Initializes a configuration object with pre-loaded data. Overrides StorableConfigBase::initWithData
Config::resetOverriddenData protected function Resets the current data, so overrides are re-applied.
Config::setData public function Replaces the data of this configuration object. Overrides ConfigBase::setData
Config::setModuleOverride public function Sets module overrides for this configuration object.
Config::setOverriddenData protected function Sets the current data for this configuration object.
Config::setSettingsOverride public function Sets settings.php overrides for this configuration object.
ConfigBase::$data protected property The data of the configuration object.
ConfigBase::$name protected property The name of the configuration object.
ConfigBase::castSafeStrings protected function Casts any objects that implement MarkupInterface to string.
ConfigBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
ConfigBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
ConfigBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags 1
ConfigBase::getName public function Returns the name of this configuration object.
ConfigBase::MAX_NAME_LENGTH constant The maximum length of a configuration object name.
ConfigBase::merge public function Merges data into a configuration object.
ConfigBase::setName public function Sets the name of this configuration object.
ConfigBase::validateKeys protected function Validates all keys in a passed in config array structure.
ConfigBase::validateName public static function Validates the configuration object name.
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
LingotekFakeConfigWrapper::$config public property
LingotekFakeConfigWrapper::clear public function Unsets a value in this configuration object. Overrides Config::clear
LingotekFakeConfigWrapper::get public function Gets data from this configuration object. Overrides Config::get
LingotekFakeConfigWrapper::getRawData public function Gets the raw data without overrides. Overrides Config::getRawData
LingotekFakeConfigWrapper::save public function Saves the configuration object. Overrides Config::save
LingotekFakeConfigWrapper::set public function Sets a value in this configuration object. Overrides Config::set
LingotekFakeConfigWrapper::__construct public function Constructs a configuration object. Overrides Config::__construct
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
StorableConfigBase::$isNew protected property Whether the configuration object is new or has been saved to the storage.
StorableConfigBase::$originalData protected property The data of the configuration object.
StorableConfigBase::$schemaWrapper protected property The config schema wrapper object for this configuration object.
StorableConfigBase::$storage protected property The storage used to load and save this configuration object.
StorableConfigBase::$typedConfigManager protected property The typed config manager.
StorableConfigBase::castValue protected function Casts the value to correct data type using the configuration schema.
StorableConfigBase::getSchemaWrapper protected function Gets the schema wrapper for the whole configuration object.
StorableConfigBase::getStorage public function Retrieves the storage used to load and save this configuration object.
StorableConfigBase::isNew public function Returns whether this configuration object is new.
StorableConfigBase::validateValue protected function Validate the values are allowed data types.