You are here

class ContextCurrentUserAuth in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8 src/Context/ContextCurrentUserAuth.php \Drupal\tmgmt_smartling\Context\ContextCurrentUserAuth
  2. 8.2 src/Context/ContextCurrentUserAuth.php \Drupal\tmgmt_smartling\Context\ContextCurrentUserAuth
  3. 8.3 src/Context/ContextCurrentUserAuth.php \Drupal\tmgmt_smartling\Context\ContextCurrentUserAuth

Hierarchy

Expanded class hierarchy of ContextCurrentUserAuth

1 string reference to 'ContextCurrentUserAuth'
tmgmt_smartling.services.yml in ./tmgmt_smartling.services.yml
tmgmt_smartling.services.yml
1 service uses ContextCurrentUserAuth
tmgmt_smartling.utils.context.current_user_auth in ./tmgmt_smartling.services.yml
Drupal\tmgmt_smartling\Context\ContextCurrentUserAuth

File

src/Context/ContextCurrentUserAuth.php, line 8

Namespace

Drupal\tmgmt_smartling\Context
View source
class ContextCurrentUserAuth {

  /**
   * @var AccountInterface
   */
  protected $currentAccount;

  /**
   * ContextCurrentUserAuth constructor.
   * @param AccountInterface $account
   */
  public function __construct(AccountInterface $account) {
    $this->currentAccount = $account;
  }

  /**
   * Returns cookies of the needed user.
   *
   * @param string $name
   * @return string
   * @throws WrongUsernameException
   */
  public function getCookies($name) {
    if ($this->currentAccount
      ->getAccountName() !== $name) {
      throw new WrongUsernameException('You tried to authenticate with a username that is different from the current user. This feature wasn\'t implemented yet.');
    }
    return session_name() . "=" . session_id();
  }
  public function getCurrentAccount() {
    return $this->currentAccount;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContextCurrentUserAuth::$currentAccount protected property
ContextCurrentUserAuth::getCookies public function Returns cookies of the needed user.
ContextCurrentUserAuth::getCurrentAccount public function
ContextCurrentUserAuth::__construct public function ContextCurrentUserAuth constructor.