private function CFDefaultFieldComparator::makeResultArray in Changed Fields API 7.3
Same name and namespace in other branches
- 7 includes/changed_fields.core.inc \CFDefaultFieldComparator::makeResultArray()
- 7.2 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 src/
FieldComparator/ CFDefaultFieldComparator.php - Method that compares old and new field values.
- CFDefaultFieldComparator::runFieldComparison in src/
FieldComparator/ CFDefaultFieldComparator.php - Method that runs comparison of field values.
File
- src/
FieldComparator/ CFDefaultFieldComparator.php, line 283
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', [
$fc['value'],
]);
$oldFc = reset($oldFc);
$resultOldValue[] = $oldFc;
}
}
if ($newValue) {
foreach ($newValue as $key => $fc) {
$resultNewValue[] = $fc['entity'];
}
}
}
else {
$resultOldValue = $oldValue;
$resultNewValue = $newValue;
}
return [
'old_value' => $resultOldValue,
'new_value' => $resultNewValue,
];
}