1 | <?php |
||
8 | class ConceptMappingPropertyValue extends VocabularyDataObject |
||
9 | { |
||
10 | /** property type */ |
||
11 | private $type; |
||
12 | private $source; |
||
13 | private $clang; |
||
14 | private $labelcache; |
||
15 | |||
16 | /** |
||
17 | * ConceptMappingPropertyValue constructor. |
||
18 | * |
||
19 | * @param Model $model |
||
20 | * @param Vocabulary $vocab Target vocabulary |
||
21 | * @param Resource $target Target concept resource |
||
22 | * @param Resource $source Source concept resource |
||
23 | * @param string $prop Mapping property |
||
24 | * @param ?string $clang Preferred label language (nullable) |
||
|
|||
25 | */ |
||
26 | public function __construct(Model $model, Vocabulary $vocab, Resource $target, Resource $source, string $prop, $clang = '') |
||
34 | |||
35 | public function __toString() |
||
41 | |||
42 | public function getType() |
||
46 | |||
47 | public function getLabel($lang = '', $queryExVocabs = true) |
||
48 | { |
||
49 | if (isset($this->labelcache[$lang])) { |
||
50 | return $this->labelcache[$lang]; |
||
51 | } |
||
52 | |||
53 | $label = $this->queryLabel($lang); |
||
54 | $this->labelcache[$lang] = $label; |
||
55 | return $label; |
||
56 | } |
||
57 | |||
58 | private function queryLabel($lang = '', $queryExVocabs = true) |
||
59 | { |
||
60 | if ($this->clang) { |
||
61 | $lang = $this->clang; |
||
62 | } |
||
63 | |||
64 | |||
65 | $label = $this->getResourceLabel($this->resource, $lang); |
||
66 | if ($label) { |
||
67 | return $label; |
||
68 | } |
||
69 | |||
70 | // if multiple vocabularies are found, the following method will return in priority the current vocabulary of the mapping |
||
71 | $exvocab = $queryExVocabs ? $this->model->guessVocabularyFromURI($this->resource->getUri(), $this->vocab->getId()) : null; |
||
72 | |||
73 | // if the resource is from another vocabulary known by the skosmos instance |
||
74 | if ($exvocab) { |
||
75 | $label = $this->getExternalLabel($exvocab, $this->getUri(), $lang) ? $this->getExternalLabel($exvocab, $this->getUri(), $lang) : $this->getExternalLabel($exvocab, $this->getUri(), $exvocab->getConfig()->getDefaultLanguage()); |
||
76 | if ($label) { |
||
77 | return $label; |
||
78 | } |
||
79 | } |
||
80 | |||
81 | // using URI as label if nothing else has been found. |
||
82 | $label = $this->resource->shorten() ? $this->resource->shorten() : $this->resource->getUri(); |
||
83 | return $label; |
||
84 | } |
||
85 | |||
86 | private function getResourceLabel($res, $lang = '') { |
||
103 | |||
104 | public function getUri() |
||
108 | |||
109 | public function getExVocab() |
||
114 | |||
115 | public function getVocab() |
||
119 | |||
120 | public function getVocabName($lang = '') |
||
149 | |||
150 | public function isExternal() { |
||
151 | $propertyUris = $this->resource->propertyUris(); |
||
154 | |||
155 | public function getNotation() |
||
169 | |||
170 | /** |
||
171 | * Return the mapping as a JSKOS-compatible array. |
||
172 | * @return array |
||
173 | */ |
||
174 | public function asJskos($queryExVocabs = true) |
||
231 | |||
232 | } |
||
233 | |||
234 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.