Fix command dispatching

This commit is contained in:
James Brooks
2018-06-25 22:25:54 +01:00
parent dd6bbce517
commit 8bb8ee3dc7
30 changed files with 88 additions and 73 deletions
@@ -76,7 +76,7 @@ class ComponentController extends AbstractApiController
public function store()
{
try {
$component = dispatch(new CreateComponentCommand(
$component = execute(new CreateComponentCommand(
Binput::get('name'),
Binput::get('description'),
Binput::get('status'),
@@ -97,9 +97,9 @@ class ComponentController extends AbstractApiController
Collection::make(preg_split('/ ?, ?/', $tags))->map(function ($tag) {
return trim($tag);
})->map(function ($tag) {
return dispatch(new CreateTagCommand($tag));
return execute(new CreateTagCommand($tag));
})->each(function ($tag) use ($component) {
dispatch(new ApplyTagCommand($component, $tag));
execute(new ApplyTagCommand($component, $tag));
});
}
@@ -116,7 +116,7 @@ class ComponentController extends AbstractApiController
public function update(Component $component)
{
try {
dispatch(new UpdateComponentCommand(
execute(new UpdateComponentCommand(
$component,
Binput::get('name'),
Binput::get('description'),
@@ -139,9 +139,9 @@ class ComponentController extends AbstractApiController
Collection::make(preg_split('/ ?, ?/', $tags))->map(function ($tag) {
return trim($tag);
})->map(function ($tag) {
return dispatch(new CreateTagCommand($tag));
return execute(new CreateTagCommand($tag));
})->each(function ($tag) use ($component) {
dispatch(new ApplyTagCommand($component, $tag));
execute(new ApplyTagCommand($component, $tag));
});
}
@@ -157,7 +157,7 @@ class ComponentController extends AbstractApiController
*/
public function destroy(Component $component)
{
dispatch(new RemoveComponentCommand($component));
execute(new RemoveComponentCommand($component));
return $this->noContent();
}
@@ -92,7 +92,7 @@ class ComponentGroupController extends AbstractApiController
public function store()
{
try {
$group = dispatch(new CreateComponentGroupCommand(
$group = execute(new CreateComponentGroupCommand(
Binput::get('name'),
Binput::get('order', 0),
Binput::get('collapsed', 0),
@@ -115,7 +115,7 @@ class ComponentGroupController extends AbstractApiController
public function update(ComponentGroup $group)
{
try {
$group = dispatch(new UpdateComponentGroupCommand(
$group = execute(new UpdateComponentGroupCommand(
$group,
Binput::get('name'),
Binput::get('order'),
@@ -138,7 +138,7 @@ class ComponentGroupController extends AbstractApiController
*/
public function destroy(ComponentGroup $group)
{
dispatch(new RemoveComponentGroupCommand($group));
execute(new RemoveComponentGroupCommand($group));
return $this->noContent();
}
@@ -67,7 +67,7 @@ class IncidentController extends AbstractApiController
public function store()
{
try {
$incident = dispatch(new CreateIncidentCommand(
$incident = execute(new CreateIncidentCommand(
Binput::get('name'),
Binput::get('status'),
Binput::get('message', null, false, false),
@@ -98,7 +98,7 @@ class IncidentController extends AbstractApiController
public function update(Incident $incident)
{
try {
$incident = dispatch(new UpdateIncidentCommand(
$incident = execute(new UpdateIncidentCommand(
$incident,
Binput::get('name'),
Binput::get('status'),
@@ -128,7 +128,7 @@ class IncidentController extends AbstractApiController
*/
public function destroy(Incident $incident)
{
dispatch(new RemoveIncidentCommand($incident));
execute(new RemoveIncidentCommand($incident));
return $this->noContent();
}
@@ -74,7 +74,7 @@ class IncidentUpdateController extends AbstractApiController
public function store(Incident $incident)
{
try {
$update = dispatch(new CreateIncidentUpdateCommand(
$update = execute(new CreateIncidentUpdateCommand(
$incident,
Binput::get('status'),
Binput::get('message'),
@@ -100,7 +100,7 @@ class IncidentUpdateController extends AbstractApiController
public function update(Incident $incident, IncidentUpdate $update)
{
try {
$update = dispatch(new UpdateIncidentUpdateCommand(
$update = execute(new UpdateIncidentUpdateCommand(
$update,
Binput::get('status'),
Binput::get('message'),
@@ -124,7 +124,7 @@ class IncidentUpdateController extends AbstractApiController
public function destroy(Incident $incident, IncidentUpdate $update)
{
try {
dispatch(new RemoveIncidentUpdateCommand($update));
execute(new RemoveIncidentUpdateCommand($update));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
@@ -62,7 +62,7 @@ class MetricController extends AbstractApiController
public function store()
{
try {
$metric = dispatch(new CreateMetricCommand(
$metric = execute(new CreateMetricCommand(
Binput::get('name'),
Binput::get('suffix'),
Binput::get('description'),
@@ -92,7 +92,7 @@ class MetricController extends AbstractApiController
public function update(Metric $metric)
{
try {
$metric = dispatch(new UpdateMetricCommand(
$metric = execute(new UpdateMetricCommand(
$metric,
Binput::get('name'),
Binput::get('suffix'),
@@ -122,7 +122,7 @@ class MetricController extends AbstractApiController
*/
public function destroy(Metric $metric)
{
dispatch(new RemoveMetricCommand($metric));
execute(new RemoveMetricCommand($metric));
return $this->noContent();
}
@@ -48,7 +48,7 @@ class MetricPointController extends AbstractApiController
public function store(Metric $metric)
{
try {
$metricPoint = dispatch(new CreateMetricPointCommand(
$metricPoint = execute(new CreateMetricPointCommand(
$metric,
Binput::get('value'),
Binput::get('timestamp')
@@ -70,7 +70,7 @@ class MetricPointController extends AbstractApiController
*/
public function update(Metric $metric, MetricPoint $metricPoint)
{
$metricPoint = dispatch(new UpdateMetricPointCommand(
$metricPoint = execute(new UpdateMetricPointCommand(
$metricPoint,
$metric,
Binput::get('value'),
@@ -90,7 +90,7 @@ class MetricPointController extends AbstractApiController
*/
public function destroy(Metric $metric, MetricPoint $metricPoint)
{
dispatch(new RemoveMetricPointCommand($metricPoint));
execute(new RemoveMetricPointCommand($metricPoint));
return $this->noContent();
}
@@ -67,7 +67,7 @@ class ScheduleController extends AbstractApiController
public function store()
{
try {
$schedule = dispatch(new CreateScheduleCommand(
$schedule = execute(new CreateScheduleCommand(
Binput::get('name'),
Binput::get('message', null, false, false),
Binput::get('status'),
@@ -92,7 +92,7 @@ class ScheduleController extends AbstractApiController
public function update(Schedule $schedule)
{
try {
$schedule = dispatch(new UpdateScheduleCommand(
$schedule = execute(new UpdateScheduleCommand(
$schedule,
Binput::get('name'),
Binput::get('message'),
@@ -118,7 +118,7 @@ class ScheduleController extends AbstractApiController
public function destroy(Schedule $schedule)
{
try {
dispatch(new DeleteScheduleCommand($schedule));
execute(new DeleteScheduleCommand($schedule));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
@@ -50,7 +50,7 @@ class SubscriberController extends AbstractApiController
$verified = Binput::get('verify', app(Repository::class)->get('setting.skip_subscriber_verification'));
try {
$subscriber = dispatch(new SubscribeSubscriberCommand(Binput::get('email'), $verified, Binput::get('components', null)));
$subscriber = execute(new SubscribeSubscriberCommand(Binput::get('email'), $verified, Binput::get('components', null)));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
@@ -67,7 +67,7 @@ class SubscriberController extends AbstractApiController
*/
public function destroy(Subscriber $subscriber)
{
dispatch(new UnsubscribeSubscriberCommand($subscriber));
execute(new UnsubscribeSubscriberCommand($subscriber));
return $this->noContent();
}
@@ -30,7 +30,7 @@ class SubscriptionController extends AbstractApiController
*/
public function destroy(Subscription $subscription)
{
dispatch(new UnsubscribeSubscriptionCommand($subscription));
execute(new UnsubscribeSubscriptionCommand($subscription));
return $this->noContent();
}