Update command subscriber to fire system events

This commit is contained in:
James Brooks
2016-08-03 12:34:43 +01:00
parent 6b6eeb9a3e
commit e6227301fd
3 changed files with 81 additions and 5 deletions

View File

@@ -11,6 +11,9 @@
namespace CachetHQ\Cachet\Subscribers;
use CachetHQ\Cachet\Bus\Events\System\SystemWasInstalledEvent;
use CachetHQ\Cachet\Bus\Events\System\SystemWasResetEvent;
use CachetHQ\Cachet\Bus\Events\System\SystemWasUpdatedEvent;
use CachetHQ\Cachet\Settings\Cache;
use Carbon\Carbon;
use Exception;
@@ -63,19 +66,67 @@ class CommandSubscriber
*/
public function subscribe(Dispatcher $events)
{
$events->listen('command.installing', __CLASS__.'@fire', 5);
$events->listen('command.updating', __CLASS__.'@fire', 5);
$events->listen('command.resetting', __CLASS__.'@fire', 5);
$events->listen('command.installing', __CLASS__.'@fireInstallingCommand', 5);
$events->listen('command.updating', __CLASS__.'@fireUpdatingCommand', 5);
$events->listen('command.resetting', __CLASS__.'@fireResettingCommand', 5);
}
/**
* Clear the settings cache, and backup the databases.
* Fire the installing command.
*
* @param \Illuminate\Console\Command $command
*
* @return void
*/
public function fire(Command $command)
public function fireInstallingCommand(Command $command)
{
$this->handleMainCommand($command);
event(new SystemWasInstalledEvent());
$command->success('System was installed!');
}
/**
* Fire the updating command.
*
* @param \Illuminate\Console\Command $command
*
* @return void
*/
public function fireUpdatingCommand(Command $command)
{
$this->handleMainCommand($command);
event(new SystemWasUpdatedEvent());
$command->success('System was updated!');
}
/**
* Fire the resetting command.
*
* @param \Illuminate\Console\Command $command
*
* @return void
*/
public function fireResettingCommand(Command $command)
{
$this->handleMainCommand($command);
event(new SystemWasResetEvent());
$command->success('System was reset!');
}
/**
* Handle the main bulk of the command, clear the settings and backup the database.
*
* @param \Illuminate\Console\Command $command
*
* @return void
*/
protected function handleMainCommand(Command $command)
{
$command->line('Clearing settings cache...');