public function LingotekSetupController::defaultsPage in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 8 src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::defaultsPage()
- 8.2 src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::defaultsPage()
- 4.0.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::defaultsPage()
- 3.0.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::defaultsPage()
- 3.1.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::defaultsPage()
- 3.2.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::defaultsPage()
- 3.3.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::defaultsPage()
- 3.4.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::defaultsPage()
- 3.5.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::defaultsPage()
- 3.6.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::defaultsPage()
- 3.7.x src/Controller/LingotekSetupController.php \Drupal\lingotek\Controller\LingotekSetupController::defaultsPage()
1 string reference to 'LingotekSetupController::defaultsPage'
File
- src/
Controller/ LingotekSetupController.php, line 103
Class
- LingotekSetupController
- Returns responses for lingotek module setup routes.
Namespace
Drupal\lingotek\ControllerCode
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) {
$config = \Drupal::configFactory()
->getEditable('lingotek.settings');
$config
->set('default.project', current(array_keys($resources['project'])));
$config
->set('default.vault', current(array_keys($resources['vault'])));
$default_workflow = array_search('Machine Translation', $resources['workflow']);
if ($default_workflow === FALSE) {
$default_workflow = current(array_keys($resources['workflow']));
}
$config
->set('default.workflow', $default_workflow);
// Assign the project callback
$new_callback_url = \Drupal::urlGenerator()
->generateFromRoute('lingotek.notify', [], [
'absolute' => TRUE,
]);
$config
->set('account.callback_url', $new_callback_url);
$config
->save();
$new_response = $this->lingotek
->setProjectCallBackUrl($config
->get('default.project'), $new_callback_url);
return $this
->redirect('lingotek.dashboard');
}
return [
'#type' => 'markup',
'markup' => $this->formBuilder
->getForm(LingotekSettingsDefaultsForm::class),
];
}