Completed
Push — master ( 668741...fcb265 )
by Fabien
04:22
created
Classes/Facet/StandardFacet.php 1 patch
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -19,153 +19,153 @@
 block discarded – undo
19 19
 class StandardFacet implements FacetInterface
20 20
 {
21 21
 
22
-    /**
23
-     * @var string
24
-     */
25
-    protected $name;
26
-
27
-    /**
28
-     * @var string
29
-     */
30
-    protected $label;
31
-
32
-    /**
33
-     * @var array
34
-     */
35
-    protected $suggestions = [];
36
-
37
-    /**
38
-     * @var string
39
-     */
40
-    protected $dataType;
41
-
42
-    /**
43
-     * @var bool
44
-     */
45
-    protected $canModifyMatcher = false;
46
-
47
-    /**
48
-     * Constructor of a Generic Facet in Vidi.
49
-     *
50
-     * @param string $name
51
-     * @param string $label
52
-     * @param array $suggestions
53
-     */
54
-    public function __construct($name, $label = '', array $suggestions = array())
55
-    {
56
-        $this->name = $name;
57
-        if (empty($label)) {
58
-            $label = $this->name;
59
-        }
60
-        $this->label = $label;
61
-        $this->suggestions = $suggestions;
62
-    }
63
-
64
-    /**
65
-     * @return string
66
-     */
67
-    public function getName()
68
-    {
69
-        return $this->name;
70
-    }
71
-
72
-    /**
73
-     * @return string
74
-     */
75
-    public function getLabel()
76
-    {
77
-        if ($this->label === $this->name) {
78
-            $label = Tca::table($this->dataType)->field($this->getName())->getLabel();
79
-        } else {
80
-            $label = LocalizationUtility::translate($this->label, '');
81
-            if (empty($label)) {
82
-                $label = $this->label;
83
-            }
84
-        }
85
-
86
-        return $label;
87
-    }
88
-
89
-    /**
90
-     * @return array
91
-     */
92
-    public function getSuggestions()
93
-    {
94
-
95
-        $values = [];
96
-        foreach ($this->suggestions as $key => $label) {
97
-            $localizedLabel = $this->getLanguageService()->sL($label);
98
-            if (!empty($localizedLabel)) {
99
-                $label = $localizedLabel;
100
-            }
101
-
102
-            $values[] = [$key => $label];
103
-        }
104
-
105
-        return $values;
106
-    }
107
-
108
-    /**
109
-     * @return \TYPO3\CMS\Lang\LanguageService
110
-     */
111
-    protected function getLanguageService()
112
-    {
113
-
114
-        /** @var \TYPO3\CMS\Lang\LanguageService $langService */
115
-        $langService = $GLOBALS['LANG'];
116
-        if (!$langService) {
117
-            $langService = GeneralUtility::makeInstance(\TYPO3\CMS\Lang\LanguageService::class);
118
-            $langService->init('en');
119
-        }
120
-
121
-        return $langService;
122
-    }
123
-
124
-    /**
125
-     * @return bool
126
-     */
127
-    public function hasSuggestions()
128
-    {
129
-        return !empty($this->suggestions);
130
-    }
131
-
132
-    /**
133
-     * @param string $dataType
134
-     * @return $this
135
-     */
136
-    public function setDataType($dataType)
137
-    {
138
-        $this->dataType = $dataType;
139
-        return $this;
140
-    }
141
-
142
-    /**
143
-     * @return bool
144
-     */
145
-    public function canModifyMatcher()
146
-    {
147
-        return $this->canModifyMatcher;
148
-    }
149
-
150
-    /**
151
-     * @param Matcher $matcher
152
-     * @param $value
153
-     * @return Matcher
154
-     */
155
-    public function modifyMatcher(Matcher $matcher, $value)
156
-    {
157
-        return $matcher;
158
-    }
159
-
160
-    /**
161
-     * Magic method implementation for retrieving state.
162
-     *
163
-     * @param array $states
164
-     * @return StandardFacet
165
-     */
166
-    static public function __set_state($states)
167
-    {
168
-        return new StandardFacet($states['name'], $states['label'], $states['suggestions']);
169
-    }
22
+	/**
23
+	 * @var string
24
+	 */
25
+	protected $name;
26
+
27
+	/**
28
+	 * @var string
29
+	 */
30
+	protected $label;
31
+
32
+	/**
33
+	 * @var array
34
+	 */
35
+	protected $suggestions = [];
36
+
37
+	/**
38
+	 * @var string
39
+	 */
40
+	protected $dataType;
41
+
42
+	/**
43
+	 * @var bool
44
+	 */
45
+	protected $canModifyMatcher = false;
46
+
47
+	/**
48
+	 * Constructor of a Generic Facet in Vidi.
49
+	 *
50
+	 * @param string $name
51
+	 * @param string $label
52
+	 * @param array $suggestions
53
+	 */
54
+	public function __construct($name, $label = '', array $suggestions = array())
55
+	{
56
+		$this->name = $name;
57
+		if (empty($label)) {
58
+			$label = $this->name;
59
+		}
60
+		$this->label = $label;
61
+		$this->suggestions = $suggestions;
62
+	}
63
+
64
+	/**
65
+	 * @return string
66
+	 */
67
+	public function getName()
68
+	{
69
+		return $this->name;
70
+	}
71
+
72
+	/**
73
+	 * @return string
74
+	 */
75
+	public function getLabel()
76
+	{
77
+		if ($this->label === $this->name) {
78
+			$label = Tca::table($this->dataType)->field($this->getName())->getLabel();
79
+		} else {
80
+			$label = LocalizationUtility::translate($this->label, '');
81
+			if (empty($label)) {
82
+				$label = $this->label;
83
+			}
84
+		}
85
+
86
+		return $label;
87
+	}
88
+
89
+	/**
90
+	 * @return array
91
+	 */
92
+	public function getSuggestions()
93
+	{
94
+
95
+		$values = [];
96
+		foreach ($this->suggestions as $key => $label) {
97
+			$localizedLabel = $this->getLanguageService()->sL($label);
98
+			if (!empty($localizedLabel)) {
99
+				$label = $localizedLabel;
100
+			}
101
+
102
+			$values[] = [$key => $label];
103
+		}
104
+
105
+		return $values;
106
+	}
107
+
108
+	/**
109
+	 * @return \TYPO3\CMS\Lang\LanguageService
110
+	 */
111
+	protected function getLanguageService()
112
+	{
113
+
114
+		/** @var \TYPO3\CMS\Lang\LanguageService $langService */
115
+		$langService = $GLOBALS['LANG'];
116
+		if (!$langService) {
117
+			$langService = GeneralUtility::makeInstance(\TYPO3\CMS\Lang\LanguageService::class);
118
+			$langService->init('en');
119
+		}
120
+
121
+		return $langService;
122
+	}
123
+
124
+	/**
125
+	 * @return bool
126
+	 */
127
+	public function hasSuggestions()
128
+	{
129
+		return !empty($this->suggestions);
130
+	}
131
+
132
+	/**
133
+	 * @param string $dataType
134
+	 * @return $this
135
+	 */
136
+	public function setDataType($dataType)
137
+	{
138
+		$this->dataType = $dataType;
139
+		return $this;
140
+	}
141
+
142
+	/**
143
+	 * @return bool
144
+	 */
145
+	public function canModifyMatcher()
146
+	{
147
+		return $this->canModifyMatcher;
148
+	}
149
+
150
+	/**
151
+	 * @param Matcher $matcher
152
+	 * @param $value
153
+	 * @return Matcher
154
+	 */
155
+	public function modifyMatcher(Matcher $matcher, $value)
156
+	{
157
+		return $matcher;
158
+	}
159
+
160
+	/**
161
+	 * Magic method implementation for retrieving state.
162
+	 *
163
+	 * @param array $states
164
+	 * @return StandardFacet
165
+	 */
166
+	static public function __set_state($states)
167
+	{
168
+		return new StandardFacet($states['name'], $states['label'], $states['suggestions']);
169
+	}
170 170
 
171 171
 }
Please login to merge, or discard this patch.