You are here

public function HostsSetterController::setHosts in Lingotek Translation 3.3.x

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

Helper method for setting up a valid host for testing.

Required for the workbench links.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request.

Return value

\Symfony\Component\HttpFoundation\JsonResponse A JSON response with the current basepath and a success message.

1 string reference to 'HostsSetterController::setHosts'
lingotek_test.routing.yml in tests/modules/lingotek_test/lingotek_test.routing.yml
tests/modules/lingotek_test/lingotek_test.routing.yml

File

tests/modules/lingotek_test/src/Controller/HostsSetterController.php, line 52

Class

HostsSetterController
Controller for pointing up the host and sandbox in config to the local site.

Namespace

Drupal\lingotek_test\Controller

Code

public function setHosts(Request $request) {
  $basepath = $request
    ->getSchemeAndHttpHost();
  $config = $this->configFactory
    ->getEditable('lingotek.settings');
  $config
    ->set('account.use_production', TRUE)
    ->set('account.sandbox_host', $basepath)
    ->set('account.host', $basepath);
  $config
    ->save();
  return new JsonResponse([
    'message' => 'Success setting host to ' . $basepath,
    'basepath' => $basepath,
  ]);
}