protected function BrightcoveVideo::getIngestionToken in Brightcove Video Connect 8
Same name and namespace in other branches
- 8.2 src/Entity/BrightcoveVideo.php \Drupal\brightcove\Entity\BrightcoveVideo::getIngestionToken()
- 3.x 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 268
Class
- BrightcoveVideo
- Defines the Brightcove Video entity.
Namespace
Drupal\brightcove\EntityCode
protected function getIngestionToken() {
$token = NULL;
try {
// Generate unique token.
do {
$token = Crypt::hmacBase64($this
->getVideoId(), 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;
}