Completed
Push — master ( 3e8b02...37f80c )
by Florian
16:58
created
Tests/Command/SyncCommandTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,8 +43,8 @@
 block discarded – undo
43 43
 			'get' 
44 44
 		))->disableOriginalConstructor()->getMock();
45 45
 		
46
-		$container->method('get')->willReturnCallback(function ($serviceId) use ($that) {
47
-			switch($serviceId) {
46
+		$container->method('get')->willReturnCallback(function($serviceId) use ($that) {
47
+			switch ($serviceId) {
48 48
 				case 'kernel':
49 49
 					return $that;
50 50
 				case 'doctrine.orm.entity_manager':
Please login to merge, or discard this patch.
DependencyInjection/StingerSoftEntitySearchExtension.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
 
35 35
 		$container->setParameter('stinger_soft.entity_search.available_facets', $config['facets']);
36 36
 
37
-		$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
37
+		$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
38 38
 		$loader->load('services.yml');
39 39
 		
40 40
 		$entityToDocumentMapperDefinition = $container->getDefinition(EntityToDocumentMapperInterface::SERVICE_ID);
Please login to merge, or discard this patch.
Controller/SearchControllerTrait.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 namespace StingerSoft\EntitySearchBundle\Controller;
10 10
 
11 11
 use StingerSoft\EntitySearchBundle\Form\QueryType;
12
-use StingerSoft\EntitySearchBundle\Model\Document;
13 12
 use StingerSoft\EntitySearchBundle\Model\PaginatableResultSet;
14 13
 use StingerSoft\EntitySearchBundle\Model\Query;
15 14
 use StingerSoft\EntitySearchBundle\Services\Facet\FacetServiceInterface;
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 
39 39
 	public function searchAction(Request $request) {
40
-		if($request->query->get('term', false) !== false) {
40
+		if ($request->query->get('term', false) !== false) {
41 41
 			$this->setSearchTerm($request->getSession(), $request->query->get('term'));
42 42
 			return $this->redirectToRoute('stinger_soft_entity_search_search');
43 43
 		}
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 		));
54 54
 
55 55
 		$facetForm->handleRequest($request);
56
-		if($facetForm->isSubmitted()) {
57
-			if($facetForm->get('clear')->isClicked()) {
56
+		if ($facetForm->isSubmitted()) {
57
+			if ($facetForm->get('clear')->isClicked()) {
58 58
 				$query->setFacets($this->getDefaultFacets());
59 59
 			}
60 60
 			$this->setSearchTerm($request->getSession(), $query->getSearchTerm());
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 		$page = $request->query->get('page', 1);
72 72
 		$results = array();
73
-		if($result instanceof PaginatableResultSet) {
73
+		if ($result instanceof PaginatableResultSet) {
74 74
 			$results = $result->paginate($page, $this->getResultsPerPage());
75 75
 		} else {
76 76
 			$results = $result->getResults(($page - 1) * $this->getResultsPerPage(), $this->getResultsPerPage());
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	protected function getConfiguredUsedFacets(array $queryUsedFacets) {
89 89
 		$availableFacets = $this->getAvailableFacets();
90 90
 		$usedFacets = array();
91
-		foreach($queryUsedFacets as $queryUsedFacet) {
91
+		foreach ($queryUsedFacets as $queryUsedFacet) {
92 92
 			$usedFacets[$queryUsedFacet] = $availableFacets[$queryUsedFacet];
93 93
 		}
94 94
 		return $usedFacets;
@@ -152,16 +152,16 @@  discard block
 block discarded – undo
152 152
 
153 153
 
154 154
 	protected function initFacets() {
155
-		if(!$this->availableFacets) {
155
+		if (!$this->availableFacets) {
156 156
 			$this->availableFacets = array();
157 157
 			$this->facetFormatter = array();
158 158
 
159 159
 			$facetServices = $this->getParameter('stinger_soft.entity_search.available_facets');
160
-			foreach($facetServices as $facetServiceId) {
160
+			foreach ($facetServices as $facetServiceId) {
161 161
 				/** @var FacetServiceInterface $facetService */
162 162
 				$facetService = $this->get($facetServiceId);
163 163
 				$this->availableFacets[$facetService->getField()] = $facetService->getFormOptions();
164
-				if($facetService->getFacetFormatter()) {
164
+				if ($facetService->getFacetFormatter()) {
165 165
 					$this->facetFormatter[$facetService->getField()] = $facetService->getFacetFormatter();
166 166
 				}
167 167
 			}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 * @return string[string][]
176 176
 	 */
177 177
 	protected function getSearchFacets(SessionInterface $session) {
178
-		$facets = $session->get($this->getSessionPrefix() . '_facets', false);
178
+		$facets = $session->get($this->getSessionPrefix().'_facets', false);
179 179
 		return $facets ? json_decode($facets, true) : $this->getDefaultFacets();
180 180
 	}
181 181
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @param string[string][] $facets
187 187
 	 */
188 188
 	protected function setSearchFacets(SessionInterface $session, $facets) {
189
-		$session->set($this->getSessionPrefix() . '_facets', json_encode($facets));
189
+		$session->set($this->getSessionPrefix().'_facets', json_encode($facets));
190 190
 	}
191 191
 
192 192
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 * @return mixed
197 197
 	 */
198 198
 	protected function getSearchTerm(SessionInterface $session) {
199
-		return $session->get($this->getSessionPrefix() . '_term', false);
199
+		return $session->get($this->getSessionPrefix().'_term', false);
200 200
 	}
201 201
 
202 202
 	/**
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 * @param string $term
207 207
 	 */
208 208
 	protected function setSearchTerm(SessionInterface $session, $term) {
209
-		$session->set($this->getSessionPrefix() . '_term', $term);
209
+		$session->set($this->getSessionPrefix().'_term', $term);
210 210
 	}
211 211
 
212 212
 	/**
Please login to merge, or discard this patch.
Command/SyncCommand.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	protected function execute(InputInterface $input, OutputInterface $output) {
71 71
 		// Detect upload path
72
-		if(!self::$defaultUploadPath) {
72
+		if (!self::$defaultUploadPath) {
73 73
 			$root = $this->getContainer()->get('kernel')->getRootDir();
74
-			self::$defaultUploadPath = $root . '/../web/uploads';
74
+			self::$defaultUploadPath = $root.'/../web/uploads';
75 75
 		}
76 76
 
77 77
 		// Get the entity argument
78 78
 		$entity = $input->getArgument('entity');
79 79
 
80
-		if($entity == 'all') {
80
+		if ($entity == 'all') {
81 81
 			/**
82 82
 			 * @var EntityManager $entityManager
83 83
 			 */
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
 			/**
94 94
 			 * @var ClassMetadata $m
95 95
 			 */
96
-			foreach($meta as $m) {
96
+			foreach ($meta as $m) {
97 97
 
98
-				if($m->getReflectionClass()->isAbstract() || $m->getReflectionClass()->isInterface()) {
98
+				if ($m->getReflectionClass()->isAbstract() || $m->getReflectionClass()->isInterface()) {
99 99
 					continue;
100 100
 				}
101
-				if(!$mapper->isClassIndexable($m->getReflectionClass()->getName())) {
101
+				if (!$mapper->isClassIndexable($m->getReflectionClass()->getName())) {
102 102
 					continue;
103 103
 				}
104 104
 				$this->indexEntity($input, $output, $m->getReflectionClass()->getName());
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		try {
120 120
 			// Get repository for the given entity type
121 121
 			$repository = $entityManager->getRepository($entity);
122
-		} catch(\Exception $e) {
122
+		} catch (\Exception $e) {
123 123
 			$output->writeln(sprintf('<error>No repository found for "%s", check your input</error>', $entity));
124 124
 			return;
125 125
 		}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		$useBatch = !($entityManager->getConnection()->getDatabasePlatform() instanceof SQLServerPlatform);
133 133
 
134 134
 		$iterableResult = $useBatch ? $queryBuilder->getQuery()->iterate() : $queryBuilder->getQuery()->getResult();
135
-		if($entityCount == 0) {
135
+		if ($entityCount == 0) {
136 136
 			$output->writeln('<comment>No entities found for indexing</comment>');
137 137
 			return;
138 138
 		}
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
 		$entitiesIndexed = 0;
141 141
 
142 142
 		// Index each entity separate
143
-		foreach($iterableResult as $row) {
143
+		foreach ($iterableResult as $row) {
144 144
 			$entity = $useBatch ? $row[0] : $row;
145
-			if($this->getEntityToDocumentMapper()->isIndexable($entity)) {
145
+			if ($this->getEntityToDocumentMapper()->isIndexable($entity)) {
146 146
 				$document = $this->getEntityToDocumentMapper()->createDocument($entityManager, $entity);
147
-				if($document === false) continue;
147
+				if ($document === false) continue;
148 148
 				try {
149 149
 					$this->getSearchService($entityManager)->saveDocument($document);
150 150
 					$entitiesIndexed++;
151
-				} catch(\Exception $e) {
152
-					$output->writeln('<error>Failed to index entity with ID ' . $document->getEntityId() . '</error>');
151
+				} catch (\Exception $e) {
152
+					$output->writeln('<error>Failed to index entity with ID '.$document->getEntityId().'</error>');
153 153
 				}
154
-				if($entitiesIndexed % 50 == 0) {
154
+				if ($entitiesIndexed % 50 == 0) {
155 155
 					$entityManager->flush();
156 156
 				}
157 157
 			}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		}
160 160
 		$entityManager->flush();
161 161
 		$entityManager->clear();
162
-		$output->writeln('<comment>Indexed ' . $entitiesIndexed . ' entities</comment>');
162
+		$output->writeln('<comment>Indexed '.$entitiesIndexed.' entities</comment>');
163 163
 	}
164 164
 
165 165
 	/**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @return EntityToDocumentMapperInterface
168 168
 	 */
169 169
 	protected function getEntityToDocumentMapper() {
170
-		if(!$this->entityToDocumentMapper) {
170
+		if (!$this->entityToDocumentMapper) {
171 171
 			$this->entityToDocumentMapper = $this->getContainer()->get(EntityToDocumentMapperInterface::SERVICE_ID);
172 172
 		}
173 173
 		return $this->entityToDocumentMapper;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @return SearchService
179 179
 	 */
180 180
 	protected function getSearchService(ObjectManager $manager) {
181
-		if(!$this->searchService) {
181
+		if (!$this->searchService) {
182 182
 			$this->searchService = $this->getContainer()->get(SearchService::SERVICE_ID);
183 183
 		}
184 184
 		$this->searchService->setObjectManager($manager);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -144,7 +144,9 @@
 block discarded – undo
144 144
 			$entity = $useBatch ? $row[0] : $row;
145 145
 			if($this->getEntityToDocumentMapper()->isIndexable($entity)) {
146 146
 				$document = $this->getEntityToDocumentMapper()->createDocument($entityManager, $entity);
147
-				if($document === false) continue;
147
+				if($document === false) {
148
+					continue;
149
+				}
148 150
 				try {
149 151
 					$this->getSearchService($entityManager)->saveDocument($document);
150 152
 					$entitiesIndexed++;
Please login to merge, or discard this patch.