Skip to content

Commit

Permalink
Merge pull request #156 from AndreyBrazhnyk/lumen-support
Browse files Browse the repository at this point in the history
Lumen support
  • Loading branch information
nunomaduro committed Feb 27, 2019
2 parents b4b5f19 + 09c9910 commit 1d2acda
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/Console/Commands/OptimizeCommand.php
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
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
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
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
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
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

0 comments on commit 1d2acda

Please sign in to comment.