function brightcove_admin_player_edit_form in Brightcove Video Connect 7.7
Same name and namespace in other branches
- 7.6 brightcove.player.inc \brightcove_admin_player_edit_form()
Form callback for 'admin/config/media/brightcove/players/{%/%/edit,add}'.
_state
Parameters
array $form:
string|null $bcid:
string|null $player_id: Must be set when $bcid is set.
Return value
array
1 string reference to 'brightcove_admin_player_edit_form'
- brightcove_menu in ./
brightcove.module - Implements hook_menu().
File
- ./
brightcove.player.inc, line 131
Code
function brightcove_admin_player_edit_form(array $form, array &$form_state, $bcid = NULL, $player_id = NULL) {
if ($bcid) {
$form['bcid'] = [
'#type' => 'value',
'#value' => $bcid,
];
}
else {
$default_client = brightcove_client_load_or_default();
$form['bcid'] = [
'#type' => 'select',
'#title' => t('API Client'),
'#options' => array_map(function ($client) {
return $client->label;
}, entity_load('brightcove_client')),
'#default_value' => $default_client ? $default_client->bcid : NULL,
];
}
/** @var \Brightcove\Object\Player\Branch\Configuration\Configuration $configuration */
$configuration = NULL;
/** @var \Brightcove\Object\Player\Player $player */
$player = NULL;
if ($player_id) {
$client = brightcove_client_load($bcid);
/** @var \Brightcove\API\PM $pm */
list(, , $pm) = brightcove_create_classes($client);
$player = $pm
->getPlayer($player_id);
$configuration = $player
->getBranches()
->getPreview()
->getConfiguration();
}
else {
$configuration = _brightcove_admin_empty_configuration();
}
$form['player_id'] = [
'#type' => 'value',
'#value' => $player_id,
];
$form['name'] = [
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $player ? $player
->getName() : '',
'#required' => TRUE,
];
$form['description'] = [
'#type' => 'textarea',
'#title' => t('Description'),
'#default_value' => $player ? $player
->getDescription() : '',
];
$form = _brightcove_admin_player_configuration_form($form, $configuration);
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Save'),
];
return $form;
}