Update command subscriber to fire system events
This commit is contained in:
22
app/Bus/Events/System/SystemWasResetEvent.php
Normal file
22
app/Bus/Events/System/SystemWasResetEvent.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Bus\Events\System;
|
||||
|
||||
/**
|
||||
* This is the system was reset event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class SystemWasResetEvent implements SystemEventInterface
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -93,6 +93,9 @@ class EventServiceProvider extends ServiceProvider
|
||||
'CachetHQ\Cachet\Bus\Events\System\SystemWasInstalledEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\System\SystemWasResetEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\System\SystemWasUpdatedEvent' => [
|
||||
//
|
||||
],
|
||||
|
||||
@@ -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...');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user