You are here

trait LingotekSetupTrait in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/LingotekSetupTrait.php \Drupal\lingotek\LingotekSetupTrait
  2. 4.0.x src/LingotekSetupTrait.php \Drupal\lingotek\LingotekSetupTrait
  3. 3.0.x src/LingotekSetupTrait.php \Drupal\lingotek\LingotekSetupTrait
  4. 3.1.x src/LingotekSetupTrait.php \Drupal\lingotek\LingotekSetupTrait
  5. 3.2.x src/LingotekSetupTrait.php \Drupal\lingotek\LingotekSetupTrait
  6. 3.3.x src/LingotekSetupTrait.php \Drupal\lingotek\LingotekSetupTrait
  7. 3.4.x src/LingotekSetupTrait.php \Drupal\lingotek\LingotekSetupTrait
  8. 3.5.x src/LingotekSetupTrait.php \Drupal\lingotek\LingotekSetupTrait
  9. 3.6.x src/LingotekSetupTrait.php \Drupal\lingotek\LingotekSetupTrait
  10. 3.7.x src/LingotekSetupTrait.php \Drupal\lingotek\LingotekSetupTrait
  11. 3.8.x src/LingotekSetupTrait.php \Drupal\lingotek\LingotekSetupTrait

Useful methods for checking if Lingotek is already setup.

Hierarchy

4 files declare their use of LingotekSetupTrait
LingotekConfigManagementForm.php in src/Form/LingotekConfigManagementForm.php
Contains \Drupal\Lingotek\Form\LingotekConfigManagementForm.
LingotekControllerBase.php in src/Controller/LingotekControllerBase.php
Contains \Drupal\lingotek\Controller\LingotekControllerBase.
LingotekManagementForm.php in src/Form/LingotekManagementForm.php
Contains \Drupal\Lingotek\Form\LingotekManagementForm.
LingotekMetadataEditForm.php in src/Form/LingotekMetadataEditForm.php

File

src/LingotekSetupTrait.php, line 13
Contains \Drupal\lingotek\LingotekSetupTrait.

Namespace

Drupal\lingotek
View source
trait LingotekSetupTrait {

  /**
   * A lingotek connector object
   *
   * @var \Drupal\lingotek\LingotekInterface
   */
  protected $lingotek;

  /**
   * Verify the Lingotek Translation module has been properly initialized.
   *
   * @return mixed Symfony\Component\HttpFoundation\RedirectResponse or FALSE
   *   A redirect response object, or FALSE if setup is complete.
   */
  protected function checkSetup() {
    if (!$this
      ->setupCompleted()) {
      return $this
        ->redirect('lingotek.setup_account');
    }
    return FALSE;
  }

  /**
   * Checks if Lingotek module is completely set up.
   *
   * @return boolean TRUE if connected, FALSE otherwise.
   */
  public function setupCompleted() {
    $info = $this
      ->config('lingotek.settings')
      ->get('account');
    if (!empty($info['access_token']) && !empty($info['login_id'])) {
      return TRUE;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LingotekSetupTrait::$lingotek protected property A lingotek connector object
LingotekSetupTrait::checkSetup protected function Verify the Lingotek Translation module has been properly initialized.
LingotekSetupTrait::setupCompleted public function Checks if Lingotek module is completely set up.