private function CFDefaultFieldComparator::makeResultArray in Changed Fields API 7
Same name and namespace in other branches
- 7.3 src/FieldComparator/CFDefaultFieldComparator.php \CFDefaultFieldComparator::makeResultArray()
- 7.2 includes/changed_fields.core.inc \CFDefaultFieldComparator::makeResultArray()
Method that generates result array for CFDefaultFieldComparator::compareFieldValues().
Parameters
$fieldType:
$oldValue:
$newValue:
Return value
array
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 403 - changed_fields.core.inc file.
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,
);
}