Example #1
0
function equalRecords( Structure $structure, Record $lhs, Record $rhs ) {
	$result = true;
	$attributes = $structure->getAttributes();
	$i = 0;
	
	while ( $result && $i < count( $attributes ) ) {
		$attribute = $attributes[$i];
		$type = $attribute->type;
		$lhsValue = $lhs->getAttributeValue( $attribute );
		$rhsValue = $rhs->getAttributeValue( $attribute );
		
		if ( $type instanceof Structure )
			$result = $lhsValue instanceof Record && $rhsValue instanceof Record && equalRecords( $type, $lhsValue, $rhsValue );
		else
			$result = $lhsValue == $rhsValue;
			
		$i++;
	}
	
	return $result;
}
Example #2
0
	protected function updateRecord( IdStack $idPath, Record $record, Structure $structure, $editors ) {
		if ( count( $editors ) > 0 ) {
			$updateRecord = $this->getUpdateRecord( $idPath, $structure, $editors );

			// only update if it has been modified (for example an modified definition)
			if ( !equalRecords( $structure, $record, $updateRecord ) )
				$this->controller->update( $idPath->getKeyStack(), $updateRecord );
		}
	}