|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SMW\Notifications\ChangeNotification; |
|
4
|
|
|
|
|
5
|
|
|
use SMW\Notifications\PropertyRegistry; |
|
6
|
|
|
use SMW\ApplicationFactory; |
|
7
|
|
|
use SMW\Notifications\DataValues\NotificationGroupValue; |
|
8
|
|
|
use SMW\Store; |
|
9
|
|
|
use SMW\DIProperty; |
|
10
|
|
|
use SMWDIBlob as DIBlob; |
|
11
|
|
|
use SMWDataItem as DataItem; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @license GNU GPL v2+ |
|
15
|
|
|
* @since 1.0 |
|
16
|
|
|
* |
|
17
|
|
|
* @author mwjames |
|
18
|
|
|
*/ |
|
19
|
|
|
class NotificationGroupsLocator { |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var Store |
|
23
|
|
|
*/ |
|
24
|
|
|
private $store; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @since 1.0 |
|
28
|
|
|
* |
|
29
|
|
|
* @param Store $store |
|
30
|
|
|
*/ |
|
31
|
5 |
|
public function __construct( Store $store ) { |
|
32
|
5 |
|
$this->store = $store; |
|
33
|
5 |
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Special group |
|
37
|
|
|
* |
|
38
|
|
|
* @since 1.0 |
|
39
|
|
|
* |
|
40
|
|
|
* @return [] |
|
|
|
|
|
|
41
|
|
|
*/ |
|
42
|
1 |
|
public function getSpecialGroupOnSpecificationChange() { |
|
43
|
|
|
return array( |
|
44
|
1 |
|
NotificationGroupValue::SPECIAL_GROUP => array( new DIBlob( NotificationGroupValue::getSpecialGroupName() ) ) |
|
45
|
1 |
|
); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @since 1.0 |
|
50
|
|
|
* |
|
51
|
|
|
* @param DataItem $dataItem |
|
52
|
|
|
* @param array $subSemanticDataMatch |
|
53
|
|
|
* |
|
54
|
|
|
* @return DataItem[] |
|
55
|
|
|
*/ |
|
56
|
2 |
|
public function findNotificationsToGroupList( DataItem $dataItem, array $subSemanticDataMatch ) { |
|
57
|
|
|
|
|
58
|
2 |
|
$property = new DIProperty( |
|
59
|
|
|
PropertyRegistry::NOTIFICATIONS_TO_GROUP |
|
60
|
2 |
|
); |
|
61
|
|
|
|
|
62
|
|
|
// Either match the property on a plain assignment or |
|
63
|
2 |
|
if ( ( $pv = $this->store->getPropertyValues( $dataItem, $property ) ) !== array() ) { |
|
64
|
|
|
return $pv; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
// Find out whether a detection matrix was build using a subobject |
|
68
|
2 |
|
$semanticData = $this->store->getSemanticData( |
|
69
|
|
|
$dataItem |
|
|
|
|
|
|
70
|
2 |
|
); |
|
71
|
|
|
|
|
72
|
2 |
|
$propertyValues = array(); |
|
73
|
|
|
|
|
74
|
|
|
// Get the group from the subobject that contained the matchable |
|
75
|
|
|
// condition from the preceding filterOnChange process |
|
76
|
2 |
|
foreach ( $subSemanticDataMatch as $hash => $value ) { |
|
77
|
1 |
|
foreach ( $value as $sobj ) { |
|
78
|
|
|
if ( |
|
79
|
1 |
|
( $hash === $dataItem->getHash() ) && |
|
80
|
1 |
|
( $subSemanticData = $semanticData->findSubSemanticData( $sobj ) ) !== array() ) { |
|
81
|
1 |
|
$propertyValues = array_merge( $propertyValues, $subSemanticData->getPropertyValues( $property ) ); |
|
82
|
1 |
|
} |
|
83
|
1 |
|
} |
|
84
|
2 |
|
} |
|
85
|
|
|
|
|
86
|
2 |
|
return $propertyValues; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @since 1.0 |
|
91
|
|
|
* |
|
92
|
|
|
* @param array $subSemanticDataMatch |
|
93
|
|
|
* |
|
94
|
|
|
* @return Closure |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getNotificationsToGroupListByCallback( array $subSemanticDataMatch ) { |
|
97
|
1 |
|
return function( $dataItem ) use( $subSemanticDataMatch ) { |
|
98
|
|
|
return $this->findNotificationsToGroupList( $dataItem, $subSemanticDataMatch ); |
|
99
|
1 |
|
}; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
} |
|
103
|
|
|
|
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.