Completed
Push — master ( c3bbaf...3bd11d )
by Florian
12:33
created
Command/SyncCommand.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	protected function execute(InputInterface $input, OutputInterface $output) {
69 69
 		// Detect upload path
70
-		if(!self::$defaultUploadPath) {
70
+		if (!self::$defaultUploadPath) {
71 71
 			$root = $this->getContainer()->get('kernel')->getRootDir();
72
-			self::$defaultUploadPath = $root . '/../web/uploads';
72
+			self::$defaultUploadPath = $root.'/../web/uploads';
73 73
 		}
74 74
 		
75 75
 		// Get the entity argument
76 76
 		$entity = $input->getArgument('entity');
77 77
 		
78
-		if($entity == 'all') {
78
+		if ($entity == 'all') {
79 79
 			/**
80 80
 			 * @var EntityManager $entityManager
81 81
 			 */
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 			/**
92 92
 			 * @var ClassMetadata $m
93 93
 			 */
94
-			foreach($meta as $m) {
94
+			foreach ($meta as $m) {
95 95
 				
96
-				if($m->getReflectionClass()->isAbstract() || $m->getReflectionClass()->isInterface()) {
96
+				if ($m->getReflectionClass()->isAbstract() || $m->getReflectionClass()->isInterface()) {
97 97
 					continue;
98 98
 				}
99
-				if(!$mapper->isClassIndexable($m->getReflectionClass()->getName())) {
99
+				if (!$mapper->isClassIndexable($m->getReflectionClass()->getName())) {
100 100
 					continue;
101 101
 				}
102 102
 				$this->indexEntity($input, $output, $m->getReflectionClass()->getName());
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		try {
118 118
 			// Get repository for the given entity type
119 119
 			$repository = $entityManager->getRepository($entity);
120
-		} catch(\Exception $e) {
120
+		} catch (\Exception $e) {
121 121
 			$output->writeln(sprintf('<error>No repository found for "%s", check your input</error>', $entity));
122 122
 			return;
123 123
 		}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		$useBatch = !($entityManager->getConnection()->getDatabasePlatform() instanceof SQLServerPlatform);
131 131
 		
132 132
 		$iterableResult = $useBatch ? $queryBuilder->getQuery()->iterate() : $queryBuilder->getQuery()->getResult();
133
-		if($entityCount == 0) {
133
+		if ($entityCount == 0) {
134 134
 			$output->writeln('<comment>No entities found for indexing</comment>');
135 135
 			return;
136 136
 		}
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
 		// Index each entity separate
141 141
 		foreach ($iterableResult as $row) {
142 142
 			$entity = $useBatch ? $row[0] : $row;
143
-			if($this->getEntityToDocumentMapper()->isIndexable($entity)) {
143
+			if ($this->getEntityToDocumentMapper()->isIndexable($entity)) {
144 144
 				$document = $this->getEntityToDocumentMapper()->createDocument($entityManager, $entity);
145
-				if($document === false) continue;
145
+				if ($document === false) continue;
146 146
 				$this->getSearchService($entityManager)->saveDocument($document);
147 147
 				$entitiesIndexed++;
148
-				if($entitiesIndexed % 50 == 0) {
148
+				if ($entitiesIndexed % 50 == 0) {
149 149
 					$entityManager->flush();
150 150
 				}
151 151
 			}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		}
154 154
 		$entityManager->flush();
155 155
 		$entityManager->clear();
156
-		$output->writeln('<comment>Indexed ' . $entitiesIndexed . ' entities</comment>');
156
+		$output->writeln('<comment>Indexed '.$entitiesIndexed.' entities</comment>');
157 157
 	}
158 158
 
159 159
 	/**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @return EntityToDocumentMapperInterface
162 162
 	 */
163 163
 	protected function getEntityToDocumentMapper() {
164
-		if(!$this->entityToDocumentMapper) {
164
+		if (!$this->entityToDocumentMapper) {
165 165
 			$this->entityToDocumentMapper = $this->getContainer()->get(EntityToDocumentMapperInterface::SERVICE_ID);
166 166
 		}
167 167
 		return $this->entityToDocumentMapper;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @return SearchService
173 173
 	 */
174 174
 	protected function getSearchService(ObjectManager $manager) {
175
-		if(!$this->searchService) {
175
+		if (!$this->searchService) {
176 176
 			$this->searchService = $this->getContainer()->get(SearchService::SERVICE_ID);
177 177
 		}
178 178
 		$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
@@ -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.