laravel-resque/src/ResqueServiceProvider.php

50 lines
1.1 KiB
PHP
Raw Normal View History

2016-07-28 21:52:05 +00:00
<?php
namespace Hlgrrnhrdt\Resque;
use Hlgrrnhrdt\Resque\Console\WorkCommand;
use Illuminate\Support\ServiceProvider;
/**
* ResqueServiceProvider
*
* @author Holger Reinhardt <hlgrrnhrdt@gmail.com>
*/
class ResqueServiceProvider extends ServiceProvider
{
2016-07-29 16:03:41 +00:00
/**
*
*/
public function boot()
{
$connection = $this->app['config']['resque.connection'];
\Resque::setBackend($connection['server'], $connection['db']);
}
2016-07-28 21:52:05 +00:00
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
2016-07-29 16:03:41 +00:00
$this->registerResque();
2016-07-28 21:52:05 +00:00
$this->registerWorkCommand();
}
2016-07-29 16:03:41 +00:00
protected function registerResque()
2016-07-28 21:52:05 +00:00
{
2016-07-29 16:03:41 +00:00
$this->app->singleton('resque', function () {
2016-07-29 16:04:55 +00:00
$prefix = $connection = $this->app['config']['resque.prefix'];
return (new Resque())->setPrefix($prefix);
2016-07-28 21:52:05 +00:00
});
}
protected function registerWorkCommand()
{
2016-07-29 12:05:07 +00:00
$this->app->singleton('command.resque.work', function () {
return new WorkCommand($this->app->make('resque.manager'));
2016-07-28 21:52:05 +00:00
});
2016-07-29 12:02:56 +00:00
$this->commands('command.resque.work');
2016-07-28 21:52:05 +00:00
}
}