Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lumen support #156

Merged
merged 3 commits into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Console/Commands/OptimizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Illuminate\Console\Command;
use Algolia\ScoutExtended\Algolia;
use Illuminate\Console\Application;
use Algolia\ScoutExtended\Settings\Compiler;
use Algolia\ScoutExtended\Settings\LocalFactory;
use Algolia\ScoutExtended\Helpers\SearchableFinder;
Expand Down Expand Up @@ -60,7 +61,7 @@ public function handle(
$compiler->compile($settings, $path);
$this->output->success('Settings file created at: '.$path);
$this->output->note('Please review the settings file and synchronize it with Algolia using: "'.
ARTISAN_BINARY.' scout:sync"');
Application::artisanBinary().' scout:sync"');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Engines/AlgoliaEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function map(Builder $builder, $results, $searchable)
return $searchable->newCollection();
}

return resolve(ModelsResolver::class)->from($builder, $searchable, $results);
return app(ModelsResolver::class)->from($builder, $searchable, $results);
}

/**
Expand Down
8 changes: 3 additions & 5 deletions src/Helpers/SearchableFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Laravel\Scout\Searchable;
use Illuminate\Console\Command;
use Symfony\Component\Finder\Finder;
use Illuminate\Foundation\Application;
use Symfony\Component\Console\Exception\InvalidArgumentException;

/**
Expand All @@ -32,18 +31,17 @@ final class SearchableFinder
private static $declaredClasses;

/**
* @var \Illuminate\Foundation\Application
* @var \Illuminate\Contracts\Foundation\Application
*/
private $app;

/**
* SearchableModelsFinder constructor.
*
* @param \Illuminate\Foundation\Application $app
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function __construct(Application $app)
public function __construct($app)
{
$this->app = $app;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Repositories/LocalSettingsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getPath(SearchIndex $index): string
$settingsPath = config('scout.algolia.settings_path');

if ($settingsPath === null) {
return config_path($fileName);
return app('path.config').DIRECTORY_SEPARATOR.$fileName;
}

if (! $this->files->exists($settingsPath)) {
Expand Down
5 changes: 5 additions & 0 deletions src/ScoutExtendedServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Algolia\AlgoliaSearch\AnalyticsClient;
use Algolia\ScoutExtended\Engines\AlgoliaEngine;
use Algolia\ScoutExtended\Managers\EngineManager;
use Algolia\ScoutExtended\Helpers\SearchableFinder;
use Algolia\ScoutExtended\Console\Commands\SyncCommand;
use Algolia\ScoutExtended\Console\Commands\FlushCommand;
use Algolia\ScoutExtended\Searchable\AggregatorObserver;
Expand Down Expand Up @@ -89,6 +90,10 @@ private function registerBinds(): void

$this->app->singleton(AggregatorObserver::class, AggregatorObserver::class);
$this->app->bind(\Laravel\Scout\Builder::class, Builder::class);

$this->app->bind(SearchableFinder::class, function () {
return new SearchableFinder($this->app);
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Searchable/Aggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function bootSearchable(): void
{
($self = new static)->registerSearchableMacros();

$observer = tap(resolve(AggregatorObserver::class))->setAggregator(static::class, $models = $self->getModels());
$observer = tap(app(AggregatorObserver::class))->setAggregator(static::class, $models = $self->getModels());

foreach ($models as $model) {
$model::observe($observer);
Expand Down