WeWorkServiceProvider.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace WeWork\Laravel;
  3. use Illuminate\Support\ServiceProvider;
  4. use WeWork\App;
  5. class WeWorkServiceProvider extends ServiceProvider
  6. {
  7. /**
  8. * Indicates if loading of the provider is deferred.
  9. *
  10. * @var bool
  11. */
  12. protected $defer = true;
  13. /**
  14. * Bootstrap services.
  15. *
  16. * @return void
  17. */
  18. public function boot()
  19. {
  20. $this->publishes(
  21. [
  22. __DIR__.'/config.php' => config_path('wework.php'),
  23. ]
  24. );
  25. }
  26. /**
  27. * Register services.
  28. *
  29. * @return void
  30. */
  31. public function register()
  32. {
  33. $this->app->singleton(
  34. 'wework',
  35. function ($app, $parameters) {
  36. $wework = array_merge($app['config']['wework'], $parameters);
  37. $agent = $wework['agents'][$wework['default']];
  38. $config = array_merge($agent, $wework);
  39. $config['log'] = LogBridge::class;
  40. $config['cache'] = CacheBridge::class;
  41. return new App($config);
  42. }
  43. );
  44. }
  45. /**
  46. * Get the services provided by the provider.
  47. *
  48. * @return array
  49. */
  50. public function provides()
  51. {
  52. return ['wework'];
  53. }
  54. }