public function BrightcovePlaylistEntityController::save in Brightcove Video Connect 7.7
Same name and namespace in other branches
- 7.6 brightcove.playlist.inc \BrightcovePlaylistEntityController::save()
Overwrites EntityAPIController::save().
Overrides EntityAPIController::save
File
- ./
brightcove.playlist.inc, line 32 - Brightcove playlist related functions.
Class
- BrightcovePlaylistEntityController
- Entity controller class for Brightcove client.
Code
public function save($playlist_entity, DatabaseTransaction $transaction = NULL) {
if (!isset($playlist_entity->client)) {
watchdog('brightcove', 'Saving playlist failed due to missing client property.', [], WATCHDOG_ERROR);
drupal_set_message(t('Saving playlist failed due to missing client property.'), 'error');
return;
}
$bcid = $playlist_entity->client->bcid;
brightcove_try(function () use ($playlist_entity, $bcid) {
/** @var \Brightcove\API\CMS $cms */
list($cms, ) = brightcove_create_classes($playlist_entity->client);
if (!empty($playlist_entity->bpid)) {
field_attach_update('brightcove_playlist', $playlist_entity);
$cms
->updatePlaylist($playlist_entity->playlist);
brightcove_invalidate_cache("brightcove:playlist:{$playlist_entity->playlist->getId()}:{$bcid}");
}
else {
field_attach_insert('brightcove_playlist', $playlist_entity);
$cms
->createPlaylist($playlist_entity->playlist);
}
$name = $playlist_entity->playlist
->getName();
watchdog('brightcove', 'Saving brightcove playlist "@name" was successful.', [
'@name' => $name,
], WATCHDOG_INFO);
drupal_set_message(t('Saving brightcove playlist "@name" was successful.', [
'@name' => $name,
]), 'status');
}, function (\Brightcove\API\Exception\APIException $ex) {
throw $ex;
});
brightcove_invalidate_cache('brightcove:playlist:list', TRUE);
}