/**
  * batch addMediaInfoAction action saves a media info object
  * 
  * @action addMediaInfo
  * @param KalturaMediaInfo $mediaInfo
  * @return KalturaMediaInfo 
  * @throws KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND
  */
 function addMediaInfoAction(KalturaMediaInfo $mediaInfo)
 {
     $mediaInfoDb = null;
     $flavorAsset = null;
     if ($mediaInfo->flavorAssetId) {
         $flavorAsset = assetPeer::retrieveByIdNoFilter($mediaInfo->flavorAssetId);
         if (!$flavorAsset) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $mediaInfo->flavorAssetId);
         }
         $mediaInfoDb = mediaInfoPeer::retrieveByFlavorAssetId($mediaInfo->flavorAssetId);
         if ($mediaInfoDb && $mediaInfoDb->getFlavorAssetVersion() == $flavorAsset->getVersion()) {
             $mediaInfoDb = $mediaInfo->toUpdatableObject($mediaInfoDb);
         } else {
             $mediaInfoDb = null;
         }
     }
     if (!$mediaInfoDb) {
         $mediaInfoDb = $mediaInfo->toInsertableObject();
     }
     if ($flavorAsset) {
         $mediaInfoDb->setFlavorAssetVersion($flavorAsset->getVersion());
     }
     $mediaInfoDb = kBatchManager::addMediaInfo($mediaInfoDb);
     $mediaInfo->fromObject($mediaInfoDb);
     return $mediaInfo;
 }
Exemple #2
0
 /**
  * batch addMediaInfoAction action saves a media info object
  * 
  * @action addMediaInfo
  * @param KalturaMediaInfo $mediaInfo
  * @return KalturaMediaInfo 
  */
 function addMediaInfoAction(KalturaMediaInfo $mediaInfo)
 {
     $mediaInfoDb = null;
     $flavorAsset = null;
     if ($mediaInfo->flavorAssetId) {
         $flavorAsset = flavorAssetPeer::retrieveById($mediaInfo->flavorAssetId);
         $mediaInfoDb = mediaInfoPeer::retrieveByFlavorAssetId($mediaInfo->flavorAssetId);
         if ($mediaInfoDb && $mediaInfoDb->getFlavorAssetVersion() == $flavorAsset->getVersion()) {
             $mediaInfoDb = $mediaInfo->toUpdatableObject($mediaInfoDb);
         } else {
             $mediaInfoDb = null;
         }
     }
     if (!$mediaInfoDb) {
         $mediaInfoDb = $mediaInfo->toInsertableObject();
     }
     if ($flavorAsset) {
         $mediaInfoDb->setFlavorAssetVersion($flavorAsset->getVersion());
     }
     $mediaInfoDb = kBatchManager::addMediaInfo($mediaInfoDb);
     $mediaInfo->fromObject($mediaInfoDb);
     return $mediaInfo;
 }