Completed
Push — master ( e5e78d...6c2a09 )
by Florian
10:13
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,11 +91,11 @@  discard block
 block discarded – undo
91 91
 			/**
92 92
 			 * @var ClassMetadata $m
93 93
 			 */
94
-			foreach($meta as $m) {
95
-				if($m->getReflectionClass()->isAbstract() || $m->getReflectionClass()->isInterface()) {
94
+			foreach ($meta as $m) {
95
+				if ($m->getReflectionClass()->isAbstract() || $m->getReflectionClass()->isInterface()) {
96 96
 					continue;
97 97
 				}
98
-				if(!$mapper->isClassIndexable($m->getReflectionClass()->getName())) {
98
+				if (!$mapper->isClassIndexable($m->getReflectionClass()->getName())) {
99 99
 					continue;
100 100
 				}
101 101
 				$this->indexEntity($input, $output, $m->getReflectionClass()->getName());
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 		try {
117 117
 			// Get repository for the given entity type
118 118
 			$repository = $entityManager->getRepository($entity);
119
-		} catch(\Exception $e) {
119
+		} catch (\Exception $e) {
120 120
 			$output->writeln(sprintf('<error>No repository found for "%s", check your input</error>', $entity));
121 121
 			return;
122 122
 		}
123 123
 		
124 124
 		// Get all entities
125 125
 		$entities = $repository->findAll();
126
-		if(count($entities) == 0) {
126
+		if (count($entities) == 0) {
127 127
 			$output->writeln('<comment>No entities found for indexing</comment>');
128 128
 			return;
129 129
 		}
@@ -131,15 +131,15 @@  discard block
 block discarded – undo
131 131
 		$entitiesIndexed = 0;
132 132
 		
133 133
 		// Index each entity seperate
134
-		foreach($entities as $entity) {
135
-			if($this->getEntityToDocumentMapper()->isIndexable($entity)) {
134
+		foreach ($entities as $entity) {
135
+			if ($this->getEntityToDocumentMapper()->isIndexable($entity)) {
136 136
 				$document = $this->getEntityToDocumentMapper()->createDocument($entityManager, $entity);
137
-				if($document === false) continue;
137
+				if ($document === false) continue;
138 138
 				$this->getSearchService($entityManager)->saveDocument($document);
139 139
 				$entitiesIndexed++;
140 140
 			}
141 141
 		}
142
-		$output->writeln('<comment>Indexed ' . $entitiesIndexed . ' entities</comment>');
142
+		$output->writeln('<comment>Indexed '.$entitiesIndexed.' entities</comment>');
143 143
 	}
144 144
 
145 145
 	/**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return EntityToDocumentMapperInterface
148 148
 	 */
149 149
 	protected function getEntityToDocumentMapper() {
150
-		if(!$this->entityToDocumentMapper) {
150
+		if (!$this->entityToDocumentMapper) {
151 151
 			$this->entityToDocumentMapper = $this->getContainer()->get(EntityToDocumentMapperInterface::SERVICE_ID);
152 152
 		}
153 153
 		return $this->entityToDocumentMapper;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @return SearchService
159 159
 	 */
160 160
 	protected function getSearchService(ObjectManager $manager) {
161
-		if(!$this->searchService) {
161
+		if (!$this->searchService) {
162 162
 			$this->searchService = $this->getContainer()->get(SearchService::SERVICE_ID);
163 163
 		}
164 164
 		$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
@@ -134,7 +134,9 @@
 block discarded – undo
134 134
 		foreach($entities as $entity) {
135 135
 			if($this->getEntityToDocumentMapper()->isIndexable($entity)) {
136 136
 				$document = $this->getEntityToDocumentMapper()->createDocument($entityManager, $entity);
137
-				if($document === false) continue;
137
+				if($document === false) {
138
+					continue;
139
+				}
138 140
 				$this->getSearchService($entityManager)->saveDocument($document);
139 141
 				$entitiesIndexed++;
140 142
 			}
Please login to merge, or discard this patch.