本文整理汇总了PHP中Tinebase_Record_Abstract::diff方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Record_Abstract::diff方法的具体用法?PHP Tinebase_Record_Abstract::diff怎么用?PHP Tinebase_Record_Abstract::diff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Record_Abstract
的用法示例。
在下文中一共展示了Tinebase_Record_Abstract::diff方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeModLog
/**
* computes changes of records and writes them to the logbook
*
* NOTE: expects last_modified_by and last_modified_time to be set
* properly in the $_newRecord
*
* @param Tinebase_Record_Abstract $_newRecord record from user data
* @param Tinebase_Record_Abstract $_curRecord record from storage
* @param string $_model
* @param string $_backend
* @param string $_id
* @return Tinebase_Record_RecordSet RecordSet of Tinebase_Model_ModificationLog
*/
public function writeModLog($_newRecord, $_curRecord, $_model, $_backend, $_id)
{
$commonModLog = $this->_getCommonModlog($_model, $_backend, array('last_modified_time' => $_newRecord->last_modified_time, 'last_modified_by' => $_newRecord->last_modified_by), $_id);
$diffs = $_curRecord->diff($_newRecord);
if (!empty($diffs) && Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' diffs: ' . print_r($diffs, TRUE));
}
if (!empty($diffs) && Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' curRecord: ' . print_r($_curRecord->toArray(), TRUE));
}
$modifications = new Tinebase_Record_RecordSet('Tinebase_Model_ModificationLog');
$this->_loopModifications($diffs, $commonModLog, $modifications, $_curRecord->toArray(), $_curRecord->getModlogOmitFields());
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Logged ' . count($modifications) . ' modifications.');
}
return $modifications;
}
示例2: diff
/**
* (non-PHPdoc)
* @see Tinebase_Record_Abstract::diff()
*/
public function diff($record, $omitFields = array())
{
$checkRrule = false;
if (!in_array('rrule', $omitFields)) {
$omitFields[] = 'rrule';
$checkRrule = true;
}
$diff = parent::diff($record, $omitFields);
if ($checkRrule) {
$ownRrule = !$this->rrule instanceof Calendar_Model_Rrule ? Calendar_Model_Rrule::getRruleFromString((string) $this->rrule) : $this->rrule;
$recordRrule = !$record->rrule instanceof Calendar_Model_Rrule ? Calendar_Model_Rrule::getRruleFromString($record->rrule) : $record->rrule;
$rruleDiff = $ownRrule->diff($recordRrule);
// don't take small ( < one day) rrule_until changes as diff
if ($ownRrule->until instanceof Tinebase_DateTime && (isset($rruleDiff->diff['until']) || array_key_exists('until', $rruleDiff->diff)) && $rruleDiff->diff['until'] instanceof Tinebase_DateTime && abs($rruleDiff->diff['until']->getTimestamp() - $ownRrule->until->getTimestamp()) < 86400) {
$rruleDiffArray = $rruleDiff->diff;
unset($rruleDiffArray['until']);
$rruleDiff->diff = $rruleDiffArray;
}
if (!empty($rruleDiff->diff)) {
$diffArray = $diff->diff;
$diffArray['rrule'] = $rruleDiff;
$diff->diff = $diffArray;
}
}
return $diff;
}
示例3: _mergeRecord
/**
* merge record / skip if no diff
*
* @param Tinebase_Record_Abstract $updateRecord
* @param Tinebase_Record_Abstract $mergeRecord
* @return Tinebase_Record_Abstract
*/
protected function _mergeRecord($updateRecord, $mergeRecord)
{
$omitFields = array('creation_time', 'created_by', 'last_modified_time', 'last_modified_by', 'seq', 'id');
$diff = $updateRecord->diff($mergeRecord, $omitFields);
if (!$diff || $diff->isEmpty()) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Records are identical, no need to update');
}
return null;
} else {
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Got diff: ' . print_r($diff->diff, TRUE));
}
}
return $updateRecord->merge($mergeRecord, $diff);
}