You are here

public static function BrightcoveVideo::loadByBrightcoveVideoId in Brightcove Video Connect 8

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

Loads a Video based on the Brightcove Video ID and Account ID.

Parameters

string $account_id: The ID of the account.

string $brightcove_video_id: The External ID of the Video.

Return value

\Drupal\Core\Entity\EntityInterface|null The matching Brightcove Video or NULL if the video cannot be found.

File

src/Entity/BrightcoveVideo.php, line 587

Class

BrightcoveVideo
Defines the Brightcove Video entity.

Namespace

Drupal\brightcove\Entity

Code

public static function loadByBrightcoveVideoId($account_id, $brightcove_video_id) {

  // Get API Client by Account ID.
  $api_client_ids = \Drupal::entityQuery('brightcove_api_client')
    ->condition('account_id', $account_id)
    ->execute();
  $entity_ids = \Drupal::entityQuery('brightcove_video')
    ->condition('api_client', reset($api_client_ids))
    ->condition('video_id', $brightcove_video_id)
    ->condition('status', 1)
    ->execute();
  if (!empty($entity_ids)) {
    return self::load(reset($entity_ids));
  }
  return NULL;
}