rdf_get_mapping($entity_type, $bundle)
Returns the RDF mapping object associated with a bundle.
The function reads the rdf_mapping object from the current configuration, or returns a ready-to-use empty one if no configuration entry exists yet for this bundle. This streamlines the manipulation of mapping objects by always returning a consistent object that reflects the current state of the configuration.
Example usage: -Map the 'article' bundle to 'sioc:Post' and the 'title' field to 'dc:title'.
rdf_get_mapping('node', 'article') ->setBundleMapping(array( 'types' => array('sioc:Post'), )) ->setFieldMapping('title', array( 'properties' => array('dc:title') )) ->save();
Parameters
string $entity_type: The entity type.
string $bundle: The bundle.
Return value
\Drupal\rdf\Entity\RdfMapping The RdfMapping object.
Related topics
- RDF Mapping API
- Functions to describe entities and bundles in RDF.
File
- core/modules/rdf/rdf.module, line 71
- Enables semantically enriched output for Drupal sites in the form of RDFa.
Code
function rdf_get_mapping($entity_type, $bundle) { // Try loading the mapping from configuration. $mapping = RdfMapping::load($entity_type . '.' . $bundle); // If not found, create a fresh mapping object. if (!$mapping) { $mapping = RdfMapping::create(array( 'targetEntityType' => $entity_type, 'bundle' => $bundle, )); } return $mapping; }
Please login to continue.