forked from bschmitt/laravel-amqp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bschmitt#3 from junaidnasir/master
Service Provider for Laravel
- Loading branch information
Showing
2 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php namespace Bschmitt\Amqp; | ||
|
||
use Bschmitt\Amqp\Consumer; | ||
use Bschmitt\Amqp\Publisher; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class AmqpServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Indicates if loading of the provider is deferred. | ||
* | ||
* @var bool | ||
*/ | ||
protected $defer = true; | ||
|
||
/** | ||
* Bootstrap any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->app->bind('Amqp', 'Bschmitt\Amqp\Amqp'); | ||
if (!class_exists('Amqp')) { | ||
class_alias('Bschmitt\Amqp\Facades\Amqp', 'Amqp'); | ||
} | ||
} | ||
/** | ||
* Register the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->singleton('Bschmitt\Amqp\Publisher', function ($app) { | ||
return new Publisher(config()); | ||
}); | ||
$this->app->singleton('Bschmitt\Amqp\Consumer', function ($app) { | ||
return new Consumer(config()); | ||
}); | ||
|
||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
{ | ||
return ['Amqp','Bschmitt\Amqp\Publisher' , 'Bschmitt\Amqp\Consumer']; | ||
} | ||
} |