1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SMW\Exporter\ResourceBuilders; |
4
|
|
|
|
5
|
|
|
use SMW\Exporter\ResourceBuilder; |
6
|
|
|
use SMW\DIProperty; |
7
|
|
|
use SMWExporter as Exporter; |
8
|
|
|
use SMW\DataValueFactory; |
9
|
|
|
use SMWDataItem as DataItem; |
10
|
|
|
use SMWExpData as ExpData; |
11
|
|
|
use SMWExpLiteral as ExpLiteral; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @private |
15
|
|
|
* |
16
|
|
|
* @license GNU GPL v2+ |
17
|
|
|
* @since 2.5 |
18
|
|
|
* |
19
|
|
|
* @author mwjames |
20
|
|
|
*/ |
21
|
|
|
class PropertyDescriptionValueResourceBuilder extends PropertyValueResourceBuilder { |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @since 2.5 |
25
|
|
|
* |
26
|
|
|
* {@inheritDoc} |
27
|
|
|
*/ |
28
|
15 |
|
public function isResourceBuilderFor( DIProperty $property ) { |
29
|
15 |
|
return $property->getKey() === '_PDESC'; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @since 2.5 |
34
|
|
|
* |
35
|
|
|
* {@inheritDoc} |
36
|
|
|
*/ |
37
|
2 |
|
public function addResourceValue( ExpData $expData, DIProperty $property, DataItem $dataItem ) { |
38
|
|
|
|
39
|
2 |
|
parent::addResourceValue( $expData, $property, $dataItem ); |
40
|
|
|
|
41
|
2 |
|
$dataValue = DataValueFactory::getInstance()->newDataValueByItem( |
42
|
|
|
$dataItem, |
43
|
|
|
$property |
44
|
|
|
); |
45
|
|
|
|
46
|
2 |
|
$list = $dataValue->toArray(); |
47
|
|
|
|
48
|
2 |
|
if ( !isset( $list['_TEXT'] ) || !isset( $list['_LCODE'] ) ) { |
49
|
|
|
return; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
// Ussing `skos:scopeNote` instead of `skos:definition` since we can not |
53
|
|
|
// ensure that the description given by a user is complete. |
54
|
|
|
// |
55
|
|
|
// "skos:scopeNote supplies some, possibly partial, information about the |
56
|
|
|
// intended meaning of a concept ..." |
57
|
|
|
// |
58
|
|
|
// "skos:definition supplies a complete explanation of the intended |
59
|
|
|
// meaning of a concept." |
60
|
|
|
// |
61
|
|
|
// According to https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation |
62
|
|
|
|
63
|
2 |
|
$expData->addPropertyObjectValue( |
64
|
2 |
|
$this->exporter->getSpecialNsResource( 'skos', 'scopeNote' ), |
|
|
|
|
65
|
2 |
|
new ExpLiteral( |
66
|
2 |
|
(string)$list['_TEXT'], |
67
|
2 |
|
'http://www.w3.org/2001/XMLSchema#string', |
68
|
2 |
|
(string)$list['_LCODE'], |
69
|
|
|
$dataItem |
70
|
|
|
) |
71
|
|
|
); |
72
|
2 |
|
} |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: