function brightcove_field_autocomplete in Brightcove Video Connect 7.7
Same name and namespace in other branches
- 7.2 brightcove_field/brightcove_field.browse.inc \brightcove_field_autocomplete()
- 7.3 brightcove_field/brightcove_field.browse.inc \brightcove_field_autocomplete()
- 7.4 brightcove_field/brightcove_field.browse.inc \brightcove_field_autocomplete()
- 7.5 brightcove_field/brightcove_field.browse.inc \brightcove_field_autocomplete()
- 7.6 brightcove_field.browse.inc \brightcove_field_autocomplete()
Menu callback for brightcove_field/autocomplete.
Parameters
$field_name: Field name - field name that is requesting autocomplete. Unused, will be utilized to limit access to certain videos for certain fields.
$client: The client entity object.
$string: String to search for - will match videos by this text.
Return value
JSON object with matched videos.
1 string reference to 'brightcove_field_autocomplete'
- brightcove_menu in ./
brightcove.module - Implements hook_menu().
File
- ./
brightcove_field.browse.inc, line 62 - Holds a method to list all BC videos that are attachable to a field.
Code
function brightcove_field_autocomplete($type, $field_name, $client, $string = '') {
$matches = [];
$result = [];
switch ($type) {
case 'video':
brightcove_try(function () use (&$result, $client, $string) {
/** @var \Brightcove\API\CMS $cms */
list($cms, ) = brightcove_create_classes($client);
$result = $cms
->listVideos($string);
});
break;
case 'playlist':
// TODO implement if needed
$result = [];
break;
}
foreach ((array) $result as $bc_item) {
// Note: Brightcove ID is autogenerated by Brightcove and thus doesn't require XSS protection.
$matches[check_plain($bc_item->name) . ' [id:' . $bc_item->id . ']'] = check_plain($bc_item->name) . ' [id: ' . $bc_item->id . ']';
}
drupal_json_output($matches);
}