Rename incident bus

This commit is contained in:
James Brooks 2017-03-18 09:41:33 +00:00
parent a55575656d
commit 485116b5ce
13 changed files with 50 additions and 50 deletions

View File

@ -12,12 +12,12 @@
namespace CachetHQ\Cachet\Bus\Commands\Incident; namespace CachetHQ\Cachet\Bus\Commands\Incident;
/** /**
* This is the report incident command. * This is the create incident command.
* *
* @author Joseph Cohen <joe@alt-three.com> * @author Joseph Cohen <joe@alt-three.com>
* @author James Brooks <james@alt-three.com> * @author James Brooks <james@alt-three.com>
*/ */
final class ReportIncidentCommand final class CreateIncidentCommand
{ {
/** /**
* The incident name. * The incident name.
@ -115,7 +115,7 @@ final class ReportIncidentCommand
]; ];
/** /**
* Create a new report incident command instance. * Create a new create incident command instance.
* *
* @param string $name * @param string $name
* @param int $status * @param int $status

View File

@ -19,7 +19,7 @@ use CachetHQ\Cachet\Models\User;
* *
* @author James Brooks <james@alt-three.com> * @author James Brooks <james@alt-three.com>
*/ */
final class ReportIncidentUpdateCommand final class CreateIncidentUpdateCommand
{ {
/** /**
* The incident. * The incident.

View File

@ -15,7 +15,7 @@ use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\User; use CachetHQ\Cachet\Models\User;
final class IncidentWasReportedEvent implements ActionInterface, IncidentEventInterface final class IncidentWasCreatedEvent implements ActionInterface, IncidentEventInterface
{ {
/** /**
* The user who reported the event. * The user who reported the event.

View File

@ -12,8 +12,8 @@
namespace CachetHQ\Cachet\Bus\Handlers\Commands\Incident; namespace CachetHQ\Cachet\Bus\Handlers\Commands\Incident;
use CachetHQ\Cachet\Bus\Commands\Component\UpdateComponentCommand; use CachetHQ\Cachet\Bus\Commands\Component\UpdateComponentCommand;
use CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent; use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent;
use CachetHQ\Cachet\Bus\Exceptions\Incident\InvalidIncidentTimestampException; use CachetHQ\Cachet\Bus\Exceptions\Incident\InvalidIncidentTimestampException;
use CachetHQ\Cachet\Models\Component; use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\Incident;
@ -25,11 +25,11 @@ use Twig_Environment;
use Twig_Loader_Array; use Twig_Loader_Array;
/** /**
* This is the report incident command handler. * This is the create incident command handler.
* *
* @author James Brooks <james@alt-three.com> * @author James Brooks <james@alt-three.com>
*/ */
class ReportIncidentCommandHandler class CreateIncidentCommandHandler
{ {
/** /**
* The authentication guard instance. * The authentication guard instance.
@ -46,7 +46,7 @@ class ReportIncidentCommandHandler
protected $dates; protected $dates;
/** /**
* Create a new report incident command handler instance. * Create a new create incident command handler instance.
* *
* @param \Illuminate\Contracts\Auth\Guard $auth * @param \Illuminate\Contracts\Auth\Guard $auth
* @param \CachetHQ\Cachet\Services\Dates\DateFactory $dates * @param \CachetHQ\Cachet\Services\Dates\DateFactory $dates
@ -60,13 +60,13 @@ class ReportIncidentCommandHandler
} }
/** /**
* Handle the report incident command. * Handle the create incident command.
* *
* @param \CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand $command * @param \CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand $command
* *
* @return \CachetHQ\Cachet\Models\Incident * @return \CachetHQ\Cachet\Models\Incident
*/ */
public function handle(ReportIncidentCommand $command) public function handle(CreateIncidentCommand $command)
{ {
$data = [ $data = [
'name' => $command->name, 'name' => $command->name,
@ -116,7 +116,7 @@ class ReportIncidentCommandHandler
)); ));
} }
event(new IncidentWasReportedEvent($this->auth->user(), $incident, (bool) $command->notify)); event(new IncidentWasCreatedEvent($this->auth->user(), $incident, (bool) $command->notify));
return $incident; return $incident;
} }
@ -125,11 +125,11 @@ class ReportIncidentCommandHandler
* Compiles an incident template into an incident message. * Compiles an incident template into an incident message.
* *
* @param \CachetHQ\Cachet\Models\IncidentTemplate $template * @param \CachetHQ\Cachet\Models\IncidentTemplate $template
* @param \CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand $command * @param \CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand $command
* *
* @return string * @return string
*/ */
protected function parseTemplate(IncidentTemplate $template, ReportIncidentCommand $command) protected function parseTemplate(IncidentTemplate $template, CreateIncidentCommand $command)
{ {
$env = new Twig_Environment(new Twig_Loader_Array([])); $env = new Twig_Environment(new Twig_Loader_Array([]));
$template = $env->createTemplate($template->template); $template = $env->createTemplate($template->template);

View File

@ -12,7 +12,7 @@
namespace CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate; namespace CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate;
use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand; use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand;
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasReportedEvent; use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasReportedEvent;
use CachetHQ\Cachet\Models\IncidentUpdate; use CachetHQ\Cachet\Models\IncidentUpdate;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
@ -22,7 +22,7 @@ use Illuminate\Contracts\Auth\Guard;
* *
* @author James Brooks <james@alt-three.com> * @author James Brooks <james@alt-three.com>
*/ */
class ReportIncidentUpdateCommandHandler class CreateIncidentUpdateCommandHandler
{ {
/** /**
* The authentication guard instance. * The authentication guard instance.
@ -46,11 +46,11 @@ class ReportIncidentUpdateCommandHandler
/** /**
* Handle the report incident command. * Handle the report incident command.
* *
* @param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand $command * @param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand $command
* *
* @return \CachetHQ\Cachet\Models\IncidentUpdate * @return \CachetHQ\Cachet\Models\IncidentUpdate
*/ */
public function handle(ReportIncidentUpdateCommand $command) public function handle(CreateIncidentUpdateCommand $command)
{ {
$data = [ $data = [
'incident_id' => $command->incident->id, 'incident_id' => $command->incident->id,

View File

@ -11,7 +11,7 @@
namespace CachetHQ\Cachet\Bus\Handlers\Events\Incident; namespace CachetHQ\Cachet\Bus\Handlers\Events\Incident;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent; use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent;
use CachetHQ\Cachet\Models\Subscriber; use CachetHQ\Cachet\Models\Subscriber;
use CachetHQ\Cachet\Notifications\Incident\NewIncidentNotification; use CachetHQ\Cachet\Notifications\Incident\NewIncidentNotification;
@ -39,11 +39,11 @@ class SendIncidentEmailNotificationHandler
/** /**
* Handle the event. * Handle the event.
* *
* @param \CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent $event * @param \CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent $event
* *
* @return void * @return void
*/ */
public function handle(IncidentWasReportedEvent $event) public function handle(IncidentWasCreatedEvent $event)
{ {
$incident = $event->incident; $incident = $event->incident;

View File

@ -60,12 +60,12 @@ class EventServiceProvider extends ServiceProvider
'CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasUpdatedEvent' => [ 'CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasUpdatedEvent' => [
// //
], ],
'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent' => [
'CachetHQ\Cachet\Bus\Handlers\Events\Incident\SendIncidentEmailNotificationHandler',
],
'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasRemovedEvent' => [ 'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasRemovedEvent' => [
// //
], ],
'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent' => [
'CachetHQ\Cachet\Bus\Handlers\Events\Incident\SendIncidentEmailNotificationHandler',
],
'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasUpdatedEvent' => [ 'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasUpdatedEvent' => [
// //
], ],

View File

@ -11,8 +11,8 @@
namespace CachetHQ\Cachet\Http\Controllers\Api; namespace CachetHQ\Cachet\Http\Controllers\Api;
use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand;
use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand;
use CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand;
use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand;
use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\Incident;
use GrahamCampbell\Binput\Facades\Binput; use GrahamCampbell\Binput\Facades\Binput;
@ -67,7 +67,7 @@ class IncidentController extends AbstractApiController
public function postIncidents() public function postIncidents()
{ {
try { try {
$incident = dispatch(new ReportIncidentCommand( $incident = dispatch(new CreateIncidentCommand(
Binput::get('name'), Binput::get('name'),
Binput::get('status'), Binput::get('status'),
Binput::get('message', null, false, false), Binput::get('message', null, false, false),

View File

@ -11,8 +11,8 @@
namespace CachetHQ\Cachet\Http\Controllers\Api; namespace CachetHQ\Cachet\Http\Controllers\Api;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\RemoveIncidentUpdateCommand; use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\RemoveIncidentUpdateCommand;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand; use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand;
use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentUpdate; use CachetHQ\Cachet\Models\IncidentUpdate;
@ -74,7 +74,7 @@ class IncidentUpdateController extends AbstractApiController
public function postIncidentUpdate(Incident $incident) public function postIncidentUpdate(Incident $incident)
{ {
try { try {
$update = dispatch(new ReportIncidentUpdateCommand( $update = dispatch(new CreateIncidentUpdateCommand(
$incident, $incident,
Binput::get('status'), Binput::get('status'),
Binput::get('message'), Binput::get('message'),

View File

@ -12,10 +12,10 @@
namespace CachetHQ\Cachet\Http\Controllers\Dashboard; namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
use AltThree\Validator\ValidationException; use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand;
use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand;
use CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand;
use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand; use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand;
use CachetHQ\Cachet\Models\Component; use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\ComponentGroup; use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\Incident;
@ -108,7 +108,7 @@ class IncidentController extends Controller
public function createIncidentAction() public function createIncidentAction()
{ {
try { try {
$incident = dispatch(new ReportIncidentCommand( $incident = dispatch(new CreateIncidentCommand(
Binput::get('name'), Binput::get('name'),
Binput::get('status'), Binput::get('status'),
Binput::get('message', null, false, false), Binput::get('message', null, false, false),
@ -308,7 +308,7 @@ class IncidentController extends Controller
public function createIncidentUpdateAction(Incident $incident) public function createIncidentUpdateAction(Incident $incident)
{ {
try { try {
$incident = dispatch(new ReportIncidentUpdateCommand( $incident = dispatch(new CreateIncidentUpdateCommand(
$incident, $incident,
Binput::get('status'), Binput::get('status'),
Binput::get('message'), Binput::get('message'),

View File

@ -12,17 +12,17 @@
namespace CachetHQ\Tests\Cachet\Bus\Commands\Incident; namespace CachetHQ\Tests\Cachet\Bus\Commands\Incident;
use AltThree\TestBench\CommandTrait; use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Incident\ReportIncidentCommandHandler; use CachetHQ\Cachet\Bus\Handlers\Commands\Incident\CreateIncidentCommandHandler;
use CachetHQ\Tests\Cachet\AbstractTestCase; use CachetHQ\Tests\Cachet\AbstractTestCase;
/** /**
* This is the add incident command test class. * This is the create incident command test class.
* *
* @author James Brooks <james@alt-three.com> * @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com> * @author Graham Campbell <graham@alt-three.com>
*/ */
class ReportIncidentCommandTest extends AbstractTestCase class CreateIncidentCommandTest extends AbstractTestCase
{ {
use CommandTrait; use CommandTrait;
@ -42,7 +42,7 @@ class ReportIncidentCommandTest extends AbstractTestCase
'template_vars' => [], 'template_vars' => [],
]; ];
$object = new ReportIncidentCommand( $object = new CreateIncidentCommand(
$params['name'], $params['name'],
$params['status'], $params['status'],
$params['message'], $params['message'],
@ -66,6 +66,6 @@ class ReportIncidentCommandTest extends AbstractTestCase
protected function getHandlerClass() protected function getHandlerClass()
{ {
return ReportIncidentCommandHandler::class; return CreateIncidentCommandHandler::class;
} }
} }

View File

@ -12,18 +12,18 @@
namespace CachetHQ\Tests\Cachet\Bus\Commands\IncidentUpdate; namespace CachetHQ\Tests\Cachet\Bus\Commands\IncidentUpdate;
use AltThree\TestBench\CommandTrait; use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand; use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate\ReportIncidentUpdateCommandHandler; use CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate\CreateIncidentUpdateCommandHandler;
use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\User; use CachetHQ\Cachet\Models\User;
use CachetHQ\Tests\Cachet\AbstractTestCase; use CachetHQ\Tests\Cachet\AbstractTestCase;
/** /**
* This is the report incident update command test class. * This is the create incident update command test class.
* *
* @author James Brooks <james@alt-three.com> * @author James Brooks <james@alt-three.com>
*/ */
class ReportIncidentUpdateCommandTest extends AbstractTestCase class CreateIncidentUpdateCommandTest extends AbstractTestCase
{ {
use CommandTrait; use CommandTrait;
@ -35,7 +35,7 @@ class ReportIncidentUpdateCommandTest extends AbstractTestCase
'message' => 'Foo', 'message' => 'Foo',
'user' => new User(), 'user' => new User(),
]; ];
$object = new ReportIncidentUpdateCommand($params['incident'], $params['status'], $params['message'], $params['user']); $object = new CreateIncidentUpdateCommand($params['incident'], $params['status'], $params['message'], $params['user']);
return compact('params', 'object'); return compact('params', 'object');
} }
@ -47,6 +47,6 @@ class ReportIncidentUpdateCommandTest extends AbstractTestCase
protected function getHandlerClass() protected function getHandlerClass()
{ {
return ReportIncidentUpdateCommandHandler::class; return CreateIncidentUpdateCommandHandler::class;
} }
} }

View File

@ -11,16 +11,16 @@
namespace CachetHQ\Tests\Cachet\Bus\Events\Incident; namespace CachetHQ\Tests\Cachet\Bus\Events\Incident;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent; use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent;
use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\User; use CachetHQ\Cachet\Models\User;
/** /**
* This is the incident was reported event test class. * This is the incident was created event test class.
* *
* @author James Brooks <james@alt-three.com> * @author James Brooks <james@alt-three.com>
*/ */
class IncidentWasReportedEventTest extends AbstractIncidentEventTestCase class IncidentWasCreatedEventTest extends AbstractIncidentEventTestCase
{ {
protected function objectHasHandlers() protected function objectHasHandlers()
{ {
@ -34,7 +34,7 @@ class IncidentWasReportedEventTest extends AbstractIncidentEventTestCase
'incident' => new Incident(), 'incident' => new Incident(),
'notify' => true, 'notify' => true,
]; ];
$object = new IncidentWasReportedEvent($params['user'], $params['incident'], $params['notify']); $object = new IncidentWasCreatedEvent($params['user'], $params['incident'], $params['notify']);
return compact('params', 'object'); return compact('params', 'object');
} }