function brightcove_autocomplete_videos in Brightcove Video Connect 7.7
Same name and namespace in other branches
- 7.3 brightcove.module \brightcove_autocomplete_videos()
- 7.4 brightcove.module \brightcove_autocomplete_videos()
- 7.5 brightcove.module \brightcove_autocomplete_videos()
- 7.6 brightcove.module \brightcove_autocomplete_videos()
Autocomplete callback for listing videos.
Parameters
Entity $client: The client entity object to use for aurocompleting videos.
string $videos_typed: The string of comma-separated videos typed so far.
1 string reference to 'brightcove_autocomplete_videos'
- brightcove_menu in ./
brightcove.module - Implements hook_menu().
File
- ./
brightcove.module, line 2239 - Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.
Code
function brightcove_autocomplete_videos($client, $videos_typed) {
$matches = [];
$result = [];
$videos_typed = drupal_explode_tags($videos_typed);
$video_last = drupal_strtolower(array_pop($videos_typed));
brightcove_try(function () use (&$result, $client, $video_last) {
/** @var \Brightcove\API\CMS $cms */
list($cms, ) = brightcove_create_classes($client);
$result = $cms
->listVideos($video_last);
});
foreach ($result as $video) {
// Note: Video ID is autogenerated by Brightcove and thus doesn't require XSS protection.
$matches[check_plain($video
->getName()) . ' [id:' . $video
->getId() . ']'] = check_plain($video
->getName()) . ' [id:' . $video
->getId() . ']';
}
$prefix = count($videos_typed) ? drupal_implode_tags($videos_typed) . ', ' : '';
$video_matches = [];
foreach ($matches as $name) {
$video_matches[$prefix . $name] = check_plain($name);
}
drupal_json_output($video_matches);
}