Completed
Push — master ( c40a22...4c05c5 )
by Hamoud
23:40 queued 09:50
created

ScoutElasticServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 19
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace Alhoqbani\Elastic;
4
5
use Elasticsearch\ClientBuilder;
6
use Illuminate\Support\ServiceProvider;
7
use Laravel\Scout\EngineManager;
8
9
class ScoutElasticServiceProvider extends ServiceProvider
10
{
11
12
    /**
13
     * Register the service provider.
14
     *
15
     * @return void
16
     */
17
    public function register()
18
    {
19
20
        $this->app->make(EngineManager::class)->extend('elastic', function () {
21
22
            $hosts = $this->app['config']->get('services.scout-elastic.hosts');
23
24
            $client = ClientBuilder::create()
25
                ->setHosts($hosts)
26
                ->build();
27
28
            return new ScoutElasticEngine($client);
29
        });
30
31
        $this->publishes([
32
            __DIR__ . '/../config/scout-elastic.php' =>
33
                $this->app['path.config'] . DIRECTORY_SEPARATOR . 'scout-elastic.php',
34
        ]);
35
    }
36
}
37