Completed
Push — master ( 3a384d...f26e19 )
by Florian
02:45
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.
Command/SyncCommand.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -142,7 +142,9 @@
 block discarded – undo
142 142
 			$entity = $useBatch ? $row[0] : $row;
143 143
 			if($this->getEntityToDocumentMapper()->isIndexable($entity)) {
144 144
 				$document = $this->getEntityToDocumentMapper()->createDocument($entityManager, $entity);
145
-				if($document === false) continue;
145
+				if($document === false) {
146
+					continue;
147
+				}
146 148
 				$this->getSearchService($entityManager)->saveDocument($document);
147 149
 				$entitiesIndexed++;
148 150
 				if($entitiesIndexed % 50 == 0) {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 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,14 +140,14 @@  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
 				$this->getSearchService($entityManager)->saveDocument($document);
149 149
 				$entitiesIndexed++;
150
-				if($entitiesIndexed % 50 == 0) {
150
+				if ($entitiesIndexed % 50 == 0) {
151 151
 					$entityManager->flush();
152 152
 				}
153 153
 			}
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		}
156 156
 		$entityManager->flush();
157 157
 		$entityManager->clear();
158
-		$output->writeln('<comment>Indexed ' . $entitiesIndexed . ' entities</comment>');
158
+		$output->writeln('<comment>Indexed '.$entitiesIndexed.' entities</comment>');
159 159
 	}
160 160
 
161 161
 	/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @return EntityToDocumentMapperInterface
164 164
 	 */
165 165
 	protected function getEntityToDocumentMapper() {
166
-		if(!$this->entityToDocumentMapper) {
166
+		if (!$this->entityToDocumentMapper) {
167 167
 			$this->entityToDocumentMapper = $this->getContainer()->get(EntityToDocumentMapperInterface::SERVICE_ID);
168 168
 		}
169 169
 		return $this->entityToDocumentMapper;
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @return SearchService
175 175
 	 */
176 176
 	protected function getSearchService(ObjectManager $manager) {
177
-		if(!$this->searchService) {
177
+		if (!$this->searchService) {
178 178
 			$this->searchService = $this->getContainer()->get(SearchService::SERVICE_ID);
179 179
 		}
180 180
 		$this->searchService->setObjectManager($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.