本文整理汇总了PHP中kFileSyncUtils::clearWAMSDataForKey方法的典型用法代码示例。如果您正苦于以下问题:PHP kFileSyncUtils::clearWAMSDataForKey方法的具体用法?PHP kFileSyncUtils::clearWAMSDataForKey怎么用?PHP kFileSyncUtils::clearWAMSDataForKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kFileSyncUtils
的用法示例。
在下文中一共展示了kFileSyncUtils::clearWAMSDataForKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceEntry
/**
* @param entry $entry
* @param entry $tempEntry
*/
public static function replaceEntry(entry $entry, entry $tempEntry = null)
{
KalturaLog::debug("in replaceEntry");
if (!$tempEntry) {
$tempEntry = entryPeer::retrieveByPK($entry->getReplacingEntryId());
}
if (!$tempEntry) {
KalturaLog::err("Temp entry id [" . $entry->getReplacingEntryId() . "] not found");
return;
}
//Extract all assets of the temp entry
$tempAssets = assetPeer::retrieveByEntryId($tempEntry->getId());
//Extract all assets of the existing entry
$oldAssets = assetPeer::retrieveByEntryId($entry->getId());
KalturaLog::debug("num of old assets: " . count($oldAssets));
$newAssets = array();
//Loop which creates a mapping between the new assets' paramsId and their type to the asset itself
foreach ($tempAssets as $newAsset) {
if ($newAsset->getStatus() != asset::FLAVOR_ASSET_STATUS_READY) {
KalturaLog::debug("Do not add new asset [" . $newAsset->getId() . "] to flavor [" . $newAsset->getFlavorParamsId() . "] status [" . $newAsset->getStatus() . "]");
continue;
}
//If doesn't exist - create a new array for the current asset's type.
if (!isset($newAssets[$newAsset->getType()])) {
$newAssets[$newAsset->getType()] = array();
}
if ($newAsset->getFlavorParamsId() || $newAsset instanceof flavorAsset) {
$newAssets[$newAsset->getType()][$newAsset->getFlavorParamsId()] = $newAsset;
KalturaLog::debug("Added new asset [" . $newAsset->getId() . "] for asset params [" . $newAsset->getFlavorParamsId() . "]");
} else {
$newAssets[$newAsset->getType()]['asset_' . count($newAssets[$newAsset->getType()])] = $newAsset;
KalturaLog::debug("Added new asset [" . $newAsset->getId() . "] with no asset params");
}
}
$saveEntry = false;
$defaultThumbAssetNew = null;
foreach ($oldAssets as $oldAsset) {
/* @var $oldAsset asset */
kFileSyncUtils::clearWAMSDataForKey($oldAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET));
//If the newAssets map contains an asset of the same type and paramsId as the current old asset,
// re-link the old asset to the new asset.
if (isset($newAssets[$oldAsset->getType()]) && isset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()])) {
$newAsset = $newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()];
/* @var $newAsset asset */
KalturaLog::debug("Create link from new asset [" . $newAsset->getId() . "] to old asset [" . $oldAsset->getId() . "] for flavor [" . $oldAsset->getFlavorParamsId() . "]");
if ($oldAsset instanceof flavorAsset) {
$oldAsset->setBitrate($newAsset->getBitrate());
$oldAsset->setFrameRate($newAsset->getFrameRate());
$oldAsset->setVideoCodecId($newAsset->getVideoCodecId());
}
$oldAsset->setWidth($newAsset->getWidth());
$oldAsset->setHeight($newAsset->getHeight());
$oldAsset->setContainerFormat($newAsset->getContainerFormat());
$oldAsset->setSize($newAsset->getSize());
$oldAsset->setFileExt($newAsset->getFileExt());
$oldAsset->setTags($newAsset->getTags());
$oldAsset->setDescription($newAsset->getDescription());
$oldAsset->incrementVersion();
$oldAsset->setStatusLocalReady();
$oldAsset->save();
$oldFileSync = $oldAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$newFileSync = $newAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::createSyncFileLinkForKey($oldFileSync, $newFileSync);
$newFlavorMediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($newAsset->getId());
if ($newFlavorMediaInfo) {
$oldFlavorNewMediaInfo = $newFlavorMediaInfo->copy();
$oldFlavorNewMediaInfo->setFlavorAssetId($oldAsset->getId());
$oldFlavorNewMediaInfo->setFlavorAssetVersion($oldAsset->getVersion());
$oldFlavorNewMediaInfo->save();
}
unset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()]);
if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
$defaultThumbAssetNew = $oldAsset;
KalturaLog::debug("Nominating ThumbAsset [" . $oldAsset->getId() . "] as the default ThumbAsset after replacent");
}
} elseif ($oldAsset instanceof flavorAsset || $oldAsset instanceof thumbAsset) {
KalturaLog::debug("Delete old asset [" . $oldAsset->getId() . "] for paramsId [" . $oldAsset->getFlavorParamsId() . "]");
$oldAsset->setStatus(flavorAsset::ASSET_STATUS_DELETED);
$oldAsset->setDeletedAt(time());
$oldAsset->save();
$entry->removeFlavorParamsId($oldAsset->getFlavorParamsId());
$saveEntry = true;
}
}
foreach ($newAssets as $newAssetsByTypes) {
foreach ($newAssetsByTypes as $newAsset) {
$createdAsset = $newAsset->copyToEntry($entry->getId(), $entry->getPartnerId());
KalturaLog::debug("Copied from new asset [" . $newAsset->getId() . "] to copied asset [" . $createdAsset->getId() . "] for flavor [" . $newAsset->getFlavorParamsId() . "]");
if ($createdAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
$defaultThumbAssetNew = $newAsset;
KalturaLog::debug("Nominating ThumbAsset [" . $newAsset->getId() . "] as the default ThumbAsset after replacent");
}
}
}
if ($defaultThumbAssetNew) {
kBusinessConvertDL::setAsDefaultThumbAsset($defaultThumbAssetNew);
//.........这里部分代码省略.........