/** * Get flavor params output object by ID * * @action get * @param int $id * @return KalturaFlavorParamsOutput * @throws KalturaErrors::FLAVOR_PARAMS_OUTPUT_ID_NOT_FOUND */ public function getAction($id) { $flavorParamsOutputDb = assetParamsOutputPeer::retrieveByPK($id); if (!$flavorParamsOutputDb) { throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_OUTPUT_ID_NOT_FOUND, $id); } $flavorParamsOutput = KalturaFlavorParamsFactory::getFlavorParamsOutputInstance($flavorParamsOutputDb->getType()); $flavorParamsOutput->fromObject($flavorParamsOutputDb); return $flavorParamsOutput; }
/** * @param kConvartableJobData $dbConvartableJobData * @return KalturaConvartableJobData */ public function fromObject($dbConvartableJobData) { parent::fromObject($dbConvartableJobData); $dbFlavorParams = $dbConvartableJobData->getFlavorParamsOutput(); if ($dbFlavorParams) { $this->flavorParamsOutput = KalturaFlavorParamsFactory::getFlavorParamsOutputInstance($dbFlavorParams->getType()); $this->flavorParamsOutput->fromObject($dbFlavorParams); } return $this; }
/** * Get Thumb Params by ID * * @action get * @param int $id * @return KalturaThumbParams */ public function getAction($id) { $thumbParamsDb = thumbParamsPeer::retrieveByPK($id); if (!$thumbParamsDb) { throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_ID_NOT_FOUND, $id); } $thumbParams = KalturaFlavorParamsFactory::getFlavorParamsInstance($thumbParamsDb->getType()); $thumbParams->fromObject($thumbParamsDb); return $thumbParams; }
/** * Get Caption Params by ID * * @action get * @param int $id * @return KalturaCaptionParams */ public function getAction($id) { $captionParamsDb = assetParamsPeer::retrieveByPK($id); if (!$captionParamsDb) { throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_ID_NOT_FOUND, $id); } $captionParams = KalturaFlavorParamsFactory::getFlavorParamsInstance($captionParamsDb->getType()); $captionParams->fromObject($captionParamsDb, $this->getResponseProfile()); return $captionParams; }
public static function fromDbArray($arr) { $newArr = new KalturaFlavorParamsArray(); if ($arr == null) { return $newArr; } foreach ($arr as $obj) { $nObj = KalturaFlavorParamsFactory::getFlavorParamsInstance($obj->getType()); $nObj->fromObject($obj); $newArr[] = $nObj; } return $newArr; }
public static function fromDbArray($arr, KalturaDetachedResponseProfile $responseProfile = null) { $newArr = new KalturaThumbParamsArray(); if ($arr == null) { return $newArr; } foreach ($arr as $obj) { $nObj = KalturaFlavorParamsFactory::getFlavorParamsInstance($obj->getType()); $nObj->fromObject($obj, $responseProfile); $newArr[] = $nObj; } return $newArr; }
/** * Get Flavor Asset with the relevant Flavor Params (Flavor Params can exist without Flavor Asset & vice versa) * * @action getFlavorAssetsWithParams * @param string $entryId * @return KalturaFlavorAssetWithParamsArray */ public function getFlavorAssetsWithParamsAction($entryId) { $dbEntry = entryPeer::retrieveByPK($entryId); if (!$dbEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } // get all the flavor params of partner 0 and the current partner (note that partner 0 is defined as partner group in service.ct) $flavorParamsDb = flavorParamsPeer::doSelect(new Criteria()); // get the flavor assets for this entry $c = new Criteria(); $c->add(flavorAssetPeer::ENTRY_ID, $entryId); $c->add(flavorAssetPeer::STATUS, array(flavorAsset::FLAVOR_ASSET_STATUS_DELETED, flavorAsset::FLAVOR_ASSET_STATUS_TEMP), Criteria::NOT_IN); $flavorAssetsDb = flavorAssetPeer::doSelect($c); // find what flavot params are required $requiredFlavorParams = array(); foreach ($flavorAssetsDb as $item) { $requiredFlavorParams[$item->getFlavorParamsId()] = true; } // now merge the results, first organize the flavor params in an array with the id as the key $flavorParamsArray = array(); foreach ($flavorParamsDb as $item) { $flavorParams = $item->getId(); $flavorParamsArray[$flavorParams] = $item; if (isset($requiredFlavorParams[$flavorParams])) { unset($requiredFlavorParams[$flavorParams]); } } // adding missing required flavors params to the list if (count($requiredFlavorParams)) { $flavorParamsDb = flavorParamsPeer::retrieveByPKsNoFilter(array_keys($requiredFlavorParams)); foreach ($flavorParamsDb as $item) { $flavorParamsArray[$item->getId()] = $item; } } $usedFlavorParams = array(); // loop over the flavor assets and add them, if it has flavor params add them too $flavorAssetWithParamsArray = new KalturaFlavorAssetWithParamsArray(); foreach ($flavorAssetsDb as $flavorAssetDb) { $flavorParamsId = $flavorAssetDb->getFlavorParamsId(); $flavorAssetWithParams = new KalturaFlavorAssetWithParams(); $flavorAssetWithParams->entryId = $entryId; $flavorAsset = new KalturaFlavorAsset(); $flavorAsset->fromObject($flavorAssetDb); $flavorAssetWithParams->flavorAsset = $flavorAsset; if (isset($flavorParamsArray[$flavorParamsId])) { $flavorParamsDb = $flavorParamsArray[$flavorParamsId]; $flavorParams = KalturaFlavorParamsFactory::getFlavorParamsInstance($flavorParamsDb->getType()); $flavorParams->fromObject($flavorParamsDb); $flavorAssetWithParams->flavorParams = $flavorParams; // we want to log which flavor params are in use, there could be more // than one flavor asset using same params $usedFlavorParams[$flavorParamsId] = $flavorParamsId; } // else if ($flavorAssetDb->getIsOriginal()) // { // // create a dummy flavor params // $flavorParams = new KalturaFlavorParams(); // $flavorParams->name = "Original source"; // $flavorAssetWithParams->flavorParams = $flavorParams; // } $flavorAssetWithParamsArray[] = $flavorAssetWithParams; } // copy the remaining params foreach ($flavorParamsArray as $flavorParamsId => $flavorParamsDb) { if (isset($usedFlavorParams[$flavorParamsId])) { // flavor params already exists for a flavor asset, not need // to list it one more time continue; } $flavorParams = KalturaFlavorParamsFactory::getFlavorParamsInstance($flavorParamsDb->getType()); $flavorParams->fromObject($flavorParamsDb); $flavorAssetWithParams = new KalturaFlavorAssetWithParams(); $flavorAssetWithParams->entryId = $entryId; $flavorAssetWithParams->flavorParams = $flavorParams; $flavorAssetWithParamsArray[] = $flavorAssetWithParams; } return $flavorAssetWithParamsArray; }
/** * Update Flavor Params by ID * * @action update * @param int $id * @param KalturaFlavorParams $flavorParams * @return KalturaFlavorParams */ public function updateAction($id, KalturaFlavorParams $flavorParams) { if ($flavorParams->name !== null) { $flavorParams->validatePropertyMinLength("name", self::PROPERTY_MIN_LENGTH); } $flavorParamsDb = assetParamsPeer::retrieveByPK($id); if (!$flavorParamsDb) { throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_ID_NOT_FOUND, $id); } $flavorParams->toUpdatableObject($flavorParamsDb); $flavorParamsDb->save(); $flavorParams = KalturaFlavorParamsFactory::getFlavorParamsInstance($flavorParamsDb->getType()); $flavorParams->fromObject($flavorParamsDb); return $flavorParams; }