You are here

public function LingotekFake::get in Lingotek Translation 3.2.x

Same name and namespace in other branches
  1. 8 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  2. 8.2 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  3. 4.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  4. 3.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  5. 3.1.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  6. 3.3.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  7. 3.4.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  8. 3.5.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  9. 3.6.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  10. 3.7.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  11. 3.8.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()

Gets data from the configuration object.

Parameters

string $key: A string that maps to a key within the configuration data. For instance in the following configuration array:

array(
  'foo' => array(
    'bar' => 'baz',
  ),
);

A key of 'foo.bar' would return the string 'baz'. However, a key of 'foo' would return array('bar' => 'baz'). If no key is specified, then the entire data array is returned.

Return value

mixed The data that was requested.

Overrides LingotekInterface::get

Deprecated

in lingotek:3.0.1 and is removed from lingotek:4.0.0. Use configuration or configuration services directly.

See also

\Drupal\lingotek\LingotekConfigurationServiceInterface

1 call to LingotekFake::get()
LingotekFake::getEditable in tests/modules/lingotek_test/src/LingotekFake.php
Gets data from the mutable configuration object. Returns an mutable configuration object for a given name.

File

tests/modules/lingotek_test/src/LingotekFake.php, line 37

Class

LingotekFake

Namespace

Drupal\lingotek_test

Code

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,
          'sandbox_host' => $host,
          'authorize_path' => $this
            ->get('account.authorize_path'),
          'default_client_id' => $this
            ->get('account.default_client_id'),
          'access_token' => 'test_token',
          'login_id' => 'testUser@example.com',
          'use_production' => TRUE,
        ];
      }
    case 'account.login_id':
      return 'testUser@example.com';
    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
        ->getDefaults();
    case 'default.community':
      return $this->config
        ->get($this::SETTINGS)
        ->get($key) ? $this->config
        ->get($this::SETTINGS)
        ->get($key) : 'test_community';
    case 'default.project':
      return $this->config
        ->get($this::SETTINGS)
        ->get($key) ? $this->config
        ->get($this::SETTINGS)
        ->get($key) : 'test_project';
    case 'default.vault':
      return $this->config
        ->get($this::SETTINGS)
        ->get($key) ? $this->config
        ->get($this::SETTINGS)
        ->get($key) : 'test_vault';
    case 'default.filter':
      return $this->config
        ->get($this::SETTINGS)
        ->get($key) ? $this->config
        ->get($this::SETTINGS)
        ->get($key) : 'drupal_default';
    case 'default.subfilter':
      return $this->config
        ->get($this::SETTINGS)
        ->get($key) ? $this->config
        ->get($this::SETTINGS)
        ->get($key) : 'drupal_default';
    case 'default.workflow':
      return $this->config
        ->get($this::SETTINGS)
        ->get($key) ? $this->config
        ->get($this::SETTINGS)
        ->get($key) : 'test_workflow';
    case 'profile':
      return [
        [
          'id' => 1,
          'name' => 'automatic',
          'auto_upload' => TRUE,
          'auto_download' => TRUE,
        ],
      ];
  }
}