You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.8 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. <?php
  2. namespace TomLingham\Searchy;
  3. use Illuminate\Contracts\Container\Container;
  4. use Illuminate\Foundation\Application as LaravelApplication;
  5. use Illuminate\Support\ServiceProvider;
  6. use Laravel\Lumen\Application as LumenApplication;
  7. /**
  8. * This is the searchy service provider class.
  9. *
  10. * @author Tom Lingham <tjlingham@gmail.com>
  11. * @author Vincent Klaiber <hello@vinkla.com>
  12. */
  13. class SearchyServiceProvider extends ServiceProvider
  14. {
  15. /**
  16. * Boot the service provider.
  17. *
  18. * @return void
  19. */
  20. public function boot()
  21. {
  22. $this->setupConfig();
  23. }
  24. /**
  25. * Setup the config.
  26. *
  27. * @return void
  28. */
  29. protected function setupConfig()
  30. {
  31. $source = realpath(__DIR__.'/../config/searchy.php');
  32. if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
  33. $this->publishes([$source => config_path('searchy.php')]);
  34. } elseif ($this->app instanceof LumenApplication) {
  35. $this->app->configure('searchy');
  36. }
  37. $this->mergeConfigFrom($source, 'searchy');
  38. }
  39. /**
  40. * Register the service provider.
  41. *
  42. * @return void
  43. */
  44. public function register()
  45. {
  46. $this->registerSearchBuilder();
  47. }
  48. /**
  49. * Register the search builder class.
  50. *
  51. * @return void
  52. */
  53. public function registerSearchBuilder()
  54. {
  55. $this->app->singleton('searchy', function (Container $app) {
  56. $config = $app['config'];
  57. return new SearchBuilder($config);
  58. });
  59. $this->app->alias('searchy', SearchBuilder::class);
  60. }
  61. /**
  62. * Get the services provided by the provider.
  63. *
  64. * @return string[]
  65. */
  66. public function provides()
  67. {
  68. return [
  69. 'searchy',
  70. ];
  71. }
  72. }