File tree 2 files changed +39
-16
lines changed
2 files changed +39
-16
lines changed Original file line number Diff line number Diff line change 21
21
],
22
22
23
23
'retries ' => 1 ,
24
+
25
+ 'handler ' => null ,
24
26
],
25
27
26
28
/*
27
29
|--------------------------------------------------------------------------
28
- | Amazon Elasticsearch Service
30
+ | Handlers
29
31
|--------------------------------------------------------------------------
30
32
|
31
- | Sign all requests made to AWS by simply setting up the config with your
32
- | AWS settings like the following.
33
- |
34
- | 'aws_config' => [
35
- | 'key' => env('AWS_KEY'),
36
- | 'secret' => env('AWS_SECRET'),
37
- | 'region' => env('AWS_REGION'),
38
- | ],
33
+ | Use this to handle certain aspects of a Elasticsearch request.
39
34
|
40
35
*/
41
36
42
- 'aws_config ' => null ,
37
+ 'handlers ' => [
38
+ 'aws ' => [
39
+ 'class ' => \LaravelHunt \Handlers \AwsSignature::class,
40
+ 'key ' => env ('AWS_KEY ' ),
41
+ 'secret ' => env ('AWS_SECRET ' ),
42
+ 'region ' => env ('AWS_REGION ' , 'us-east-1 ' ),
43
+ ],
44
+ ],
43
45
44
46
/*
45
47
|--------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -45,12 +45,7 @@ public function __construct(array $config = [])
45
45
$ this ->config = $ config ;
46
46
$ this ->multilingual = $ this ->config ('multilingual ' , false );
47
47
48
- // AWS Elasticsearch enabled
49
- if ($ aws = $ this ->config ('aws_config ' , null )) {
50
- $ this ->config ['config ' ]['handler ' ] = new AwsSignature ($ aws );
51
- }
52
-
53
- $ this ->elasticsearch = ClientBuilder::fromConfig ($ this ->config ('config ' ));
48
+ $ this ->elasticsearch = ClientBuilder::fromConfig ($ this ->getElasticSearchConfig ());
54
49
}
55
50
56
51
/**
@@ -646,4 +641,30 @@ public function getIndexName()
646
641
{
647
642
return $ this ->config ('index ' , 'default ' );
648
643
}
644
+
645
+ /**
646
+ * Get Elasticsearch settings.
647
+ *
648
+ * @return array
649
+ */
650
+ protected function getElasticSearchConfig ()
651
+ {
652
+ // Get all settings
653
+ $ settings = $ this ->config ('config ' );
654
+
655
+ // Get a handler if one is set
656
+ if ($ config = $ this ->config ('handlers. ' . $ this ->config ('config.handler ' ), null )) {
657
+
658
+ // Get handler class
659
+ $ handler = Arr::pull ($ config , 'class ' );
660
+
661
+ // Create handler instance
662
+ $ settings ['handler ' ] = new $ handler ($ config );
663
+ }
664
+ else {
665
+ unset($ settings ['handler ' ]);
666
+ }
667
+
668
+ return $ settings ;
669
+ }
649
670
}
You can’t perform that action at this time.
0 commit comments