@@ -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': |
@@ -142,7 +142,9 @@ |
||
| 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) { |
@@ -69,15 +69,15 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -34,7 +34,7 @@ |
||
| 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); |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | namespace StingerSoft\EntitySearchBundle\Controller; |
| 10 | 10 | |
| 11 | 11 | use StingerSoft\EntitySearchBundle\Form\QueryType; |
| 12 | -use StingerSoft\EntitySearchBundle\Model\Document; |
|
| 13 | 12 | use StingerSoft\EntitySearchBundle\Model\PaginatableResultSet; |
| 14 | 13 | use StingerSoft\EntitySearchBundle\Model\Query; |
| 15 | 14 | use StingerSoft\EntitySearchBundle\Services\Facet\FacetServiceInterface; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | public function searchAction(Request $request) { |
| 40 | - if($request->query->get('term', false) !== false) { |
|
| 40 | + if ($request->query->get('term', false) !== false) { |
|
| 41 | 41 | $this->setSearchTerm($request->getSession(), $request->query->get('term')); |
| 42 | 42 | return $this->redirectToRoute('stinger_soft_entity_search_search'); |
| 43 | 43 | } |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | )); |
| 54 | 54 | |
| 55 | 55 | $facetForm->handleRequest($request); |
| 56 | - if($facetForm->isSubmitted()) { |
|
| 57 | - if($facetForm->get('clear')->isClicked()) { |
|
| 56 | + if ($facetForm->isSubmitted()) { |
|
| 57 | + if ($facetForm->get('clear')->isClicked()) { |
|
| 58 | 58 | $query->setFacets($this->getDefaultFacets()); |
| 59 | 59 | } |
| 60 | 60 | $this->setSearchTerm($request->getSession(), $query->getSearchTerm()); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $page = $request->query->get('page', 1); |
| 72 | 72 | $results = array(); |
| 73 | - if($result instanceof PaginatableResultSet) { |
|
| 73 | + if ($result instanceof PaginatableResultSet) { |
|
| 74 | 74 | $results = $result->paginate($page, $this->getResultsPerPage()); |
| 75 | 75 | } else { |
| 76 | 76 | $results = $result->getResults(($page - 1) * $this->getResultsPerPage(), $this->getResultsPerPage()); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | protected function getConfiguredUsedFacets(array $queryUsedFacets) { |
| 89 | 89 | $availableFacets = $this->getAvailableFacets(); |
| 90 | 90 | $usedFacets = array(); |
| 91 | - foreach($queryUsedFacets as $queryUsedFacet) { |
|
| 91 | + foreach ($queryUsedFacets as $queryUsedFacet) { |
|
| 92 | 92 | $usedFacets[$queryUsedFacet] = $availableFacets[$queryUsedFacet]; |
| 93 | 93 | } |
| 94 | 94 | return $usedFacets; |
@@ -152,16 +152,16 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | |
| 154 | 154 | protected function initFacets() { |
| 155 | - if(!$this->availableFacets) { |
|
| 155 | + if (!$this->availableFacets) { |
|
| 156 | 156 | $this->availableFacets = array(); |
| 157 | 157 | $this->facetFormatter = array(); |
| 158 | 158 | |
| 159 | 159 | $facetServices = $this->getParameter('stinger_soft.entity_search.available_facets'); |
| 160 | - foreach($facetServices as $facetServiceId) { |
|
| 160 | + foreach ($facetServices as $facetServiceId) { |
|
| 161 | 161 | /** @var FacetServiceInterface $facetService */ |
| 162 | 162 | $facetService = $this->get($facetServiceId); |
| 163 | 163 | $this->availableFacets[$facetService->getField()] = $facetService->getFormOptions(); |
| 164 | - if($facetService->getFacetFormatter()) { |
|
| 164 | + if ($facetService->getFacetFormatter()) { |
|
| 165 | 165 | $this->facetFormatter[$facetService->getField()] = $facetService->getFacetFormatter(); |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @return string[string][] |
| 176 | 176 | */ |
| 177 | 177 | protected function getSearchFacets(SessionInterface $session) { |
| 178 | - $facets = $session->get($this->getSessionPrefix() . '_facets', false); |
|
| 178 | + $facets = $session->get($this->getSessionPrefix().'_facets', false); |
|
| 179 | 179 | return $facets ? json_decode($facets, true) : $this->getDefaultFacets(); |
| 180 | 180 | } |
| 181 | 181 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @param string[string][] $facets |
| 187 | 187 | */ |
| 188 | 188 | protected function setSearchFacets(SessionInterface $session, $facets) { |
| 189 | - $session->set($this->getSessionPrefix() . '_facets', json_encode($facets)); |
|
| 189 | + $session->set($this->getSessionPrefix().'_facets', json_encode($facets)); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @return mixed |
| 197 | 197 | */ |
| 198 | 198 | protected function getSearchTerm(SessionInterface $session) { |
| 199 | - return $session->get($this->getSessionPrefix() . '_term', false); |
|
| 199 | + return $session->get($this->getSessionPrefix().'_term', false); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * @param string $term |
| 207 | 207 | */ |
| 208 | 208 | protected function setSearchTerm(SessionInterface $session, $term) { |
| 209 | - $session->set($this->getSessionPrefix() . '_term', $term); |
|
| 209 | + $session->set($this->getSessionPrefix().'_term', $term); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |