RdfMappingInterface.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace Drupal\rdf;
  3. use Drupal\Core\Config\Entity\ConfigEntityInterface;
  4. /**
  5. * Provides an interface defining an RDF mapping entity.
  6. */
  7. interface RdfMappingInterface extends ConfigEntityInterface {
  8. /**
  9. * Gets the mapping for the bundle-level data.
  10. *
  11. * The prepared bundle mapping should be used when outputting data in RDF
  12. * serializations such as RDFa. In the prepared mapping, the mapping
  13. * configuration's CURIE arrays are processed into CURIE strings suitable for
  14. * output.
  15. *
  16. * @return array
  17. * The bundle mapping.
  18. */
  19. public function getPreparedBundleMapping();
  20. /**
  21. * Gets the mapping config for the bundle-level data.
  22. *
  23. * This function returns the bundle mapping as stored in config, which may
  24. * contain CURIE arrays. If the mapping is needed for output in a
  25. * serialization format, such as RDFa, then getPreparedBundleMapping() should
  26. * be used instead.
  27. *
  28. * @return array
  29. * The bundle mapping, or an empty array if there is no mapping.
  30. */
  31. public function getBundleMapping();
  32. /**
  33. * Sets the mapping config for the bundle-level data.
  34. *
  35. * This only sets bundle-level mappings, such as the RDF type. Mappings for
  36. * a bundle's fields should be handled with setFieldMapping.
  37. *
  38. * Example usage:
  39. * -Map the 'article' bundle to 'sioc:Post'.
  40. * @code
  41. * rdf_get_mapping('node', 'article')
  42. * ->setBundleMapping(array(
  43. * 'types' => array('sioc:Post'),
  44. * ))
  45. * ->save();
  46. * @endcode
  47. *
  48. * @param array $mapping
  49. * The bundle mapping.
  50. *
  51. * @return \Drupal\rdf\Entity\RdfMapping
  52. * The RdfMapping object.
  53. */
  54. public function setBundleMapping(array $mapping);
  55. /**
  56. * Gets the prepared mapping for a field.
  57. *
  58. * The prepared field mapping should be used when outputting data in RDF
  59. * serializations such as RDFa. In the prepared mapping, the mapping
  60. * configuration's CURIE arrays are processed into CURIE strings suitable for
  61. * output.
  62. *
  63. * @param string $field_name
  64. * The name of the field.
  65. *
  66. * @return array
  67. * The prepared field mapping, or an empty array if there is no mapping.
  68. */
  69. public function getPreparedFieldMapping($field_name);
  70. /**
  71. * Gets the mapping config for a field.
  72. *
  73. * This function returns the field mapping as stored in config, which may
  74. * contain CURIE arrays. If the mapping is needed for output in a
  75. * serialization format, such as RDFa, then getPreparedFieldMapping() should
  76. * be used instead.
  77. *
  78. * @param string $field_name
  79. * The name of the field.
  80. *
  81. * @return array
  82. * The field mapping config array, or an empty array if there is no mapping.
  83. */
  84. public function getFieldMapping($field_name);
  85. /**
  86. * Sets the mapping config for a field.
  87. *
  88. * @param string $field_name
  89. * The name of the field.
  90. * @param array $mapping
  91. * The field mapping.
  92. *
  93. * @return \Drupal\rdf\Entity\RdfMapping
  94. * The RdfMapping object.
  95. */
  96. public function setFieldMapping($field_name, array $mapping = []);
  97. }