本文整理汇总了PHP中KalturaServiceBase::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP KalturaServiceBase::delete方法的具体用法?PHP KalturaServiceBase::delete怎么用?PHP KalturaServiceBase::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KalturaServiceBase
的用法示例。
在下文中一共展示了KalturaServiceBase::delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: syncTargetEntryObjects
/**
* Sync objects between the source and target accounts
* @param KalturaServiceBase $targetClientService API service for the current object type
* @param array $newObjects array of target objects that should be added/updated
* @param array $sourceObjects array of source objects
* @param array $distributedMap array of information about previously distributed objects
* @param string $targetEntryId
* @param string $addArgsFunc special function to extract arguments for the ADD api action
* @param string $updateArgsFunc special function to extract arguments for the UPDATE api action
* @return array of the synced objects
*/
protected function syncTargetEntryObjects(KalturaServiceBase $targetClientService, $newObjects, $sourceObjects, $distributedMap, $targetEntryId, $addArgsFunc = null, $updateArgsFunc = null)
{
$syncedObjects = array();
$distributedMap = empty($distributedMap) ? array() : unserialize($distributedMap);
// walk through all new target objects and add/update on target as necessary
if (count($newObjects)) {
KalturaLog::info('Syncing target objects for source IDs [' . implode(',', array_keys($newObjects)) . ']');
foreach ($newObjects as $sourceObjectId => $targetObject) {
if (is_array($distributedMap) && array_key_exists($sourceObjectId, $distributedMap)) {
// this object was previously distributed
KalturaLog::info('Source object id [' . $sourceObjectId . '] was previously distributed');
$lastDistributedUpdatedAt = isset($distributedMap[$sourceObjectId][self::DISTRIBUTED_INFO_SOURCE_UPDATED_AT]) ? $distributedMap[$sourceObjectId][self::DISTRIBUTED_INFO_SOURCE_UPDATED_AT] : null;
$currentSourceUpdatedAt = isset($sourceObjects[$sourceObjectId]->updatedAt) ? $sourceObjects[$sourceObjectId]->updatedAt : null;
$targetObjectId = isset($distributedMap[$sourceObjectId][self::DISTRIBUTED_INFO_TARGET_ID]) ? $distributedMap[$sourceObjectId][self::DISTRIBUTED_INFO_TARGET_ID] : null;
if (is_null($targetObjectId)) {
throw new Exception('Missing previously distributed target object id for source id [' . $sourceObjectId . ']');
}
if (!is_null($lastDistributedUpdatedAt) && !is_null($currentSourceUpdatedAt) && $currentSourceUpdatedAt <= $lastDistributedUpdatedAt) {
// object wasn't updated since last distributed - just return existing info
KalturaLog::info('No need to re-distributed object since it was not updated since last distribution - returning dummy object with target id [' . $targetObjectId . ']');
$targetObject->id = $targetObjectId;
$syncedObjects[$sourceObjectId] = $targetObject;
} else {
// should update existing target object
$targetObjectForUpdate = $this->removeInsertOnly($targetObject);
$updateArgs = null;
if (is_null($updateArgsFunc)) {
$updateArgs = array($targetObjectId, $targetObjectForUpdate);
} else {
$updateArgs = call_user_func_array(array($this, $updateArgsFunc), array($targetObjectId, $targetObjectForUpdate));
}
$syncedObjects[$sourceObjectId] = call_user_func_array(array($targetClientService, 'update'), $updateArgs);
}
unset($distributedMap[$sourceObjectId]);
} else {
// this object was not previously distributed - should add new target object
$addArgs = null;
if (is_null($addArgsFunc)) {
$addArgs = array($targetEntryId, $targetObject);
} else {
$addArgs = call_user_func_array(array($this, $addArgsFunc), array($targetObject));
}
$syncedObjects[$sourceObjectId] = call_user_func_array(array($targetClientService, 'add'), $addArgs);
}
}
}
// check if previously distributed objects should be deleted from the target account
if (count($distributedMap)) {
KalturaLog::info('Deleting target objects that were deleted in source with IDs [' . implode(',', array_keys($distributedMap)) . ']');
foreach ($distributedMap as $sourceId => $objInfo) {
// delete from target account
$targetId = isset($objInfo[self::DISTRIBUTED_INFO_TARGET_ID]) ? $objInfo[self::DISTRIBUTED_INFO_TARGET_ID] : null;
KalturaLog::info('Deleting previously distributed source object id [' . $sourceId . '] target object id [' . $targetId . ']');
if (is_null($targetId)) {
throw new Exception('Missing previously distributed target object id for source id [' . $sourceId . ']');
}
try {
$targetClientService->delete($targetId);
} catch (Exception $e) {
$acceptableErrorCodes = array('FLAVOR_ASSET_ID_NOT_FOUND', 'THUMB_ASSET_ID_NOT_FOUND', 'INVALID_OBJECT_ID', 'CAPTION_ASSET_ID_NOT_FOUND', 'INVALID_CUE_POINT_ID');
if (in_array($e->getCode(), $acceptableErrorCodes)) {
KalturaLog::warning('Object with id [' . $targetId . '] is already deleted - ignoring exception');
} else {
throw $e;
}
}
}
}
return $syncedObjects;
}