本文整理汇总了PHP中kFileSyncUtils::compareContent方法的典型用法代码示例。如果您正苦于以下问题:PHP kFileSyncUtils::compareContent方法的具体用法?PHP kFileSyncUtils::compareContent怎么用?PHP kFileSyncUtils::compareContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kFileSyncUtils
的用法示例。
在下文中一共展示了kFileSyncUtils::compareContent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateImpl
function updateImpl($id, $xmlData = null, $version = null)
{
$dbMetadata = MetadataPeer::retrieveByPK($id);
if (!$dbMetadata) {
throw new KalturaAPIException(MetadataErrors::METADATA_NOT_FOUND, $id);
}
if ($version && $dbMetadata->getVersion() != $version) {
throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_VERSION, $dbMetadata->getVersion());
}
$dbMetadataProfile = MetadataProfilePeer::retrieveByPK($dbMetadata->getMetadataProfileId());
if (!$dbMetadataProfile) {
throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_PROFILE, $dbMetadata->getMetadataProfileId());
}
$previousVersion = null;
if ($dbMetadata->getStatus() == Metadata::STATUS_VALID) {
$previousVersion = $dbMetadata->getVersion();
}
if ($xmlData) {
// if a metadata xslt is defined on the metadata profile - transform the given metadata
$xmlDataTransformed = $this->transformMetadata($dbMetadata->getMetadataProfileId(), $xmlData);
if ($xmlDataTransformed) {
$xmlData = $xmlDataTransformed;
}
$errorMessage = '';
if (!kMetadataManager::validateMetadata($dbMetadata->getMetadataProfileId(), $xmlData, $errorMessage)) {
// if metadata profile is transforming, and metadata profile version is not the latest, try to validate againts previous version
if ($dbMetadataProfile->getStatus() != MetadataProfile::STATUS_TRANSFORMING || $dbMetadata->getMetadataProfileVersion() >= $dbMetadataProfile->getVersion()) {
throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_DATA, $errorMessage);
}
// validates against previous version
$errorMessagePrevVersion = '';
if (!kMetadataManager::validateMetadata($dbMetadata->getMetadataProfileId(), $xmlData, $errorMessagePrevVersion, true)) {
KalturaLog::err("Failed to validate metadata object [{$id}] against metadata profile previous version [" . $dbMetadata->getMetadataProfileVersion() . "] error: {$errorMessagePrevVersion}");
// throw the error with the original error message
throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_DATA, $errorMessage);
}
} else {
$dbMetadata->setMetadataProfileVersion($dbMetadataProfile->getVersion());
}
$key = $dbMetadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
if (!kFileSyncUtils::compareContent($key, $xmlData)) {
$dbMetadata->incrementVersion();
$key = $dbMetadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
kFileSyncUtils::file_put_contents($key, $xmlData);
$dbMetadata->save();
kEventsManager::raiseEvent(new kObjectDataChangedEvent($dbMetadata, $previousVersion));
} else {
KalturaLog::info("XML data MD5 matches current filesync content MD5. Update is not necessary.");
//adding this save() in order to save the metadata profile version field in case there are no diffrences
$dbMetadata->save();
}
}
$metadata = new KalturaMetadata();
$metadata->fromObject($dbMetadata, $this->getResponseProfile());
return $metadata;
}