|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* This file is part of Scout Extended. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Algolia Team <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Algolia\ScoutExtended; |
|
15
|
|
|
|
|
16
|
|
|
use ReflectionClass; |
|
17
|
|
|
use Laravel\Scout\Builder; |
|
18
|
|
|
use Algolia\AlgoliaSearch\Analytics; |
|
|
|
|
|
|
19
|
|
|
use Illuminate\Support\ServiceProvider; |
|
20
|
|
|
use Laravel\Scout\ScoutServiceProvider; |
|
21
|
|
|
use Algolia\ScoutExtended\Engines\AlgoliaEngine; |
|
22
|
|
|
use Algolia\ScoutExtended\Managers\EngineManager; |
|
23
|
|
|
use Algolia\AlgoliaSearch\Interfaces\ClientInterface; |
|
|
|
|
|
|
24
|
|
|
use Algolia\ScoutExtended\Console\Commands\SyncCommand; |
|
25
|
|
|
use Algolia\ScoutExtended\Console\Commands\FlushCommand; |
|
26
|
|
|
use Algolia\ScoutExtended\Searchable\AggregatorObserver; |
|
27
|
|
|
use Algolia\ScoutExtended\Console\Commands\ImportCommand; |
|
28
|
|
|
use Algolia\ScoutExtended\Console\Commands\StatusCommand; |
|
29
|
|
|
use Algolia\ScoutExtended\Console\Commands\OptimizeCommand; |
|
30
|
|
|
use Algolia\ScoutExtended\Console\Commands\ReImportCommand; |
|
31
|
|
|
use Algolia\ScoutExtended\Console\Commands\MakeAggregatorCommand; |
|
32
|
|
|
|
|
33
|
|
|
final class ScoutExtendedServiceProvider extends ServiceProvider |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* {@inheritdoc} |
|
37
|
|
|
*/ |
|
38
|
19 |
|
public function boot(): void |
|
39
|
|
|
{ |
|
40
|
19 |
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'algolia'); |
|
41
|
19 |
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritdoc} |
|
45
|
|
|
*/ |
|
46
|
19 |
|
public function register(): void |
|
47
|
|
|
{ |
|
48
|
19 |
|
$this->app->register(ScoutServiceProvider::class); |
|
49
|
|
|
|
|
50
|
19 |
|
$this->registerBinds(); |
|
51
|
19 |
|
$this->registerCommands(); |
|
52
|
19 |
|
$this->registerMacros(); |
|
53
|
19 |
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Binds Algolia services into the container. |
|
57
|
|
|
* |
|
58
|
|
|
* @return void |
|
59
|
|
|
*/ |
|
60
|
19 |
|
private function registerBinds(): void |
|
61
|
|
|
{ |
|
62
|
|
|
$this->app->bind(Algolia::class, function () { |
|
63
|
1 |
|
return new Algolia($this->app); |
|
64
|
19 |
|
}); |
|
65
|
|
|
|
|
66
|
19 |
|
$this->app->alias(Algolia::class, 'algolia'); |
|
67
|
|
|
|
|
68
|
|
|
$this->app->singleton(EngineManager::class, function ($app) { |
|
69
|
16 |
|
return new EngineManager($app); |
|
70
|
19 |
|
}); |
|
71
|
|
|
|
|
72
|
19 |
|
$this->app->alias(EngineManager::class, \Laravel\Scout\EngineManager::class); |
|
73
|
|
|
|
|
74
|
|
|
$this->app->bind(AlgoliaEngine::class, function (): AlgoliaEngine { |
|
75
|
16 |
|
return $this->app->make(\Laravel\Scout\EngineManager::class)->createAlgoliaDriver(); |
|
|
|
|
|
|
76
|
19 |
|
}); |
|
77
|
|
|
|
|
78
|
19 |
|
$this->app->alias(AlgoliaEngine::class, 'algolia.engine'); |
|
79
|
|
|
|
|
80
|
|
|
$this->app->bind(ClientInterface::class, function (): ClientInterface { |
|
81
|
16 |
|
$engine = $this->app->make('algolia.engine'); |
|
82
|
|
|
$reflection = new ReflectionClass(AlgoliaEngine::class); |
|
83
|
|
|
$property = $reflection->getProperty('algolia'); |
|
84
|
|
|
$property->setAccessible(true); |
|
85
|
|
|
|
|
86
|
|
|
return $property->getValue($engine); |
|
87
|
19 |
|
}); |
|
88
|
|
|
|
|
89
|
19 |
|
$this->app->alias(ClientInterface::class, 'algolia.client'); |
|
90
|
|
|
|
|
91
|
|
|
$this->app->bind(Analytics::class, function (): Analytics { |
|
92
|
|
|
return Analytics::create(config('scout.algolia.id'), config('scout.algolia.secret')); |
|
93
|
19 |
|
}); |
|
94
|
|
|
|
|
95
|
19 |
|
$this->app->alias(Analytics::class, 'algolia.analytics'); |
|
96
|
|
|
|
|
97
|
19 |
|
$this->app->singleton(AggregatorObserver::class, AggregatorObserver::class); |
|
98
|
|
|
// $this->loadRoutesFrom(__DIR__.'/../routes/web.php'); |
|
99
|
19 |
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Register artisan commands. |
|
103
|
|
|
* |
|
104
|
|
|
* @return void |
|
105
|
|
|
*/ |
|
106
|
19 |
|
private function registerCommands(): void |
|
107
|
|
|
{ |
|
108
|
19 |
|
if ($this->app->runningInConsole()) { |
|
109
|
19 |
|
$this->commands([ |
|
110
|
19 |
|
MakeAggregatorCommand::class, |
|
111
|
|
|
ImportCommand::class, |
|
112
|
|
|
FlushCommand::class, |
|
113
|
|
|
OptimizeCommand::class, |
|
114
|
|
|
ReImportCommand::class, |
|
115
|
|
|
StatusCommand::class, |
|
116
|
|
|
SyncCommand::class, |
|
117
|
|
|
]); |
|
118
|
|
|
} |
|
119
|
19 |
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Register macros. |
|
123
|
|
|
* |
|
124
|
|
|
* @return void |
|
125
|
|
|
* |
|
126
|
|
|
* @throws \ReflectionException |
|
127
|
|
|
*/ |
|
128
|
19 |
|
private function registerMacros(): void |
|
129
|
|
|
{ |
|
130
|
19 |
|
Builder::mixin(new BuilderMacros); |
|
131
|
19 |
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths