You are here

public function LingotekManagementController::content in Lingotek Translation 3.4.x

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

File

src/Controller/LingotekManagementController.php, line 54

Class

LingotekManagementController

Namespace

Drupal\lingotek\Controller

Code

public function content() {
  if ($redirect = $this
    ->checkSetup()) {
    return $redirect;
  }
  $entity_types = \Drupal::service('lingotek.configuration')
    ->getEnabledEntityTypes();
  $entity_type_id = NULL;
  if (!empty($entity_types)) {

    // Prioritize node as main content type.
    if (array_key_exists('node', $entity_types)) {
      $entity_type_id = 'node';
    }
    else {
      $entity_type_keys = array_keys($entity_types);
      $entity_type_id = reset($entity_type_keys);
    }
  }
  if ($entity_type_id) {
    return $this
      ->redirect("lingotek.manage.{$entity_type_id}");
  }
  $build['enable_content_translation']['#markup'] = $this
    ->t('You need to enable content translation first. You can enable translation for the desired content entities on the <a href=":translation-entity">Content language</a> page.', [
    ':translation-entity' => $this->urlGenerator
      ->generateFromRoute('language.content_settings_page'),
  ]) . '<br/>';
  $build['enable_lingotek']['#markup'] = $this
    ->t('Then you need to configure how you want to translate your content with Lingotek. Enable translation for the desired content entities on the <a href=":lingotek-translation-entity">Lingotek settings</a> page.', [
    ':lingotek-translation-entity' => $this->urlGenerator
      ->generateFromRoute('lingotek.settings'),
  ]);
  return $build;
}