You are here

protected function BrightcoveVideo::getIngestionToken in Brightcove Video Connect 3.x

Same name and namespace in other branches
  1. 8.2 src/Entity/BrightcoveVideo.php \Drupal\brightcove\Entity\BrightcoveVideo::getIngestionToken()
  2. 8 src/Entity/BrightcoveVideo.php \Drupal\brightcove\Entity\BrightcoveVideo::getIngestionToken()

Get a random hash token for ingestion request callback.

Return value

string|null The generated random token or NULL if an error happened.

1 call to BrightcoveVideo::getIngestionToken()
BrightcoveVideo::save in src/Entity/BrightcoveVideo.php

File

src/Entity/BrightcoveVideo.php, line 273

Class

BrightcoveVideo
Defines the Brightcove Video entity.

Namespace

Drupal\brightcove\Entity

Code

protected function getIngestionToken() {
  $token = NULL;
  try {

    // Generate unique token.
    do {
      $token = Crypt::hmacBase64($this
        ->getBrightcoveId(), Crypt::randomBytesBase64() . Settings::getHashSalt());
    } while (\Drupal::keyValueExpirable('brightcove_callback')
      ->has($token));

    // Insert unique token into database.
    \Drupal::keyValueExpirable('brightcove_callback')
      ->setWithExpire($token, $this
      ->id(), \Drupal::config('brightcove.settings')
      ->get('notification.callbackExpirationTime'));
  } catch (\Exception $e) {
    watchdog_exception('brightcove', $e);

    // Reset token to NULL.
    $token = NULL;
  }
  return $token;
}