You are here

function rdfx_get_predicates in RDF Extensions 7.2

Gets the predicates relating the property to the entity.

2 calls to rdfx_get_predicates()
rdfx_add_literal in ./rdfx.module
Adds a literal object.
rdfx_add_resource in ./rdfx.module
Adds a resource object.

File

./rdfx.module, line 218
Extends the RDF API of Drupal core to support more RDF seralizations formats other RDF capabilities.

Code

function rdfx_get_predicates(EntityMetadataWrapper $wrapper, $name) {
  $element = array();
  if ($wrapper instanceof EntityDrupalWrapper) {
    $entity = $wrapper
      ->value();
    if (!empty($entity->rdf_mapping[$name])) {

      // Just make use of the first predicate for now.
      // @lin this support all predicates defined in the mapping.
      $predicates = $entity->rdf_mapping[$name]['predicates'];
      $element = $predicates;
    }
  }

  // For elements which don't have a mapping, expose them using a local
  // namespace. @todo site vocabulary.
  // This functionality is disabled by default as a lot of this data is
  // irrelevant for outsiders and might contains some data the site owner might
  // not want to expose.
  // @todo provide admin setting to enable this functionality.
  if (!isset($element) && variable_get('rdfx_include_unset_mappings', FALSE)) {
    $predicate = 'site:' . (is_numeric($name) ? 'item' : $name);
    $element = array(
      $predicate,
    );
  }
  return $element;
}