public function BrightcoveVideo::delete in Brightcove Video Connect 8
Same name and namespace in other branches
- 8.2 src/Entity/BrightcoveVideo.php \Drupal\brightcove\Entity\BrightcoveVideo::delete()
- 3.x src/Entity/BrightcoveVideo.php \Drupal\brightcove\Entity\BrightcoveVideo::delete()
Parameters
bool $local_only: Whether to delete the local version only or both local and Brightcove versions.
Overrides EntityBase::delete
File
- src/
Entity/ BrightcoveVideo.php, line 906
Class
- BrightcoveVideo
- Defines the Brightcove Video entity.
Namespace
Drupal\brightcove\EntityCode
public function delete($local_only = FALSE) {
// Delete video from Brightcove.
if (!$this
->isNew() && !$local_only) {
$api_client = BrightcoveUtil::getApiClient($this
->getApiClient());
$client = $api_client
->getClient();
// Delete video references.
try {
$client
->request('DELETE', 1, 'cms', $api_client
->getAccountId(), "/videos/{$this->getVideoId()}/references", NULL);
// Delete video.
$cms = BrightcoveUtil::getCmsApi($this
->getApiClient());
$cms
->deleteVideo($this
->getVideoId());
parent::delete();
} catch (APIException $e) {
if ($e
->getCode() == 404) {
drupal_set_message(t('The video was not found on Brightcove, only the local version was deleted.'), 'warning');
parent::delete();
}
else {
drupal_set_message(t('There was an error while trying to delete the Video from Brightcove: @error', [
'@error' => $e
->getMessage(),
]), 'error');
}
}
}
else {
parent::delete();
}
}