You are here

public function LingotekFake::get in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  2. 4.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  3. 3.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  4. 3.1.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::get()
  5. 3.2.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()

Overrides LingotekInterface::get

File

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

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.community':
      return \Drupal::config('lingotek.settings')
        ->get($key) ? \Drupal::config('lingotek.settings')
        ->get($key) : 'test_community';
    case 'default.project':
      return \Drupal::config('lingotek.settings')
        ->get($key) ? \Drupal::config('lingotek.settings')
        ->get($key) : 'test_project';
    case 'default.vault':
      return \Drupal::config('lingotek.settings')
        ->get($key) ? \Drupal::config('lingotek.settings')
        ->get($key) : 'test_vault';
    case 'default.workflow':
      return \Drupal::config('lingotek.settings')
        ->get($key) ? \Drupal::config('lingotek.settings')
        ->get($key) : 'test_workflow';
    case 'profile':
      return [
        [
          'id' => 1,
          'name' => 'automatic',
          'auto_upload' => TRUE,
          'auto_download' => TRUE,
        ],
      ];
  }
}