You are here

public function LingotekSetupController::handshake in Lingotek Translation 3.3.x

Same name and namespace in other branches
  1. 8 src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::handshake()
  2. 8.2 src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::handshake()
  3. 4.0.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::handshake()
  4. 3.0.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::handshake()
  5. 3.1.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::handshake()
  6. 3.2.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::handshake()
  7. 3.4.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::handshake()
  8. 3.5.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::handshake()
  9. 3.6.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::handshake()
  10. 3.7.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::handshake()
  11. 3.8.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::handshake()
1 string reference to 'LingotekSetupController::handshake'
lingotek.routing.yml in ./lingotek.routing.yml
lingotek.routing.yml

File

src/Controller/LingotekSetupController.php, line 31

Class

LingotekSetupController
Returns responses for lingotek module setup routes.

Namespace

Drupal\lingotek\Controller

Code

public function handshake() {
  if ($this
    ->receivedToken()) {
    $this
      ->saveToken($this
      ->receivedToken());
    $config = \Drupal::configFactory()
      ->getEditable('lingotek.settings');
    $config
      ->set('account.use_production', TRUE)
      ->save();
    $account_info = $this
      ->fetchAccountInfo();
    $this
      ->saveAccountInfo($account_info);
    $this
      ->messenger()
      ->addStatus($this
      ->t('Your account settings have been saved.'));
    $this->logger
      ->notice('Account connected to Lingotek.');

    // No need to show the username and token if everything worked correctly
    // Just go to the community page
    return $this
      ->redirect('lingotek.setup_community');
  }
  else {
    return [
      '#type' => 'markup',
      '#markup' => $this
        ->t('Connecting... Please wait to be redirected'),
      '#attached' => [
        'library' => [
          'lingotek/lingotek.connect',
        ],
      ],
    ];
  }
}