@@ -16,7 +16,6 @@ |
||
| 16 | 16 | use StingerSoft\EntitySearchBundle\Model\ResultSetAdapter; |
| 17 | 17 | use StingerSoft\EntitySearchBundle\Model\Result\FacetSetAdapter; |
| 18 | 18 | use StingerSoft\EntitySearchBundle\Model\Result\FacetSet; |
| 19 | -use StingerSoft\EntitySearchBundle\Model\Result\FacetAdapter; |
|
| 20 | 19 | |
| 21 | 20 | class DummySearchService extends AbstractSearchService { |
| 22 | 21 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $id = $document->getEntityClass(); |
| 31 | 31 | $id .= '#'; |
| 32 | 32 | $entityId = $document->getEntityId(); |
| 33 | - if(is_scalar($entityId)) { |
|
| 33 | + if (is_scalar($entityId)) { |
|
| 34 | 34 | $id .= $entityId; |
| 35 | 35 | } else { |
| 36 | 36 | $id .= md5(serialize($entityId)); |
@@ -76,15 +76,15 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function autocomplete($search, $maxResults = 10) { |
| 78 | 78 | $words = array(); |
| 79 | - foreach($this->index as $doc) { |
|
| 80 | - foreach($doc->getFields() as $content) { |
|
| 81 | - if(is_string($content)) { |
|
| 79 | + foreach ($this->index as $doc) { |
|
| 80 | + foreach ($doc->getFields() as $content) { |
|
| 81 | + if (is_string($content)) { |
|
| 82 | 82 | $words = array_merge($words, explode(' ', $content)); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - return array_filter($words, function ($word) use ($search) { |
|
| 87 | + return array_filter($words, function($word) use ($search) { |
|
| 88 | 88 | return stripos($word, $search) === 0; |
| 89 | 89 | }); |
| 90 | 90 | } |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | $hits = array(); |
| 106 | - foreach($this->index as $key => $doc) { |
|
| 107 | - foreach($doc->getFields() as $content) { |
|
| 108 | - if(is_string($content) && stripos($content, $term) !== false) { |
|
| 109 | - if(!isset($hits[$key])) { |
|
| 106 | + foreach ($this->index as $key => $doc) { |
|
| 107 | + foreach ($doc->getFields() as $content) { |
|
| 108 | + if (is_string($content) && stripos($content, $term) !== false) { |
|
| 109 | + if (!isset($hits[$key])) { |
|
| 110 | 110 | $hits[$key] = 0; |
| 111 | 111 | } |
| 112 | 112 | $hits[$key] = $hits[$key] + 1; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | arsort($hits); |
| 117 | 117 | $results = array(); |
| 118 | - foreach(array_keys($hits) as $docId){ |
|
| 118 | + foreach (array_keys($hits) as $docId) { |
|
| 119 | 119 | $doc = $this->index[$docId]; |
| 120 | 120 | $facets->addFacetValue(FacetSet::FACET_ENTITY_TYPE, $doc->getEntityClass()); |
| 121 | 121 | $facets->addFacetValue(FacetSet::FACET_AUTHOR, $doc->getFieldValue(Document::FIELD_AUTHOR)); |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | /** |
| 54 | 54 | * @param Document[] $results |
| 55 | 55 | */ |
| 56 | - public function setResults(array $results){ |
|
| 56 | + public function setResults(array $results) { |
|
| 57 | 57 | $this->results = $results; |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | \ No newline at end of file |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function addFacetValue($key, $value, $increaseCounterBy = 1) { |
| 33 | - if(!isset($this->facets[$key])){ |
|
| 33 | + if (!isset($this->facets[$key])) { |
|
| 34 | 34 | $this->facets[$key] = array(); |
| 35 | 35 | } |
| 36 | - if(!isset($this->facets[$key][$value])){ |
|
| 36 | + if (!isset($this->facets[$key][$value])) { |
|
| 37 | 37 | $this->facets[$key][$value] = 0; |
| 38 | 38 | } |
| 39 | 39 | $this->facets[$key][$value] = $this->facets[$key][$value] + $increaseCounterBy; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @see \StingerSoft\EntitySearchBundle\Model\Result\FacetSet::getFacet() |
| 47 | 47 | */ |
| 48 | 48 | public function getFacet($key) { |
| 49 | - if(isset($this->facets[$key])) { |
|
| 49 | + if (isset($this->facets[$key])) { |
|
| 50 | 50 | return $this->facets[$key]; |
| 51 | 51 | } else { |
| 52 | 52 | return; |