You are here

public function InstagramAccount::tokenIsValid in Instagram Feeds 8

Checks if Instagram access token exists and hasn't expired.

Return value

bool TRUE if token is set and has not been expired, FALSE otherwise.

Overrides InstagramAccountInterface::tokenIsValid

2 calls to InstagramAccount::tokenIsValid()
InstagramAccount::getToken in src/Entity/InstagramAccount.php
Gets the Instagram long-lived token.
InstagramAccount::refreshToken in src/Entity/InstagramAccount.php
Tries to refresh long-lived Instagram access token.

File

src/Entity/InstagramAccount.php, line 188

Class

InstagramAccount
Defines the instagram_account entity class.

Namespace

Drupal\instagram_feeds\Entity

Code

public function tokenIsValid() : bool {
  $expires_in = $this
    ->get('token_expiration')
    ->isEmpty() ? [
    0,
  ] : $this
    ->get('token_expiration')
    ->first()
    ->getValue();
  return !$this
    ->get('token')
    ->isEmpty() && \Drupal::time()
    ->getRequestTime() < (int) reset($expires_in);
}