@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | $builder->resetModelTransformers(); |
32 | 32 | $builder->resetViewTransformers(); |
33 | 33 | |
34 | - if($options['multiple']) { |
|
35 | - $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { |
|
34 | + if ($options['multiple']) { |
|
35 | + $builder->addEventListener(FormEvents::PRE_SUBMIT, function(FormEvent $event) { |
|
36 | 36 | $event->stopPropagation(); |
37 | 37 | }, 1); |
38 | 38 | } |
39 | - $builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) { |
|
39 | + $builder->addEventListener(FormEvents::SUBMIT, function(FormEvent $event) { |
|
40 | 40 | $data = $event->getForm()->getExtraData(); |
41 | 41 | //$event->setData(array_unique(array_merge($data, $event->getData()))); |
42 | 42 | $event->setData($data); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public function configureOptions(OptionsResolver $resolver) { |
63 | 63 | $resolver->setDefault('translation_domain', 'StingerSoftEntitySearchBundle'); |
64 | 64 | $resolver->setDefault('by_reference', true); |
65 | - if(Kernel::VERSION_ID < 30000) { |
|
65 | + if (Kernel::VERSION_ID < 30000) { |
|
66 | 66 | $resolver->setDefault('choices_as_values', true); |
67 | 67 | } |
68 | 68 | } |
@@ -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 | } |
@@ -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,14 +117,14 @@ 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 | } |
124 | 124 | |
125 | 125 | // Get all entities |
126 | 126 | $entities = $repository->findAll(); |
127 | - if(count($entities) == 0) { |
|
127 | + if (count($entities) == 0) { |
|
128 | 128 | $output->writeln('<comment>No entities found for indexing</comment>'); |
129 | 129 | return; |
130 | 130 | } |
@@ -132,20 +132,20 @@ discard block |
||
132 | 132 | $entitiesIndexed = 0; |
133 | 133 | |
134 | 134 | // Index each entity seperate |
135 | - foreach($entities as $entity) { |
|
136 | - if($this->getEntityToDocumentMapper()->isIndexable($entity)) { |
|
135 | + foreach ($entities as $entity) { |
|
136 | + if ($this->getEntityToDocumentMapper()->isIndexable($entity)) { |
|
137 | 137 | $document = $this->getEntityToDocumentMapper()->createDocument($entityManager, $entity); |
138 | - if($document === false) continue; |
|
138 | + if ($document === false) continue; |
|
139 | 139 | $this->getSearchService($entityManager)->saveDocument($document); |
140 | 140 | $entitiesIndexed++; |
141 | - if($entitiesIndexed % 50 == 0) { |
|
141 | + if ($entitiesIndexed % 50 == 0) { |
|
142 | 142 | $entityManager->flush(); |
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | 146 | } |
147 | 147 | $entityManager->flush(); |
148 | - $output->writeln('<comment>Indexed ' . $entitiesIndexed . ' entities</comment>'); |
|
148 | + $output->writeln('<comment>Indexed '.$entitiesIndexed.' entities</comment>'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return EntityToDocumentMapperInterface |
154 | 154 | */ |
155 | 155 | protected function getEntityToDocumentMapper() { |
156 | - if(!$this->entityToDocumentMapper) { |
|
156 | + if (!$this->entityToDocumentMapper) { |
|
157 | 157 | $this->entityToDocumentMapper = $this->getContainer()->get(EntityToDocumentMapperInterface::SERVICE_ID); |
158 | 158 | } |
159 | 159 | return $this->entityToDocumentMapper; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @return SearchService |
165 | 165 | */ |
166 | 166 | protected function getSearchService(ObjectManager $manager) { |
167 | - if(!$this->searchService) { |
|
167 | + if (!$this->searchService) { |
|
168 | 168 | $this->searchService = $this->getContainer()->get(SearchService::SERVICE_ID); |
169 | 169 | } |
170 | 170 | $this->searchService->setObjectManager($manager); |
@@ -135,7 +135,9 @@ |
||
135 | 135 | foreach($entities as $entity) { |
136 | 136 | if($this->getEntityToDocumentMapper()->isIndexable($entity)) { |
137 | 137 | $document = $this->getEntityToDocumentMapper()->createDocument($entityManager, $entity); |
138 | - if($document === false) continue; |
|
138 | + if($document === false) { |
|
139 | + continue; |
|
140 | + } |
|
139 | 141 | $this->getSearchService($entityManager)->saveDocument($document); |
140 | 142 | $entitiesIndexed++; |
141 | 143 | if($entitiesIndexed % 50 == 0) { |
@@ -85,6 +85,7 @@ discard block |
||
85 | 85 | * The name of the field |
86 | 86 | * @param mixed $value |
87 | 87 | * The value of this field |
88 | + * @return void |
|
88 | 89 | */ |
89 | 90 | public function addField($fieldname, $value); |
90 | 91 | |
@@ -113,6 +114,7 @@ discard block |
||
113 | 114 | * The name of the field |
114 | 115 | * @param mixed $value |
115 | 116 | * The additional value of this field |
117 | + * @return void |
|
116 | 118 | */ |
117 | 119 | public function addMultiValueField($field, $value); |
118 | 120 | |
@@ -124,6 +126,7 @@ discard block |
||
124 | 126 | * |
125 | 127 | * @param string $clazz |
126 | 128 | * The classname |
129 | + * @return void |
|
127 | 130 | */ |
128 | 131 | public function setEntityClass($clazz); |
129 | 132 | |
@@ -143,6 +146,7 @@ discard block |
||
143 | 146 | * |
144 | 147 | * @param mixed $id |
145 | 148 | * The ID of the corresponding entity |
149 | + * @return void |
|
146 | 150 | */ |
147 | 151 | public function setEntityId($id); |
148 | 152 | |
@@ -159,6 +163,7 @@ discard block |
||
159 | 163 | * hiding some programatically needed complexity from the user |
160 | 164 | * |
161 | 165 | * @param string $type |
166 | + * @return void |
|
162 | 167 | */ |
163 | 168 | public function setEntityType($type); |
164 | 169 | |
@@ -169,7 +174,7 @@ discard block |
||
169 | 174 | * |
170 | 175 | * If no entity type is set, the class will be used instead |
171 | 176 | * |
172 | - * @param return $type |
|
177 | + * @return string |
|
173 | 178 | */ |
174 | 179 | public function getEntityType(); |
175 | 180 | |
@@ -179,6 +184,7 @@ discard block |
||
179 | 184 | * <strong>note:</strong> This may not supported by the underlying implementation |
180 | 185 | * |
181 | 186 | * @param string $path |
187 | + * @return void |
|
182 | 188 | */ |
183 | 189 | public function setFile($path); |
184 | 190 |