Skip to content

Commit

Permalink
Move booting of services (#990)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Mar 16, 2021
1 parent c5863ba commit 9af72d3
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions src/HorizonServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function boot()
$this->registerRoutes();
$this->registerResources();
$this->defineAssetPublishing();
$this->offerPublishing();
$this->registerCommands();
}

/**
Expand Down Expand Up @@ -81,17 +83,53 @@ public function defineAssetPublishing()
}

/**
* Register the custom queue connectors for Horizon.
* Setup the resource publishing groups for Horizon.
*
* @return void
*/
protected function registerQueueConnectors()
protected function offerPublishing()
{
$this->app->resolving(QueueManager::class, function ($manager) {
$manager->addConnector('redis', function () {
return new RedisConnector($this->app['redis']);
});
});
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../stubs/HorizonServiceProvider.stub' => app_path('Providers/HorizonServiceProvider.php'),
], 'horizon-provider');

$this->publishes([
__DIR__.'/../config/horizon.php' => config_path('horizon.php'),
], 'horizon-config');
}
}

/**
* Register the Horizon Artisan commands.
*
* @return void
*/
protected function registerCommands()
{
if ($this->app->runningInConsole()) {
$this->commands([
Console\ClearCommand::class,
Console\ContinueCommand::class,
Console\ContinueSupervisorCommand::class,
Console\ForgetFailedCommand::class,
Console\HorizonCommand::class,
Console\InstallCommand::class,
Console\ListCommand::class,
Console\PauseCommand::class,
Console\PauseSupervisorCommand::class,
Console\PublishCommand::class,
Console\PurgeCommand::class,
Console\StatusCommand::class,
Console\SupervisorCommand::class,
Console\SupervisorsCommand::class,
Console\TerminateCommand::class,
Console\TimeoutCommand::class,
Console\WorkCommand::class,
]);
}

$this->commands([Console\SnapshotCommand::class]);
}

/**
Expand All @@ -110,9 +148,7 @@ public function register()
});

$this->configure();
$this->offerPublishing();
$this->registerServices();
$this->registerCommands();
$this->registerQueueConnectors();
}

Expand All @@ -130,24 +166,6 @@ protected function configure()
Horizon::use(config('horizon.use', 'default'));
}

/**
* Setup the resource publishing groups for Horizon.
*
* @return void
*/
protected function offerPublishing()
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../stubs/HorizonServiceProvider.stub' => app_path('Providers/HorizonServiceProvider.php'),
], 'horizon-provider');

$this->publishes([
__DIR__.'/../config/horizon.php' => config_path('horizon.php'),
], 'horizon-config');
}
}

/**
* Register Horizon's services in the container.
*
Expand All @@ -163,34 +181,16 @@ protected function registerServices()
}

/**
* Register the Horizon Artisan commands.
* Register the custom queue connectors for Horizon.
*
* @return void
*/
protected function registerCommands()
protected function registerQueueConnectors()
{
if ($this->app->runningInConsole()) {
$this->commands([
Console\ClearCommand::class,
Console\ContinueCommand::class,
Console\ContinueSupervisorCommand::class,
Console\ForgetFailedCommand::class,
Console\HorizonCommand::class,
Console\InstallCommand::class,
Console\ListCommand::class,
Console\PauseCommand::class,
Console\PauseSupervisorCommand::class,
Console\PublishCommand::class,
Console\PurgeCommand::class,
Console\StatusCommand::class,
Console\SupervisorCommand::class,
Console\SupervisorsCommand::class,
Console\TerminateCommand::class,
Console\TimeoutCommand::class,
Console\WorkCommand::class,
]);
}

$this->commands([Console\SnapshotCommand::class]);
$this->app->resolving(QueueManager::class, function ($manager) {
$manager->addConnector('redis', function () {
return new RedisConnector($this->app['redis']);
});
});
}
}

0 comments on commit 9af72d3

Please sign in to comment.