Commands and events for removing incidents

This commit is contained in:
James Brooks 2015-08-26 13:14:38 +01:00
parent a239c34892
commit b80b53191b
3 changed files with 103 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<?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\Commands\Incident;
use CachetHQ\Cachet\Models\Incident;
class RemoveIncidentCommand
{
/**
* The incident to remove.
*
* @var \CachetHQ\Cachet\Models\Incident
*/
public $incident;
/**
* Create a new remove incident command instance.
*
* @param \CachetHQ\Cachet\Models\Incident $incident
*
* @return void
*/
public function __construct(Incident $incident)
{
$this->incident = $incident;
}
}

View File

@ -0,0 +1,32 @@
<?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\Events\Incident;
use CachetHQ\Cachet\Models\Incident;
class IncidentWasRemovedEvent
{
/**
* The incident that has been removed.
*
* @var \CachetHQ\Cachet\Models\Incident
*/
public $incident;
/**
* Create a new incident was removed event instance.
*/
public function __construct(Incident $incident)
{
$this->incident = $incident;
}
}

View File

@ -0,0 +1,35 @@
<?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\Handlers\Commands\Incident;
use CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand;
use CachetHQ\Cachet\Events\Incident\IncidentWasRemovedEvent;
use CachetHQ\Cachet\Models\Incident;
class RemoveIncidentCommandHandler
{
/**
* Handle the remove incident command.
*
* @param \CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand $command
*
* @return void
*/
public function handle(RemoveIncidentCommand $command)
{
$incident = $command->incident;
event(new IncidentWasRemovedEvent($incident));
$incident->delete();
}
}