@@ -54,7 +54,7 @@ |
||
54 | 54 | * |
55 | 55 | * @see \StingerSoft\EntitySearchBundle\Model\SearchableEntity::indexEntity() |
56 | 56 | */ |
57 | - public function indexEntity(Document &$document) { |
|
57 | + public function indexEntity(Document&$document) { |
|
58 | 58 | $document->addField(Document::FIELD_TITLE, $this->getTitle()); |
59 | 59 | return self::$index; |
60 | 60 | } |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | * @see \StingerSoft\EntitySearchBundle\Model\Document::addMultiValueField() |
82 | 82 | */ |
83 | 83 | public function addMultiValueField($field, $value) { |
84 | - if(!array_key_exists($field, $this->fields)) { |
|
84 | + if (!array_key_exists($field, $this->fields)) { |
|
85 | 85 | $this->fields[$field] = array( |
86 | 86 | $value |
87 | 87 | ); |
88 | - } else if(!in_array($value, $this->fields[$field])) { |
|
88 | + } else if (!in_array($value, $this->fields[$field])) { |
|
89 | 89 | $this->fields[$field][] = $value; |
90 | 90 | } |
91 | 91 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function setEntityClass($clazz) { |
100 | 100 | $this->entityClass = $clazz; |
101 | - if(!$this->entityType) { |
|
101 | + if (!$this->entityType) { |
|
102 | 102 | $this->entityType = $clazz; |
103 | 103 | } |
104 | 104 | } |
@@ -34,10 +34,10 @@ |
||
34 | 34 | public function getEntity(Document $document) { |
35 | 35 | $clazz = $document->getEntityClass(); |
36 | 36 | |
37 | - if($clazz == null) { |
|
37 | + if ($clazz == null) { |
|
38 | 38 | return null; |
39 | 39 | } |
40 | - if(!$document->getEntityId()) { |
|
40 | + if (!$document->getEntityId()) { |
|
41 | 41 | return null; |
42 | 42 | } |
43 | 43 | return $this->managerRegistry->getManagerForClass($clazz)->getRepository($clazz)->find($document->getEntityId()); |
@@ -92,6 +92,7 @@ discard block |
||
92 | 92 | * The name of the field |
93 | 93 | * @param mixed $value |
94 | 94 | * The value of this field |
95 | + * @return void |
|
95 | 96 | */ |
96 | 97 | public function addField($fieldname, $value); |
97 | 98 | |
@@ -120,6 +121,7 @@ discard block |
||
120 | 121 | * The name of the field |
121 | 122 | * @param mixed $value |
122 | 123 | * The additional value of this field |
124 | + * @return void |
|
123 | 125 | */ |
124 | 126 | public function addMultiValueField($field, $value); |
125 | 127 | |
@@ -131,6 +133,7 @@ discard block |
||
131 | 133 | * |
132 | 134 | * @param string $clazz |
133 | 135 | * The classname |
136 | + * @return void |
|
134 | 137 | */ |
135 | 138 | public function setEntityClass($clazz); |
136 | 139 | |
@@ -150,6 +153,7 @@ discard block |
||
150 | 153 | * |
151 | 154 | * @param mixed $id |
152 | 155 | * The ID of the corresponding entity |
156 | + * @return void |
|
153 | 157 | */ |
154 | 158 | public function setEntityId($id); |
155 | 159 | |
@@ -166,6 +170,7 @@ discard block |
||
166 | 170 | * hiding some programatically needed complexity from the user |
167 | 171 | * |
168 | 172 | * @param string $type |
173 | + * @return void |
|
169 | 174 | */ |
170 | 175 | public function setEntityType($type); |
171 | 176 | |
@@ -176,7 +181,7 @@ discard block |
||
176 | 181 | * |
177 | 182 | * If no entity type is set, the class will be used instead |
178 | 183 | * |
179 | - * @param return $type |
|
184 | + * @return string |
|
180 | 185 | */ |
181 | 186 | public function getEntityType(); |
182 | 187 | |
@@ -186,6 +191,7 @@ discard block |
||
186 | 191 | * <strong>note:</strong> This may not supported by the underlying implementation |
187 | 192 | * |
188 | 193 | * @param string $path |
194 | + * @return void |
|
189 | 195 | */ |
190 | 196 | public function setFile($path); |
191 | 197 |
@@ -67,15 +67,15 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $entityCount = $countQueryBuilder->getQuery()->getSingleScalarResult(); |
129 | 129 | |
130 | 130 | $iterableResult = $queryBuilder->getQuery()->iterate(); |
131 | - if($entityCount == 0) { |
|
131 | + if ($entityCount == 0) { |
|
132 | 132 | $output->writeln('<comment>No entities found for indexing</comment>'); |
133 | 133 | return; |
134 | 134 | } |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | // Index each entity seperate |
139 | 139 | foreach ($iterableResult as $row) { |
140 | 140 | $entity = $row[0]; |
141 | - if($this->getEntityToDocumentMapper()->isIndexable($entity)) { |
|
141 | + if ($this->getEntityToDocumentMapper()->isIndexable($entity)) { |
|
142 | 142 | $document = $this->getEntityToDocumentMapper()->createDocument($entityManager, $entity); |
143 | - if($document === false) continue; |
|
143 | + if ($document === false) continue; |
|
144 | 144 | $this->getSearchService($entityManager)->saveDocument($document); |
145 | 145 | $entitiesIndexed++; |
146 | - if($entitiesIndexed % 50 == 0) { |
|
146 | + if ($entitiesIndexed % 50 == 0) { |
|
147 | 147 | $entityManager->flush(); |
148 | 148 | } |
149 | 149 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | $entityManager->flush(); |
153 | 153 | $entityManager->clear(); |
154 | - $output->writeln('<comment>Indexed ' . $entitiesIndexed . ' entities</comment>'); |
|
154 | + $output->writeln('<comment>Indexed '.$entitiesIndexed.' entities</comment>'); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @return EntityToDocumentMapperInterface |
160 | 160 | */ |
161 | 161 | protected function getEntityToDocumentMapper() { |
162 | - if(!$this->entityToDocumentMapper) { |
|
162 | + if (!$this->entityToDocumentMapper) { |
|
163 | 163 | $this->entityToDocumentMapper = $this->getContainer()->get(EntityToDocumentMapperInterface::SERVICE_ID); |
164 | 164 | } |
165 | 165 | return $this->entityToDocumentMapper; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @return SearchService |
171 | 171 | */ |
172 | 172 | protected function getSearchService(ObjectManager $manager) { |
173 | - if(!$this->searchService) { |
|
173 | + if (!$this->searchService) { |
|
174 | 174 | $this->searchService = $this->getContainer()->get(SearchService::SERVICE_ID); |
175 | 175 | } |
176 | 176 | $this->searchService->setObjectManager($manager); |
@@ -140,7 +140,9 @@ |
||
140 | 140 | $entity = $row[0]; |
141 | 141 | if($this->getEntityToDocumentMapper()->isIndexable($entity)) { |
142 | 142 | $document = $this->getEntityToDocumentMapper()->createDocument($entityManager, $entity); |
143 | - if($document === false) continue; |
|
143 | + if($document === false) { |
|
144 | + continue; |
|
145 | + } |
|
144 | 146 | $this->getSearchService($entityManager)->saveDocument($document); |
145 | 147 | $entitiesIndexed++; |
146 | 148 | if($entitiesIndexed % 50 == 0) { |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | // application.php |
3 | -require __DIR__ . '/../vendor/autoload.php'; |
|
3 | +require __DIR__.'/../vendor/autoload.php'; |
|
4 | 4 | |
5 | 5 | use StingerSoft\EntitySearchBundle\Command\ClearIndexCommand; |
6 | 6 | use StingerSoft\EntitySearchBundle\Command\SyncCommand; |
@@ -43,8 +43,8 @@ |
||
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': |