class LingotekFakeConfigWrapper in Lingotek Translation 3.5.x
Same name and namespace in other branches
- 3.3.x tests/modules/lingotek_test/src/LingotekFakeConfigWrapper.php \Drupal\lingotek_test\LingotekFakeConfigWrapper
- 3.4.x tests/modules/lingotek_test/src/LingotekFakeConfigWrapper.php \Drupal\lingotek_test\LingotekFakeConfigWrapper
- 3.6.x tests/modules/lingotek_test/src/LingotekFakeConfigWrapper.php \Drupal\lingotek_test\LingotekFakeConfigWrapper
- 3.7.x tests/modules/lingotek_test/src/LingotekFakeConfigWrapper.php \Drupal\lingotek_test\LingotekFakeConfigWrapper
- 3.8.x tests/modules/lingotek_test/src/LingotekFakeConfigWrapper.php \Drupal\lingotek_test\LingotekFakeConfigWrapper
Hierarchy
- class \Drupal\Core\Config\ConfigBase implements RefinableCacheableDependencyInterface uses RefinableCacheableDependencyTrait, DependencySerializationTrait
- class \Drupal\Core\Config\StorableConfigBase
- class \Drupal\Core\Config\Config
- class \Drupal\lingotek_test\LingotekFakeConfigWrapper
- class \Drupal\Core\Config\Config
- class \Drupal\Core\Config\StorableConfigBase
Expanded class hierarchy of LingotekFakeConfigWrapper
File
- tests/
modules/ lingotek_test/ src/ LingotekFakeConfigWrapper.php, line 11
Namespace
Drupal\lingotek_testView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
Config:: |
protected | property | An event dispatcher instance to use for configuration events. | |
Config:: |
protected | property | The current module overrides. | |
Config:: |
protected | property | The current runtime data. | |
Config:: |
protected | property | The current settings overrides. | |
Config:: |
public | function |
Deletes the configuration object. Overrides StorableConfigBase:: |
1 |
Config:: |
public | function | Gets original data from this configuration object. | |
Config:: |
public | function | Determines if overrides are applied to a key for this configuration object. | |
Config:: |
public | function |
Initializes a configuration object with pre-loaded data. Overrides StorableConfigBase:: |
|
Config:: |
protected | function | Resets the current data, so overrides are re-applied. | |
Config:: |
public | function |
Replaces the data of this configuration object. Overrides ConfigBase:: |
|
Config:: |
public | function | Sets module overrides for this configuration object. | |
Config:: |
protected | function | Sets the current data for this configuration object. | |
Config:: |
public | function | Sets settings.php overrides for this configuration object. | |
ConfigBase:: |
protected | property | The data of the configuration object. | |
ConfigBase:: |
protected | property | The name of the configuration object. | |
ConfigBase:: |
protected | function | Casts any objects that implement MarkupInterface to string. | |
ConfigBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyTrait:: |
|
ConfigBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyTrait:: |
|
ConfigBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyTrait:: |
1 |
ConfigBase:: |
public | function | Returns the name of this configuration object. | |
ConfigBase:: |
constant | The maximum length of a configuration object name. | ||
ConfigBase:: |
public | function | Merges data into a configuration object. | |
ConfigBase:: |
public | function | Sets the name of this configuration object. | |
ConfigBase:: |
protected | function | Validates all keys in a passed in config array structure. | |
ConfigBase:: |
public static | function | Validates the configuration object name. | |
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
LingotekFakeConfigWrapper:: |
public | property | ||
LingotekFakeConfigWrapper:: |
public | function |
Unsets a value in this configuration object. Overrides Config:: |
|
LingotekFakeConfigWrapper:: |
public | function |
Gets data from this configuration object. Overrides Config:: |
|
LingotekFakeConfigWrapper:: |
public | function |
Gets the raw data without overrides. Overrides Config:: |
|
LingotekFakeConfigWrapper:: |
public | function |
Saves the configuration object. Overrides Config:: |
|
LingotekFakeConfigWrapper:: |
public | function |
Sets a value in this configuration object. Overrides Config:: |
|
LingotekFakeConfigWrapper:: |
public | function |
Constructs a configuration object. Overrides Config:: |
|
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
StorableConfigBase:: |
protected | property | Whether the configuration object is new or has been saved to the storage. | |
StorableConfigBase:: |
protected | property | The data of the configuration object. | |
StorableConfigBase:: |
protected | property | The config schema wrapper object for this configuration object. | |
StorableConfigBase:: |
protected | property | The storage used to load and save this configuration object. | |
StorableConfigBase:: |
protected | property | The typed config manager. | |
StorableConfigBase:: |
protected | function | Casts the value to correct data type using the configuration schema. | |
StorableConfigBase:: |
protected | function | Gets the schema wrapper for the whole configuration object. | |
StorableConfigBase:: |
public | function | Retrieves the storage used to load and save this configuration object. | |
StorableConfigBase:: |
public | function | Returns whether this configuration object is new. | |
StorableConfigBase:: |
protected | function | Validate the values are allowed data types. |