mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-18 05:58:18 +01:00
Commands and events for removing incidents
This commit is contained in:
parent
a239c34892
commit
b80b53191b
36
app/Commands/Incident/RemoveIncidentCommand.php
Normal file
36
app/Commands/Incident/RemoveIncidentCommand.php
Normal 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;
|
||||
}
|
||||
}
|
32
app/Events/Incident/IncidentWasRemovedEvent.php
Normal file
32
app/Events/Incident/IncidentWasRemovedEvent.php
Normal 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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user