Completed
Push — master ( 77bd7b...43acf6 )
by mw
35:57 queued 01:26
created

newSortKeyPropertyAnnotator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
3
namespace SMW;
4
5
use SMw\MediaWiki\RedirectTargetFinder;
6
use SMW\PropertyAnnotator\CategoryPropertyAnnotator;
7
use SMW\PropertyAnnotator\DisplayTitlePropertyAnnotator;
8
use SMW\PropertyAnnotator\MandatoryTypePropertyAnnotator;
9
use SMW\PropertyAnnotator\NullPropertyAnnotator;
10
use SMW\PropertyAnnotator\PredefinedPropertyAnnotator;
11
use SMW\PropertyAnnotator\RedirectPropertyAnnotator;
12
use SMW\PropertyAnnotator\SortKeyPropertyAnnotator;
13
use SMW\Store;
14
15
/**
16
 * @license GNU GPL v2+
17
 * @since 2.0
18
 *
19
 * @author mwjames
20
 */
21
class PropertyAnnotatorFactory {
22
23
	/**
24
	 * @since 2.0
25
	 *
26
	 * @param SemanticData $semanticData
27
	 *
28
	 * @return NullPropertyAnnotator
29
	 */
30 160
	public function newNullPropertyAnnotator( SemanticData $semanticData ) {
31 160
		return new NullPropertyAnnotator( $semanticData );
32
	}
33
34
	/**
35
	 * @since 2.0
36
	 *
37
	 * @param SemanticData $semanticData
38
	 * @param RedirectTargetFinder $redirectTargetFinder
39
	 *
40
	 * @return RedirectPropertyAnnotator
41
	 */
42 154
	public function newRedirectPropertyAnnotator( SemanticData $semanticData, RedirectTargetFinder $redirectTargetFinder ) {
43 154
		return new RedirectPropertyAnnotator(
44 154
			$this->newNullPropertyAnnotator( $semanticData ),
45
			$redirectTargetFinder
46
		);
47
	}
48
49
	/**
50
	 * @since 2.0
51
	 *
52
	 * @param SemanticData $semanticData
53
	 * @param PageInfo $pageInfo
54
	 *
55
	 * @return PredefinedPropertyAnnotator
56
	 */
57 153
	public function newPredefinedPropertyAnnotator( SemanticData $semanticData, PageInfo $pageInfo ) {
58
59 153
		$predefinedPropertyAnnotator = new PredefinedPropertyAnnotator(
60 153
			$this->newNullPropertyAnnotator( $semanticData ),
61
			$pageInfo
62
		);
63
64 153
		$predefinedPropertyAnnotator->setPredefinedPropertyList(
65 153
			ApplicationFactory::getInstance()->getSettings()->get( 'smwgPageSpecialProperties' )
66
		);
67
68 153
		return $predefinedPropertyAnnotator;
69
	}
70
71
	/**
72
	 * @since 2.0
73
	 *
74
	 * @param SemanticData $semanticData
75
	 * @param string $sortkey
76
	 *
77
	 * @return SortKeyPropertyAnnotator
78
	 */
79 147
	public function newSortKeyPropertyAnnotator( SemanticData $semanticData, $sortkey ) {
80 147
		return new SortKeyPropertyAnnotator(
81 147
			$this->newNullPropertyAnnotator( $semanticData ),
82
			$sortkey
83
		);
84
	}
85
86
	/**
87
	 * @since 2.4
88
	 *
89
	 * @param SemanticData $semanticData
90
	 * @param string|false $displayTitle
91
	 * @param string $defaultSort
92
	 *
93
	 * @return DisplayTitlePropertyAnnotator
94
	 */
95 146
	public function newDisplayTitlePropertyAnnotator( SemanticData $semanticData, $displayTitle, $defaultSort ) {
96 146
		return new DisplayTitlePropertyAnnotator(
97 146
			$this->newNullPropertyAnnotator( $semanticData ),
98
			$displayTitle,
99
			$defaultSort
100
		);
101
	}
102
103
	/**
104
	 * @since 2.0
105
	 *
106
	 * @param SemanticData $semanticData
107
	 * @param array $categories
108
	 *
109
	 * @return CategoryPropertyAnnotator
110
	 */
111 147
	public function newCategoryPropertyAnnotator( SemanticData $semanticData, array $categories ) {
112
113 147
		$categoryPropertyAnnotator = new CategoryPropertyAnnotator(
114 147
			$this->newNullPropertyAnnotator( $semanticData ),
115
			$categories
116
		);
117
118 147
		$categoryPropertyAnnotator->setShowHiddenCategoriesState(
119 147
			ApplicationFactory::getInstance()->getSettings()->get( 'smwgShowHiddenCategories' )
120
		);
121
122 147
		$categoryPropertyAnnotator->setCategoryInstanceUsageState(
123 147
			ApplicationFactory::getInstance()->getSettings()->get( 'smwgCategoriesAsInstances' )
124
		);
125
126 147
		$categoryPropertyAnnotator->setCategoryHierarchyUsageState(
127 147
			ApplicationFactory::getInstance()->getSettings()->get( 'smwgUseCategoryHierarchy' )
128
		);
129
130 147
		return $categoryPropertyAnnotator;
131
	}
132
133
	/**
134
	 * @since 2.2
135
	 *
136
	 * @param SemanticData $semanticData
137
	 *
138
	 * @return MandatoryTypePropertyAnnotator
139
	 */
140 147
	public function newMandatoryTypePropertyAnnotator( SemanticData $semanticData ) {
141 147
		return new MandatoryTypePropertyAnnotator(
142 147
			$this->newNullPropertyAnnotator( $semanticData )
143
		);
144
	}
145
146
}
147