summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-06-18 09:15:13 (GMT)
committerAlex Pott2014-06-18 09:15:13 (GMT)
commitc9ebb49caad24ed01683edc5c449209dbbac1f4e (patch)
tree6cafcd7fbe131a8c42cec90d3f2fdc32b036fa13
parent1251cc35a7f78e803ec99f836120496f445b8b84 (diff)
Issue #2231003 by kay_v, djevans, lokapujya, seiplax | scor: GetPreparedFieldMapping() should return NULL when there are no mappings.
-rw-r--r--core/modules/rdf/rdf.module24
-rw-r--r--core/modules/rdf/src/Entity/RdfMapping.php6
-rw-r--r--core/modules/rdf/src/RdfMappingInterface.php10
3 files changed, 21 insertions, 19 deletions
diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module
index 81335c1..a66af78 100644
--- a/core/modules/rdf/rdf.module
+++ b/core/modules/rdf/rdf.module
@@ -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');
+ }
}
/**
diff --git a/core/modules/rdf/src/Entity/RdfMapping.php b/core/modules/rdf/src/Entity/RdfMapping.php
index 76607ec..072f1af 100644
--- a/core/modules/rdf/src/Entity/RdfMapping.php
+++ b/core/modules/rdf/src/Entity/RdfMapping.php
@@ -78,7 +78,7 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
if (isset($this->types)) {
return array('types' => $this->types);
}
- return NULL;
+ return array();
}
/**
@@ -105,7 +105,7 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
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 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
if (isset($this->fieldMappings[$field_name])) {
return $this->fieldMappings[$field_name];
}
- return NULL;
+ return array();
}
/**
diff --git a/core/modules/rdf/src/RdfMappingInterface.php b/core/modules/rdf/src/RdfMappingInterface.php
index 458cd2d..3ccbb4e 100644
--- a/core/modules/rdf/src/RdfMappingInterface.php
+++ b/core/modules/rdf/src/RdfMappingInterface.php
@@ -34,8 +34,8 @@ interface RdfMappingInterface extends ConfigEntityInterface {
* 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 @@ interface RdfMappingInterface extends ConfigEntityInterface {
* 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 @@ interface RdfMappingInterface extends ConfigEntityInterface {
* @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);