Completed
Push — master ( b35119...1e4e2d )
by Florian
56s queued 29s
created
Form/QueryType.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -55,25 +55,25 @@  discard block
 block discarded – undo
55 55
 		$preferredFilterChoices = $options['preferred_filter_choices'];
56 56
 		$maxChoiceGroupCount = (int)$options['max_choice_group_count'];
57 57
 
58
-		if($usedFacets && !$result) {
58
+		if ($usedFacets && !$result) {
59 59
 			$data = [];
60
-			foreach($usedFacets as $facetType => $facetTypeOptions) {
60
+			foreach ($usedFacets as $facetType => $facetTypeOptions) {
61 61
 				$facetTypeOptions = is_array($facetTypeOptions) ? $facetTypeOptions : [];
62 62
 				$preferredChoices = $preferredFilterChoices[$facetType] ?? [];
63 63
 				$i = 0;
64
-				$builder->add('facet_' . $facetType, FacetType::class, array_merge(array(
65
-					'label'             => 'stinger_soft_entity_search.forms.query.' . $facetType . '.label',
64
+				$builder->add('facet_'.$facetType, FacetType::class, array_merge(array(
65
+					'label'             => 'stinger_soft_entity_search.forms.query.'.$facetType.'.label',
66 66
 					'multiple'          => true,
67 67
 					'expanded'          => true,
68 68
 					'preferred_choices' => function($val) use ($preferredChoices, $data, $facetType, $maxChoiceGroupCount, &$i) {
69
-						$facetKey = 'facet_' . $facetType;
69
+						$facetKey = 'facet_'.$facetType;
70 70
 						return $i++ < $maxChoiceGroupCount || $maxChoiceGroupCount === 0 || \in_array($val, $preferredChoices) || (isset($data[$facetKey]) && \in_array($val, $data[$facetKey]));
71 71
 					}
72 72
 				), $facetTypeOptions));
73 73
 				unset($i);
74 74
 			}
75 75
 		}
76
-		if($result) {
76
+		if ($result) {
77 77
 			$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) use ($options, $result) {
78 78
 				$this->createFacets($event->getForm(), $result->getFacets(), $options, $event->getData());
79 79
 			});
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
 		$selectedFacets = $data->getFacets();
138 138
 		$usedFacets = $options['used_facets'];
139 139
 
140
-		foreach($facets->getFacets() as $facetType => $facetValues) {
140
+		foreach ($facets->getFacets() as $facetType => $facetValues) {
141 141
 			$preferredChoices = $preferredFilterChoices[$facetType] ?? [];
142 142
 
143 143
 			$i = 0;
144 144
 			$facetTypeOptions = $usedFacets[$facetType] ?? [];
145 145
 			$formatter = $options['facet_formatter'][$facetType] ?? null;
146
-			$builder->add('facet_' . $facetType, FacetType::class, array_merge(array(
147
-				'label'             => 'stinger_soft_entity_search.forms.query.' . $facetType . '.label',
146
+			$builder->add('facet_'.$facetType, FacetType::class, array_merge(array(
147
+				'label'             => 'stinger_soft_entity_search.forms.query.'.$facetType.'.label',
148 148
 				'multiple'          => true,
149 149
 				'expanded'          => true,
150 150
 				'choices'           => $this->generateFacetChoices($facetType, $facetValues, $selectedFacets[$facetType] ?? [], $formatter),
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
 	protected function generateFacetChoices(string $facetType, array $facets, array $selectedFacets = [], callable $formatter = null): array {
168 168
 		$choices = [];
169 169
 		$handledFacets = [];
170
-		foreach($facets as $facet => $data) {
170
+		foreach ($facets as $facet => $data) {
171 171
 			$value = $data['value'];
172 172
 			$count = $data['count'];
173
-			if($count === 0 && !\in_array($facet, $selectedFacets)) {
173
+			if ($count === 0 && !\in_array($facet, $selectedFacets)) {
174 174
 				continue;
175 175
 			}
176 176
 			$handledFacets[$facet] = true;
177 177
 			$choices[$this->formatFacet($formatter, $facetType, $facet, $value, $count)] = $facet;
178 178
 		}
179
-		foreach($selectedFacets as $facet) {
180
-			if(!isset($facets[$facet]) || isset($handledFacets[$facet])) {
179
+		foreach ($selectedFacets as $facet) {
180
+			if (!isset($facets[$facet]) || isset($handledFacets[$facet])) {
181 181
 				continue;
182 182
 			}
183 183
 			$value = $facets[$facet]['value'];
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 	 * @return string
197 197
 	 */
198 198
 	protected function formatFacet(?callable $formatter, string $facetType, string $facet, $value, int $count): string {
199
-		$default = $facet . ' (' . $count . ')';
200
-		if(!$formatter) {
199
+		$default = $facet.' ('.$count.')';
200
+		if (!$formatter) {
201 201
 			return $default;
202 202
 		}
203 203
 		return $formatter($facetType, $value, $count, $default);
Please login to merge, or discard this patch.