function brightcove_video_load_by_video_id in Brightcove Video Connect 7.7
Same name and namespace in other branches
- 7.6 brightcove.video.inc \brightcove_video_load_by_video_id()
Load a video entity by Video->getId().
This very smart function loads a brightcove_video entity by video_id or if it does not exist, it creates it.
Parameters
string $video_id:
Entity $client: The brightcove_client entity object.
Return value
Entity|boolean The brightcove_video entity object or FALSE on failure.
2 calls to brightcove_video_load_by_video_id()
- brightcove_video_edit in ./
brightcove.video.inc - Menu callback to display a video edit form.
- _brightcove_upload_form in ./
brightcove.video.inc
File
- ./
brightcove.video.inc, line 580 - Brightcove video related functions.
Code
function brightcove_video_load_by_video_id($video_id, $client) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'brightcove_video')
->propertyCondition('video_id', $video_id)
->addMetaData('account', user_load(1));
$result = $query
->execute();
if (isset($result['brightcove_video'])) {
$bvids = array_keys($result['brightcove_video']);
$bvid = reset($bvids);
$video = brightcove_video_load($bvid);
if (!empty($client)) {
$video->client = $client;
}
}
else {
$values = [
'type' => 'brightcove_video',
'video_id' => $video_id,
'client' => $client,
];
$video = entity_get_controller('brightcove_video')
->create($values);
}
return $video;
}