private function CFDefaultFieldComparator::makeResultArray in Changed Fields API 7.2
Same name and namespace in other branches
- 7.3 src/FieldComparator/CFDefaultFieldComparator.php \CFDefaultFieldComparator::makeResultArray()
- 7 includes/changed_fields.core.inc \CFDefaultFieldComparator::makeResultArray()
Method that generates result array for CFDefaultFieldComparator::compareFieldValues().
Parameters
string $fieldType: Field type.
mixed $oldValue: Old field value to compare.
mixed $newValue: New field value to compare.
Return value
array Array with old and new field values for compareFieldValues() method.
2 calls to CFDefaultFieldComparator::makeResultArray()
- CFDefaultFieldComparator::compareFieldValues in includes/
changed_fields.core.inc - Method that compares old and new field values.
- CFDefaultFieldComparator::runFieldComparison in includes/
changed_fields.core.inc - Method that runs comparison of field values.
File
- includes/
changed_fields.core.inc, line 502 - File contains core classes and interfaces.
Class
- CFDefaultFieldComparator
- Class CFDefaultFieldComparator.
Code
private function makeResultArray($fieldType, $oldValue, $newValue) {
// Return field collection item entities like field values for
// 'field_collection' field type.
if ($fieldType == 'field_collection') {
$resultOldValue = FALSE;
$resultNewValue = FALSE;
if ($oldValue) {
foreach ($oldValue as $key => $fc) {
$oldFc = entity_load('field_collection_item', array(
$fc['value'],
));
$oldFc = reset($oldFc);
$resultOldValue[] = $oldFc;
}
}
if ($newValue) {
foreach ($newValue as $key => $fc) {
$resultNewValue[] = $fc['entity'];
}
}
}
else {
$resultOldValue = $oldValue;
$resultNewValue = $newValue;
}
return array(
'old_value' => $resultOldValue,
'new_value' => $resultNewValue,
);
}