function _microdata_mapping_add_defaults in Microdata 7
Helper function.
Sets up empty arrays for all fields and properties so there aren't notices when formatters try to use them.
1 call to _microdata_mapping_add_defaults()
- _microdata_prepare_mapping in ./
microdata.module - Helper function to prepare a microdata mapping for use.
File
- ./
microdata.module, line 1098
Code
function _microdata_mapping_add_defaults(&$mapping, $entity_type, $bundle_type, $fields) {
$defaults = array(
'#itemprop' => array(),
'#itemtype' => array(),
);
foreach ($fields as $field_name => $field) {
if (!isset($field['bundles'][$entity_type]) || !in_array($bundle_type, $field['bundles'][$entity_type])) {
continue;
}
if (!isset($mapping[$field_name])) {
$mapping[$field_name] = array();
}
$mapping[$field_name] = array_merge($defaults, $mapping[$field_name]);
$subfields = _microdata_get_field_properties($entity_type, $bundle_type, $field_name);
foreach ($subfields as $subfield_name => &$subfield) {
if (!isset($mapping[$field_name][$subfield_name])) {
$mapping[$field_name][$subfield_name] = array();
}
$subfield_mapping =& $mapping[$field_name][$subfield_name];
$subfield_mapping = array_merge($defaults, $subfield_mapping);
}
}
}