BroadcastServiceProvider.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Illuminate\Broadcasting;
  3. use Illuminate\Support\ServiceProvider;
  4. use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory;
  5. use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
  6. class BroadcastServiceProvider extends ServiceProvider
  7. {
  8. /**
  9. * Indicates if loading of the provider is deferred.
  10. *
  11. * @var bool
  12. */
  13. protected $defer = true;
  14. /**
  15. * Register the service provider.
  16. *
  17. * @return void
  18. */
  19. public function register()
  20. {
  21. $this->app->singleton(BroadcastManager::class, function ($app) {
  22. return new BroadcastManager($app);
  23. });
  24. $this->app->singleton(BroadcasterContract::class, function ($app) {
  25. return $app->make(BroadcastManager::class)->connection();
  26. });
  27. $this->app->alias(
  28. BroadcastManager::class, BroadcastingFactory::class
  29. );
  30. }
  31. /**
  32. * Get the services provided by the provider.
  33. *
  34. * @return array
  35. */
  36. public function provides()
  37. {
  38. return [
  39. BroadcastManager::class,
  40. BroadcastingFactory::class,
  41. BroadcasterContract::class,
  42. ];
  43. }
  44. }