function brightcove_field_refresh_video_entity_link in Brightcove Video Connect 7.2
Same name and namespace in other branches
- 7.7 brightcove.module \brightcove_field_refresh_video_entity_link()
- 7.3 brightcove_field/brightcove_field.module \brightcove_field_refresh_video_entity_link()
- 7.4 brightcove_field/brightcove_field.module \brightcove_field_refresh_video_entity_link()
- 7.5 brightcove_field/brightcove_field.module \brightcove_field_refresh_video_entity_link()
- 7.6 brightcove.module \brightcove_field_refresh_video_entity_link()
Updates the video entity link on a video.
Parameters
$entity_type: Type of the entity to reference.
$entity: The entity to reference.
$items: The $items array of hook_field_insert() and hook_field_update(). Example: array( array('video_id' => 0), array('video_id' => 1), array('video_id' => 2), )
2 calls to brightcove_field_refresh_video_entity_link()
- brightcove_field_field_insert in brightcove_field/
brightcove_field.module - Implements hook_field_insert().
- brightcove_field_field_update in brightcove_field/
brightcove_field.module - IMplements hook_field_update().
File
- brightcove_field/
brightcove_field.module, line 1595 - Brightcove field module provides a Content Construction Kit module to developers, allowing them to browse videos in their Brightcove Studio and upload them.
Code
function brightcove_field_refresh_video_entity_link($entity_type, $entity, $items) {
if ($entity_link_field = variable_get('brightcove_link_field')) {
if ($entity_link = entity_uri($entity_type, $entity)) {
$absolute_entity_link = url($entity_link['path'], array(
'absolute' => TRUE,
) + $entity_link['options']);
$bc = brightcove_initialize();
$video_ids = array();
foreach ($items as $item) {
$video_ids[] = $item['video_id'];
}
if ($video_ids) {
$videos = $bc
->find('videosbyids', array(
'video_ids' => implode(',', $video_ids),
'video_fields' => 'id,customFields',
));
foreach ($videos as $video) {
if (!isset($video->customFields)) {
$video->customFields = new stdClass();
}
$video->customFields->{$entity_link_field} = $absolute_entity_link;
$bc
->update('video', $video);
}
}
}
}
}