File tree Expand file tree Collapse file tree 3 files changed +47
-3
lines changed
Resources/config/services/api Expand file tree Collapse file tree 3 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,14 @@ ELASTICSEARCH_HOST=localhost
114
114
ELASTICSEARCH_PORT=9200
115
115
ELASTICSEARCH_INDEX=vue_storefront_catalog
116
116
117
- # Optionally, when using Nelmio CORS Bundle
117
+ // Set transport value to "https" and ssl to "true" when using an ssl connection
118
+ ELASTICSEARCH_TRANSPORT=http
119
+ ELASTICSEARCH_SSL=false
120
+ // Leave blank if authentication is not required
121
+ ELASTICSEARCH_USERNAME=
122
+ ELASTICSEARCH_PASSWORD=
123
+
124
+ // Optionally, when using Nelmio CORS Bundle
118
125
CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
119
126
```
120
127
Original file line number Diff line number Diff line change @@ -32,17 +32,50 @@ final class GetCatalogAction
32
32
/** @var int */
33
33
private $ port ;
34
34
35
- public function __construct (ViewHandlerInterface $ viewHandler , string $ host , int $ port )
35
+ /** @var string */
36
+ private $ transport ;
37
+
38
+ /** @var bool */
39
+ private $ ssl ;
40
+
41
+ /** @var int */
42
+ private $ username ;
43
+
44
+ /** @var string */
45
+ private $ password ;
46
+
47
+ public function __construct (
48
+ ViewHandlerInterface $ viewHandler ,
49
+ string $ host ,
50
+ int $ port ,
51
+ string $ transport ,
52
+ bool $ ssl ,
53
+ string $ username ,
54
+ string $ password
55
+ )
36
56
{
37
57
$ this ->host = $ host ;
38
58
$ this ->port = $ port ;
59
+ $ this ->transport = $ transport ;
60
+ $ this ->ssl = $ ssl ;
61
+ $ this ->username = $ username ;
62
+ $ this ->password = $ password ;
39
63
$ this ->viewHandler = $ viewHandler ;
40
64
}
41
65
42
66
public function __invoke (Request $ request ): Response
43
67
{
44
68
$ client = new Client ();
45
- $ client ->addConnection (new Connection (['host ' => $ this ->host , 'port ' => $ this ->port ]));
69
+ $ connection = new Connection ([
70
+ 'host ' => $ this ->host ,
71
+ 'port ' => $ this ->port ,
72
+ 'transport ' => $ this ->transport ,
73
+ 'ssl ' => $ this ->ssl ,
74
+ 'username ' => $ this ->username ,
75
+ 'password ' => $ this ->password
76
+ ]);
77
+
78
+ $ client ->addConnection ($ connection );
46
79
47
80
$ index = $ request ->attributes ->get ('index ' );
48
81
$ type = $ request ->attributes ->get ('type ' );
Original file line number Diff line number Diff line change 14
14
<argument type =" service" id =" fos_rest.view_handler" />
15
15
<argument >%env(ELASTICSEARCH_HOST)%</argument >
16
16
<argument >%env(ELASTICSEARCH_PORT)%</argument >
17
+ <argument >%env(ELASTICSEARCH_TRANSPORT)%</argument >
18
+ <argument >%env(ELASTICSEARCH_SSL)%</argument >
19
+ <argument >%env(ELASTICSEARCH_USERNAME)%</argument >
20
+ <argument >%env(ELASTICSEARCH_PASSWORD)%</argument >
17
21
</service >
18
22
</services >
19
23
</container >
You can’t perform that action at this time.
0 commit comments