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