Commit c9ebb49c authored by alexpott's avatar alexpott

Issue #2231003 by kay_v, djevans, lokapujya, seiplax | scor:...

Issue #2231003 by kay_v, djevans, lokapujya, seiplax | scor: GetPreparedFieldMapping() should return NULL when there are no mappings.
parent 1251cc35
......@@ -215,7 +215,7 @@ function rdf_entity_prepare_view($entity_type, array $entities, array $displays)
// be displayed.
foreach ($displays[$entity->bundle()]->getComponents() as $name => $options) {
$field_mapping = $mapping->getPreparedFieldMapping($name);
if ($field_mapping['properties']) {
if ($field_mapping) {
foreach ($entity->get($name) as $item) {
$item->_attributes += rdf_rdfa_attributes($field_mapping, $item->getValue());
}
......@@ -532,16 +532,18 @@ function rdf_preprocess_taxonomy_term(&$variables) {
$bundle_mapping = $mapping->getPreparedBundleMapping();
$name_field_mapping = $mapping->getPreparedFieldMapping('name');
// Adds the RDF type of the term and the term name in a <meta> tag.
$term_label_meta = array(
'#tag' => 'meta',
'#attributes' => array(
'about' => url('taxonomy/term/' . $term->id()),
'typeof' => $bundle_mapping['types'],
'property' => $name_field_mapping['properties'],
'content' => $term->getName(),
),
);
drupal_add_html_head($term_label_meta, 'rdf_term_label');
if (!empty($name_field_mapping)) {
$term_label_meta = array(
'#tag' => 'meta',
'#attributes' => array(
'about' => url('taxonomy/term/' . $term->id()),
'typeof' => $bundle_mapping['types'],
'property' => $name_field_mapping['properties'],
'content' => $term->getName(),
),
);
drupal_add_html_head($term_label_meta, 'rdf_term_label');
}
}
/**
......
......@@ -78,7 +78,7 @@ public function getBundleMapping() {
if (isset($this->types)) {
return array('types' => $this->types);
}
return NULL;
return array();
}
/**
......@@ -105,7 +105,7 @@ public function getPreparedFieldMapping($field_name) {
if (isset($this->fieldMappings[$field_name])) {
$field_mapping = array_merge($field_mapping, $this->fieldMappings[$field_name]);
}
return $field_mapping;
return empty($field_mapping['properties']) ? array() : $field_mapping;
}
/**
......@@ -115,7 +115,7 @@ public function getFieldMapping($field_name) {
if (isset($this->fieldMappings[$field_name])) {
return $this->fieldMappings[$field_name];
}
return NULL;
return array();
}
/**
......
......@@ -34,8 +34,8 @@ public function getPreparedBundleMapping();
* serialization format, such as RDFa, then getPreparedBundleMapping() should
* be used instead.
*
* @return array|null
* The bundle mapping, or NULL if there is no mapping.
* @return array
* The bundle mapping, or an empty array if there is no mapping.
*/
public function getBundleMapping();
......@@ -75,7 +75,7 @@ public function setBundleMapping(array $mapping);
* The name of the field.
*
* @return array
* The prepared field mapping.
* The prepared field mapping, or an empty array if there is no mapping.
*/
public function getPreparedFieldMapping($field_name);
......@@ -90,8 +90,8 @@ public function getPreparedFieldMapping($field_name);
* @param string $field_name
* The name of the field.
*
* @return array|null
* The field mapping config array, or NULL if there is no mapping.
* @return array
* The field mapping config array, or an empty array if there is no mapping.
*/
public function getFieldMapping($field_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment