Completed
Push — master ( 9ac279...904bc9 )
by Florian
03:18
created
Services/AbstractSearchService.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 	 * @see \StingerSoft\EntitySearchBundle\Services\SearchService::setObjectManager()
32 32
 	 */
33 33
 	public function setObjectManager(ObjectManager $om) {
34
-		if($this->objectManager)
34
+		if ($this->objectManager)
35 35
 			return;
36 36
 		$this->objectManager = $om;
37 37
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@
 block discarded – undo
31 31
 	 * @see \StingerSoft\EntitySearchBundle\Services\SearchService::setObjectManager()
32 32
 	 */
33 33
 	public function setObjectManager(ObjectManager $om) {
34
-		if($this->objectManager)
35
-			return;
34
+		if($this->objectManager) {
35
+					return;
36
+		}
36 37
 		$this->objectManager = $om;
37 38
 	}
38 39
 
Please login to merge, or discard this patch.
Form/QueryType.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -53,25 +53,25 @@  discard block
 block discarded – undo
53 53
 		$maxChoiceGroupCount = $options['max_choice_group_count'];
54 54
 		$data = array();
55 55
 		
56
-		if($usedFacets && !$result) {
56
+		if ($usedFacets && !$result) {
57 57
 			$data = array();
58
-			foreach($usedFacets as $facetType) {
58
+			foreach ($usedFacets as $facetType) {
59 59
 				$preferredChoices = isset($preferredFilterChoices[$facetType]) ? $preferredFilterChoices[$facetType] : array();
60 60
 				$i = 0;
61
-				$builder->add('facet_' . $facetType, FacetType::class, array(
62
-					'label' => 'stinger_soft_entity_search.forms.query.' . $facetType . '.label',
61
+				$builder->add('facet_'.$facetType, FacetType::class, array(
62
+					'label' => 'stinger_soft_entity_search.forms.query.'.$facetType.'.label',
63 63
 					'multiple' => true,
64 64
 					'expanded' => true,
65 65
 					'allow_extra_fields' => true,
66
-					'preferred_choices' => function ($val) use ($preferredChoices, $data, $facetType, $maxChoiceGroupCount, &$i) {
67
-						return $i++ < $maxChoiceGroupCount || $maxChoiceGroupCount == 0 || in_array($val, $preferredChoices) || (isset($data['facet_' . $facetType]) && in_array($val, $data['facet_' . $facetType]));
66
+					'preferred_choices' => function($val) use ($preferredChoices, $data, $facetType, $maxChoiceGroupCount, &$i) {
67
+						return $i++ < $maxChoiceGroupCount || $maxChoiceGroupCount == 0 || in_array($val, $preferredChoices) || (isset($data['facet_'.$facetType]) && in_array($val, $data['facet_'.$facetType]));
68 68
 					} 
69 69
 				));
70 70
 				unset($i);
71 71
 			}
72 72
 		}
73
-		if($result) {
74
-			$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options, $result) {
73
+		if ($result) {
74
+			$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) use ($options, $result) {
75 75
 				$this->createFacets($event->getForm(), $result->getFacets(), $options, $event->getData());
76 76
 			});
77 77
 		}
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
 		$preferredFilterChoices = $options['preferred_filter_choices'];
109 109
 		$maxChoiceGroupCount = $options['max_choice_group_count'];
110 110
 		$selectedFacets = $data->getFacets();
111
-		foreach($facets->getFacets() as $facetType => $facetValues) {
111
+		foreach ($facets->getFacets() as $facetType => $facetValues) {
112 112
 			$preferredChoices = isset($preferredFilterChoices[$facetType]) ? $preferredFilterChoices[$facetType] : array();
113 113
 			
114 114
 			$i = 0;
115
-			$builder->add('facet_' . $facetType, FacetType::class, array(
116
-				'label' => 'stinger_soft_entity_search.forms.query.' . $facetType . '.label',
115
+			$builder->add('facet_'.$facetType, FacetType::class, array(
116
+				'label' => 'stinger_soft_entity_search.forms.query.'.$facetType.'.label',
117 117
 				'multiple' => true,
118 118
 				'expanded' => true,
119 119
 				'allow_extra_fields' => true,
120 120
 				'choices' => $this->generateFacetChoices($facetType, $facetValues, isset($selectedFacets[$facetType]) ? $selectedFacets[$facetType] : array(), $options['facet_formatter']),
121
-				'preferred_choices' => function ($val) use ($preferredChoices, $selectedFacets, $facetType, $maxChoiceGroupCount, &$i) {
121
+				'preferred_choices' => function($val) use ($preferredChoices, $selectedFacets, $facetType, $maxChoiceGroupCount, &$i) {
122 122
 					return $i++ < $maxChoiceGroupCount || $maxChoiceGroupCount == 0 || in_array($val, $preferredChoices) || (isset($selectedFacets[$facetType]) && in_array($val, $selectedFacets[$facetType]));
123 123
 				} 
124 124
 			));
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	protected function generateFacetChoices($facetType, array $facets, array $selectedFacets = array(), $formatter) {
135 135
 		$choices = array();
136
-		foreach($facets as $facet => $count) {
137
-			if($count == 0 && !in_array($facet, $selectedFacets))
136
+		foreach ($facets as $facet => $count) {
137
+			if ($count == 0 && !in_array($facet, $selectedFacets))
138 138
 				continue;
139 139
 			$choices[$this->formatFacet($formatter, $facetType, $facet, $count)] = $facet;
140 140
 		}
141
-		foreach($selectedFacets as $facet) {
142
-			if(isset($facets[$facet])) continue;
141
+		foreach ($selectedFacets as $facet) {
142
+			if (isset($facets[$facet])) continue;
143 143
 			$count = 0;
144 144
 			$choices[$this->formatFacet($formatter, $facetType, $facet, $count)] = $facet;
145 145
 		}
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 	}
148 148
 	
149 149
 	protected function formatFacet($formatter, $facetType, $facet, $count) {
150
-		$default = $facet . ' (' . $count . ')';
151
-		if(!$formatter) {
150
+		$default = $facet.' ('.$count.')';
151
+		if (!$formatter) {
152 152
 			return $default;
153 153
 		}
154 154
 		return call_user_func($formatter, $facetType, $facet, $count, $default);
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -134,12 +134,15 @@
 block discarded – undo
134 134
 	protected function generateFacetChoices($facetType, array $facets, array $selectedFacets = array(), $formatter) {
135 135
 		$choices = array();
136 136
 		foreach($facets as $facet => $count) {
137
-			if($count == 0 && !in_array($facet, $selectedFacets))
138
-				continue;
137
+			if($count == 0 && !in_array($facet, $selectedFacets)) {
138
+							continue;
139
+			}
139 140
 			$choices[$this->formatFacet($formatter, $facetType, $facet, $count)] = $facet;
140 141
 		}
141 142
 		foreach($selectedFacets as $facet) {
142
-			if(isset($facets[$facet])) continue;
143
+			if(isset($facets[$facet])) {
144
+				continue;
145
+			}
143 146
 			$count = 0;
144 147
 			$choices[$this->formatFacet($formatter, $facetType, $facet, $count)] = $facet;
145 148
 		}
Please login to merge, or discard this patch.