remove string binding
This commit is contained in:
parent
47fc5c2f1b
commit
c04a9f9861
|
|
@ -35,15 +35,11 @@ class SearchController extends ListDiscussionsController
|
|||
'createdAt' => 'created_at'
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
public function __construct(protected Client $elastic)
|
||||
{}
|
||||
|
||||
protected function data(ServerRequestInterface $request, Document $document)
|
||||
{
|
||||
/** @var Client $client */
|
||||
$client = resolve('blomstra.search.elastic');
|
||||
|
||||
$type = Arr::get($request->getQueryParams(), 'type');
|
||||
|
||||
$actor = RequestUtil::getActor($request);
|
||||
|
|
@ -57,7 +53,7 @@ class SearchController extends ListDiscussionsController
|
|||
BoolQuery::create()
|
||||
->add(MatchQuery::create('content', $filters['q']))
|
||||
);
|
||||
$builder = (new Builder($client))
|
||||
$builder = (new Builder($this->client))
|
||||
->index(resolve('blomstra.search.elastic_index'))
|
||||
->size($this->extractLimit($request))
|
||||
->from($this->extractOffset($request))
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class RebuildDocumentsCommand extends Command
|
|||
$queue = $container->make(Queue::class);
|
||||
|
||||
/** @var Client $client */
|
||||
$client = $container->make('blomstra.search.elastic');
|
||||
$client = $container->make(Client::class);
|
||||
|
||||
/** @var SettingsRepositoryInterface $settings */
|
||||
$settings = $container->make(SettingsRepositoryInterface::class);
|
||||
|
|
|
|||
|
|
@ -3,18 +3,14 @@
|
|||
namespace Blomstra\Search\Jobs;
|
||||
|
||||
use Elasticsearch\Client;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DeletingJob extends Job
|
||||
{
|
||||
public function handle(Container $container)
|
||||
public function handle(Client $client)
|
||||
{
|
||||
if ($this->models->isEmpty()) return;
|
||||
|
||||
/** @var Client $client */
|
||||
$client = $container->make('blomstra.search.elastic');
|
||||
|
||||
// Preparing body for storing.
|
||||
$body = $this->models->map(function (Model $model) {
|
||||
$document = $this->seeder->toDocument($model);
|
||||
|
|
|
|||
|
|
@ -3,18 +3,14 @@
|
|||
namespace Blomstra\Search\Jobs;
|
||||
|
||||
use Elasticsearch\Client;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SavingJob extends Job
|
||||
{
|
||||
public function handle(Container $container)
|
||||
public function handle(Client $client)
|
||||
{
|
||||
if ($this->models->isEmpty()) return;
|
||||
|
||||
/** @var Client $client */
|
||||
$client = $container->make('blomstra.search.elastic');
|
||||
|
||||
// Preparing body for storing.
|
||||
$body = $this->models->map(function (Model $model) {
|
||||
$document = $this->seeder->toDocument($model);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace Blomstra\Search;
|
|||
use Blomstra\Search\Jobs\DeletingJob;
|
||||
use Blomstra\Search\Jobs\SavingJob;
|
||||
use Blomstra\Search\Seeders;
|
||||
use Elasticsearch\Client;
|
||||
use Elasticsearch\ClientBuilder;
|
||||
use Flarum\Foundation\AbstractServiceProvider;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
|
|
@ -26,7 +27,7 @@ class Provider extends AbstractServiceProvider
|
|||
/** @var SettingsRepositoryInterface $settings */
|
||||
$settings = $this->container->make(SettingsRepositoryInterface::class);
|
||||
|
||||
$this->container->singleton('blomstra.search.elastic', function (Container $container) use ($settings) {
|
||||
$this->container->singleton(Client::class, function (Container $container) use ($settings) {
|
||||
$builder = ClientBuilder::create()
|
||||
->setHosts([$settings->get('blomstra-search.elastic-endpoint')])
|
||||
->setLogger($container->make(LoggerInterface::class));
|
||||
|
|
|
|||
Loading…
Reference in New Issue