Completed
Push — master ( 904bc9...a0bca2 )
by Florian
03:02
created
Model/Query.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	 * @return \Pec\Bundle\MtuDvpBundle\Entity\TestRiskValue
91 91
 	 */
92 92
 	public function __get($name) {
93
-		if(strrpos($name, 'facet_', -strlen($name)) !== false) {
93
+		if (strrpos($name, 'facet_', -strlen($name)) !== false) {
94 94
 			$facetname = substr($name, 6);
95 95
 			
96
-			if(isset($this->facets[$facetname])) {
96
+			if (isset($this->facets[$facetname])) {
97 97
 				return $this->facets[$facetname];
98 98
 			}
99 99
 			return array();
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 *        	The value of the property
109 109
 	 */
110 110
 	public function __set($name, $value) {
111
-		if(strrpos($name, 'facet_', -strlen($name)) !== false) {
111
+		if (strrpos($name, 'facet_', -strlen($name)) !== false) {
112 112
 			$facetname = substr($name, 6);
113 113
 			
114
-			if(isset($this->facets[$facetname])) {
114
+			if (isset($this->facets[$facetname])) {
115 115
 				$this->facets[$facetname] = array();
116 116
 			}
117 117
 			$this->facets[$facetname] = $value;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * @return boolean
126 126
 	 */
127 127
 	public function __isset($name) {
128
-		if(strrpos($name, 'facet_', -strlen($name)) !== false) {
128
+		if (strrpos($name, 'facet_', -strlen($name)) !== false) {
129 129
 			return true;
130 130
 		}
131 131
 		
Please login to merge, or discard this patch.
Form/FacetChoiceLoader.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 	public function loadValuesForChoices(array $choices, $value = null) {
40 40
 		// is called on form creat with $choices containing the preset of the bound entity
41 41
 		$values = array();
42
-		foreach($choices as $key => $choice) {
42
+		foreach ($choices as $key => $choice) {
43 43
 			// we use a DataTransformer, thus only plain values arrive as choices which can be used directly as value
44
-			if(is_callable($value)) {
44
+			if (is_callable($value)) {
45 45
 				$values[$key] = (string)call_user_func($value, $choice, $key);
46 46
 			} else {
47 47
 				$values[$key] = $choice;
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	public function loadChoicesForValues(array $values, $value = null) {
86 86
 		// is called on form submit after loadValuesForChoices of form create and loadChoiceList of form view create
87 87
 		$choices = array();
88
-		foreach($values as $key => $val) {
88
+		foreach ($values as $key => $val) {
89 89
 			// we use a DataTransformer, thus only plain values arrive as choices which can be used directly as value
90
-			if(is_callable($value)) {
90
+			if (is_callable($value)) {
91 91
 				$choices[$key] = (string)call_user_func($value, $val, $key);
92 92
 			} else {
93 93
 				$choices[$key] = $val;
Please login to merge, or discard this patch.
Tests/Form/QueryTypeTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@
 block discarded – undo
116 116
 		$view = $form->createView();
117 117
 		$children = $view->children;
118 118
 		
119
-		foreach(array_keys($formData) as $key) {
119
+		foreach (array_keys($formData) as $key) {
120 120
 			$this->assertArrayHasKey($key, $children);
121 121
 		}
122 122
 		
Please login to merge, or discard this patch.
Tests/Model/Result/FacetSetAdapterTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 class FacetSetAdapterTest extends \PHPUnit_Framework_TestCase {
18 18
 
19
-	public function testAddFacetValue(){
19
+	public function testAddFacetValue() {
20 20
 		$facets = new FacetSetAdapter(array());
21 21
 		$this->assertCount(0, $facets);
22 22
 		$facets->addFacetValue(Document::FIELD_AUTHOR, 'Oliver Kotte');
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 		$this->assertCount(1, $facets);
27 27
 		$this->assertCount(2, $facets->getFacet(Document::FIELD_AUTHOR));
28 28
 		
29
-		foreach($facets as $facetKey => $facetValues){
29
+		foreach ($facets as $facetKey => $facetValues) {
30 30
 			$this->assertEquals(Document::FIELD_AUTHOR, $facetKey);
31 31
 			$this->assertCount(2, $facetValues);
32 32
 		}
33 33
 	}
34 34
 	
35
-	public function testGetFacet(){
35
+	public function testGetFacet() {
36 36
 		$facets = new FacetSetAdapter(array());
37 37
 		$this->assertCount(0, $facets);
38 38
 		$this->assertNull($facets->getFacet('NotExisting'));
Please login to merge, or discard this patch.
Form/FacetType.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 		$builder->resetModelTransformers();
32 32
 		$builder->resetViewTransformers();
33 33
 		
34
-		if($options['multiple']) {
35
-			$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
34
+		if ($options['multiple']) {
35
+			$builder->addEventListener(FormEvents::PRE_SUBMIT, function(FormEvent $event) {
36 36
 				$event->stopPropagation();
37 37
 			}, 1);
38 38
 		}
39
-		$builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) {
39
+		$builder->addEventListener(FormEvents::SUBMIT, function(FormEvent $event) {
40 40
 			$data = $event->getForm()->getExtraData();
41 41
 			$event->setData(array_unique(array_merge($data, $event->getData())));
42 42
 		});
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	public function configureOptions(OptionsResolver $resolver) {
62 62
 		$resolver->setDefault('translation_domain', 'StingerSoftEntitySearchBundle');
63 63
 		$resolver->setDefault('by_reference', true);
64
-		if(Kernel::VERSION_ID < 30000) {
64
+		if (Kernel::VERSION_ID < 30000) {
65 65
 			$resolver->setDefault('choices_as_values', true);
66 66
 		}
67 67
 	}
Please login to merge, or discard this patch.
Services/DoctrineListener.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 	 * @param LifecycleEventArgs $args        	
74 74
 	 */
75 75
 	public function postPersist(LifecycleEventArgs $args) {
76
-		if(!$this->enableIndexing) return;
76
+		if (!$this->enableIndexing) return;
77 77
 		$this->updateEntity($args->getObject(), $args->getObjectManager());
78 78
 	}
79 79
 
80 80
 	public function postFlush(PostFlushEventArgs $eventArgs) {
81
-		if($this->needsFlush) {
81
+		if ($this->needsFlush) {
82 82
 			$this->needsFlush = false;
83 83
 			$eventArgs->getEntityManager()->flush();
84 84
 		}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param LifecycleEventArgs $args        	
91 91
 	 */
92 92
 	public function preRemove(LifecycleEventArgs $args) {
93
-		if(!$this->enableIndexing) return;
93
+		if (!$this->enableIndexing) return;
94 94
 		$this->removeEntity($args->getObject(), $args->getObjectManager());
95 95
 	}
96 96
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param LifecycleEventArgs $args        	
101 101
 	 */
102 102
 	public function postUpdate(LifecycleEventArgs $args) {
103
-		if(!$this->enableIndexing) return;
103
+		if (!$this->enableIndexing) return;
104 104
 		$this->updateEntity($args->getObject(), $args->getObjectManager());
105 105
 	}
106 106
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	protected function updateEntity($entity, ObjectManager $manager) {
129 129
 		$document = $this->getEntityToDocumentMapper()->createDocument($manager, $entity);
130
-		if($document !== false) {
130
+		if ($document !== false) {
131 131
 			$this->getSearchService($manager)->saveDocument($document);
132 132
 		}
133 133
 	}
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	protected function removeEntity($entity, ObjectManager $manager) {
140 140
 		$document = $this->getEntityToDocumentMapper()->createDocument($manager, $entity);
141
-		if($document !== false) {
141
+		if ($document !== false) {
142 142
 			$this->getSearchService($manager)->removeDocument($document);
143 143
 		}
144 144
 	}
Please login to merge, or discard this patch.
Services/AbstractSearchService.php 1 patch
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.
Form/QueryType.php 1 patch
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.