Skip to content

Commit 41cbab9

Browse files
committed
MERGE: Merge branch '2.1' into 3.0
# Conflicts: # Classes/Controller/SuggestController.php # Configuration/Routes.yaml # composer.json
2 parents df4d87c + 0b1d63c commit 41cbab9

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

Classes/Controller/SuggestController.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SuggestController extends ActionController
2020
{
2121
/**
2222
* @Flow\Inject
23-
* @var ElasticSearchClient
23+
* @var \Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient
2424
*/
2525
protected $elasticSearchClient;
2626

@@ -31,6 +31,20 @@ class SuggestController extends ActionController
3131
'json' => JsonView::class
3232
];
3333

34+
/**
35+
* Sets the ElasticSearchClient instance needed for this to work. If no client is set,
36+
* this controller cannot be used; but at least the package can otherwise be used with
37+
* e.g. SimpleSearch.
38+
*
39+
* @return void
40+
*/
41+
public function initializeObject()
42+
{
43+
if ($this->objectManager->isRegistered(ElasticSearchClient::class)) {
44+
$this->elasticSearchClient = $this->objectManager->get(ElasticSearchClient::class);
45+
}
46+
}
47+
3448
/**
3549
* @param string $term
3650
*
@@ -47,6 +61,10 @@ public function indexAction($term)
4761
]
4862
];
4963

64+
if ($this->elasticSearchClient === null) {
65+
throw new \RuntimeException('The SuggestController needs an ElasticSearchClient, it seems you run without the flowpack/elasticsearch-contentrepositoryadaptor package, though.', 1487189823);
66+
}
67+
5068
$response = $this->elasticSearchClient->getIndex()->request('POST', '/_suggest', [], json_encode($request))->getTreatedContent();
5169
$suggestions = array_map(function ($option) {
5270
return $option['text'];

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)