private function MigrateCommerceFileFieldHandler::_field_data_defaults in Commerce File 7
Returns the data array defaults for a Commerce File field
Return value
array
1 call to MigrateCommerceFileFieldHandler::_field_data_defaults()
- MigrateCommerceFileFieldHandler::buildFieldArray in migrate/
destinations/ fields.inc - Implementation of MigrateFileFieldBaseHandler::buildFieldArray().
File
- migrate/
destinations/ fields.inc, line 94 - Support for processing commerce file fields
Class
- MigrateCommerceFileFieldHandler
- Handle for commerce_file fields;
Code
private function _field_data_defaults(array $instance) {
$defaults = array();
// get license info
$license_info = _commerce_file_collate_license_info();
$entity_type = !empty($instance['entity_type']) ? $instance['entity_type'] : '';
if (!empty($license_info)) {
if ($entity_type == COMMERCE_FILE_LICENSE_ENTITY_NAME) {
// Licenses - default to instance settings, else unlimited
$data_default_value = COMMERCE_FILE_FIELD_UNLIMITED;
$defaults = array_fill_keys(array_keys($license_info), $data_default_value);
// merge any other instance data
if (!empty($instance_info['settings']['data'])) {
$defaults = $instance_info['settings']['data'] + $defaults;
}
}
else {
// Always set non-licenses to inherit
$data_default_value = COMMERCE_FILE_FIELD_INHERIT;
$defaults = array_fill_keys(array_keys($license_info), $data_default_value);
// merge any other instance data
if (!empty($instance_info['settings']['data'])) {
$defaults += $instance_info['settings']['data'];
}
}
}
return $defaults;
}