Skip to content

Commit 404e731

Browse files
committed
Merge branch '3.0'
# Conflicts: # Classes/Controller/SuggestController.php
2 parents 4b505ff + 41cbab9 commit 404e731

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

Classes/Controller/SuggestController.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SuggestController extends ActionController
2525

2626
/**
2727
* @Flow\Inject
28-
* @var ElasticSearchClient
28+
* @var \Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient
2929
*/
3030
protected $elasticSearchClient;
3131

@@ -48,6 +48,13 @@ class SuggestController extends ActionController
4848
'json' => JsonView::class
4949
];
5050

51+
public function initializeObject()
52+
{
53+
if ($this->objectManager->isRegistered(ElasticSearchClient::class)) {
54+
$this->elasticSearchClient = $this->objectManager->get(ElasticSearchClient::class);
55+
}
56+
}
57+
5158
/**
5259
* @param string $contextNodeIdentifier
5360
* @param string $dimensionCombination
@@ -165,11 +172,13 @@ protected function extractCompletions($response)
165172
*/
166173
protected function extractSuggestions($response)
167174
{
175+
if ($this->elasticSearchClient === null) {
176+
throw new \RuntimeException('The SuggestController needs an ElasticSearchClient, it seems you run without the flowpack/elasticsearch-contentrepositoryadaptor package, though.', 1487189823);
177+
}
168178
$suggestionOptions = isset($response['suggest']) ? $response['suggest'] : [];
169179
if (count($suggestionOptions['suggestions'][0]['options']) > 0) {
170180
return $suggestionOptions['suggestions'][0]['options'];
171181
}
172-
173182
return [];
174183
}
175184
}

Configuration/Routes.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
appendExceedingArguments: true
1111
httpMethods: ['GET']
1212
-
13-
name: 'flowpack/searchplugin - SuggestController->ajax'
13+
name: 'flowpack/searchplugin - AjaxSearchController->search'
1414
uriPattern: 'flowpack/ajaxsearch'
1515
defaults:
1616
'@package': 'Flowpack.SearchPlugin'

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"neos/fusion": "^3.0",
1313
"neos/neos": "^3.0"
1414
},
15+
"suggest": {
16+
"flowpack/elasticsearch-contentrepositoryadaptor": "Provides search using Elasticsearch",
17+
"flowpack/simplesearch-contentrepositoryadaptor": "A simple php search engine based on sqlite"
18+
},
1519
"autoload": {
1620
"psr-4": {
1721
"Flowpack\\SearchPlugin\\": "Classes"

0 commit comments

Comments
 (0)