You are here

public function LingotekSetupController::defaultsPage in Lingotek Translation 8

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

File

src/Controller/LingotekSetupController.php, line 86

Class

LingotekSetupController
Returns responses for lingotek module setup routes.

Namespace

Drupal\lingotek\Controller

Code

public function defaultsPage() {
  if ($redirect = $this
    ->checkSetup()) {
    return $redirect;
  }
  $resources = $this->lingotek
    ->getResources();

  // No choice necessary. Save and advance to the next page.
  if (count($resources['project']) == 1 && count($resources['vault']) == 1) {
    $this->lingotek
      ->set('default.project', current(array_keys($resources['project'])));
    $this->lingotek
      ->set('default.vault', current(array_keys($resources['vault'])));
    $this->lingotek
      ->set('default.workflow', array_search('Machine Translation', $resources['workflow']));

    // Assign the project callback
    $new_callback_url = \Drupal::urlGenerator()
      ->generateFromRoute('lingotek.notify', [], [
      'absolute' => TRUE,
    ]);
    $this->lingotek
      ->set('account.callback_url', $new_callback_url);
    $new_response = $this->lingotek
      ->setProjectCallBackUrl($this->lingotek
      ->get('default.project'), $new_callback_url);
    return $this
      ->redirect('lingotek.dashboard');
  }
  return array(
    '#type' => 'markup',
    'markup' => $this
      ->getLingotekForm('LingotekSettingsDefaultsForm'),
  );
}