/** * Adds the relation of flavorParams <> conversionProfile2 * * @param conversionProfile2 $conversionProfileDb * @param $flavorParamsIds * * @throws KalturaErrors::ASSET_PARAMS_INVALID_TYPE */ protected function addFlavorParamsRelation(conversionProfile2 $conversionProfileDb, $flavorParamsIds) { $existingIds = flavorParamsConversionProfilePeer::getFlavorIdsByProfileId($conversionProfileDb->getId()); $assetParamsObjects = assetParamsPeer::retrieveByPKs($flavorParamsIds); foreach ($assetParamsObjects as $assetParams) { /* @var $assetParams assetParams */ if (in_array($assetParams->getId(), $existingIds)) { continue; } if ($conversionProfileDb->getType() == ConversionProfileType::LIVE_STREAM && $assetParams->getType() != assetType::LIVE) { throw new KalturaAPIException(KalturaErrors::ASSET_PARAMS_INVALID_TYPE, $assetParams->getId(), $assetParams->getType()); } $fpc = new flavorParamsConversionProfile(); $fpc->setConversionProfileId($conversionProfileDb->getId()); $fpc->setFlavorParamsId($assetParams->getId()); $fpc->setReadyBehavior($assetParams->getReadyBehavior()); $fpc->setSystemName($assetParams->getSystemName()); $fpc->setForceNoneComplied(false); if ($assetParams->hasTag(assetParams::TAG_SOURCE) || $assetParams->hasTag(assetParams::TAG_INGEST)) { $fpc->setOrigin(assetParamsOrigin::INGEST); } else { $fpc->setOrigin(assetParamsOrigin::CONVERT); } $fpc->save(); } }
/** * Adds the relation of flavorParams <> conversionProfile2 * * @param conversionProfile2 $conversionProfileDb * @param $flavorParamsIds */ protected function addFlavorParamsRelation(conversionProfile2 $conversionProfileDb, $flavorParamsIds) { $existingIds = flavorParamsConversionProfilePeer::getFlavorIdsByProfileId($conversionProfileDb->getId()); $assetParamsObjects = assetParamsPeer::retrieveByPKs($flavorParamsIds); foreach ($assetParamsObjects as $assetParams) { /* @var $assetParams assetParams */ if (in_array($assetParams->getId(), $existingIds)) { continue; } $fpc = new flavorParamsConversionProfile(); $fpc->setConversionProfileId($conversionProfileDb->getId()); $fpc->setFlavorParamsId($assetParams->getId()); $fpc->setReadyBehavior($assetParams->getReadyBehavior()); $fpc->setSystemName($assetParams->getSystemName()); $fpc->setForceNoneComplied(false); if ($assetParams->hasTag(assetParams::TAG_SOURCE)) { $fpc->setOrigin(assetParamsOrigin::INGEST); } else { $fpc->setOrigin(assetParamsOrigin::CONVERT); } $fpc->save(); } }
$partners = PartnerPeer::doSelect($partnerCriteria); foreach ($partners as $partner) { /* @var $partner Partner */ $profileCriteria = new Criteria(); $profileCriteria->add(conversionProfile2Peer::PARTNER_ID, $partner->getId()); $profileCriteria->add(conversionProfile2Peer::TYPE, $conversionProfileType); $profileCriteria->add(conversionProfile2Peer::STATUS, ConversionProfileStatus::DELETED, Criteria::NOT_EQUAL); $profiles = conversionProfile2Peer::doSelect($profileCriteria); foreach ($profiles as $profile) { /* @var $profile conversionProfile2 */ $flavorParamsConversionProfileIds = flavorParamsConversionProfilePeer::getFlavorIdsByProfileId($profile->getId()); foreach ($additioalFlavorParamsObjects as $additioalFlavorParamsId => $additioalFlavorParamsObject) { if (in_array($additioalFlavorParamsId, $flavorParamsConversionProfileIds)) { continue; } $flavorParamsConversionProfile = new flavorParamsConversionProfile(); $flavorParamsConversionProfile->setConversionProfileId($profile->getId()); $flavorParamsConversionProfile->setFlavorParamsId($additioalFlavorParamsId); $flavorParamsConversionProfile->setReadyBehavior($additioalFlavorParamsObject->getReadyBehavior()); $flavorParamsConversionProfile->setSystemName($additioalFlavorParamsObject->getSystemName()); $flavorParamsConversionProfile->setForceNoneComplied(false); if ($additioalFlavorParamsObject->hasTag(assetParams::TAG_SOURCE) || $additioalFlavorParamsObject->hasTag(assetParams::TAG_INGEST)) { $flavorParamsConversionProfile->setOrigin(assetParamsOrigin::INGEST); } else { $flavorParamsConversionProfile->setOrigin(assetParamsOrigin::CONVERT); } $flavorParamsConversionProfile->save(); } } } exit(0);