function _commerce_file_license_property_merge in Commerce File 7
Merge one or more property data arrays into the first
- assumes all settings have been resolved for all items
- aggregates properties
1 call to _commerce_file_license_property_merge()
- _commerce_file_field_aggregate_field_items in includes/
commerce_file.field.inc - Aggregate one or more field items' settings into the first field item
File
- ./
commerce_file.module, line 418 - Provides integration of file licenses with Commerce
Code
function _commerce_file_license_property_merge($data1) {
$args = func_get_args();
// extract trunk
$trunk = array_shift($args);
if (empty($trunk)) {
$trunk = array();
}
// return $trunk if no other arrays to merge
if (empty($args)) {
return $trunk;
}
// get license info
$license_info = _commerce_file_collate_license_info();
// merge arrays
foreach ($args as $data) {
$non_license_data = array_diff_key($data, $license_info);
// only operate on license properties
foreach ($license_info as $k => $info) {
$aggregated = !empty($info['property info']['aggregated']);
// populate trunk
if (isset($trunk[$k])) {
// combine if trunk and data
if (isset($data[$k])) {
$combined = _commerce_file_license_property_combine_values($trunk[$k], $data[$k], $aggregated);
if (isset($combined)) {
$trunk[$k] = $combined;
}
}
}
elseif (isset($data[$k])) {
$trunk[$k] = $data[$k];
}
}
// merge non license data to override trunk
$trunk = $non_license_data + $trunk;
}
return $trunk;
}