public function toObject($object_to_fill = null, $props_to_skip = array()) { $object = parent::toObject($object_to_fill, $props_to_skip); $entryId = $object->getEntryId(); $entry = entryPeer::retrieveByPK($entryId); $partnerId = $entry->getPartnerId(); $transcriptId = $object->getInputTranscriptId(); $voicebaseOptionsObj = VoicebasePlugin::getPartnerVoicebaseOptions($partnerId); $object->setApiKey($voicebaseOptionsObj->apiKey); $object->setApiPassword($voicebaseOptionsObj->apiPassword); if (!$object->getFlavorAssetId()) { $sourceAsset = assetPeer::retrieveOriginalReadyByEntryId($entryId); if (!$sourceAsset) { throw new KalturaAPIException(KalturaVoicebaseErrors::NO_FLAVOR_ASSET_FOUND, $entryId); } $object->setFlavorAssetId($sourceAsset->getId()); } $voicebaseParamsMap = kConf::get('voicebase', 'integration'); if (!$object->getSpokenLanguage()) { $object->setSpokenLanguage($voicebaseParamsMap['default_language']); } $formatsString = $object->getCaptionAssetFormats(); if ($formatsString) { $formatsArray = explode(',', $formatsString); $excludedFormats = $voicebaseParamsMap['exclude_formats']; $sanitizedFormatsArray = array(); foreach ($formatsArray as $format) { $format = preg_replace("/[^A-Z_]/", "", $format); if (!constant("KalturaCaptionType::" . $format) || in_array($format, $excludedFormats)) { throw new KalturaAPIException(KalturaVoicebaseErrors::INVALID_TYPES, $formatsString); } $sanitizedFormatsArray[] = $format; } $sanitizedFormats = implode(",", $sanitizedFormatsArray); $object->setCaptionAssetFormats($sanitizedFormats); } else { $defaultFormats = implode(",", $voicebaseParamsMap['default_formats']); $object->setCaptionAssetFormats($defaultFormats); } if ($transcriptId) { $transcript = assetPeer::retrieveById($transcriptId); $key = $transcript->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); $fileSync = FileSyncPeer::retrieveByFileSyncKey($key, true); $object->setFileLocation($fileSync->getFullPath()); } return $object; }
public function toObject($object_to_fill = null, $props_to_skip = array()) { $object = parent::toObject($object_to_fill, $props_to_skip); $entryId = $object->getEntryId(); $entry = entryPeer::retrieveByPK($entryId); $partnerId = $entry->getPartnerId(); $transcriptId = $object->getInputTranscriptId(); $voicebaseOptionsObj = VoicebasePlugin::getPartnerVoicebaseOptions($partnerId); $object->setApiKey($voicebaseOptionsObj->apiKey); $object->setApiPassword($voicebaseOptionsObj->apiPassword); if ($transcriptId) { $transcript = assetPeer::retrieveById($transcriptId); $key = $transcript->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); $fileSync = FileSyncPeer::retrieveByFileSyncKey($key, true); $object->setFileLocation($fileSync->getFullPath()); } return $object; }