Use the new dispatch helper function

This commit is contained in:
Graham Campbell
2015-12-24 15:16:09 +00:00
parent 98795c8220
commit 5557edc342
15 changed files with 41 additions and 86 deletions
@@ -19,14 +19,11 @@ use CachetHQ\Cachet\Models\Tag;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class ComponentController extends AbstractApiController
{
use DispatchesJobs;
/**
* Get all components.
*
@@ -63,7 +60,7 @@ class ComponentController extends AbstractApiController
public function postComponents()
{
try {
$component = $this->dispatch(new AddComponentCommand(
$component = dispatch(new AddComponentCommand(
Binput::get('name'),
Binput::get('description'),
Binput::get('status'),
@@ -103,7 +100,7 @@ class ComponentController extends AbstractApiController
public function putComponent(Component $component)
{
try {
$this->dispatch(new UpdateComponentCommand(
dispatch(new UpdateComponentCommand(
$component,
Binput::get('name'),
Binput::get('description'),
@@ -140,7 +137,7 @@ class ComponentController extends AbstractApiController
*/
public function deleteComponent(Component $component)
{
$this->dispatch(new RemoveComponentCommand($component));
dispatch(new RemoveComponentCommand($component));
return $this->noContent();
}
@@ -17,14 +17,11 @@ use CachetHQ\Cachet\Commands\ComponentGroup\UpdateComponentGroupCommand;
use CachetHQ\Cachet\Models\ComponentGroup;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class ComponentGroupController extends AbstractApiController
{
use DispatchesJobs;
/**
* Get all groups.
*
@@ -57,7 +54,7 @@ class ComponentGroupController extends AbstractApiController
public function postGroups()
{
try {
$group = $this->dispatch(new AddComponentGroupCommand(
$group = dispatch(new AddComponentGroupCommand(
Binput::get('name'),
Binput::get('order', 0)
));
@@ -78,7 +75,7 @@ class ComponentGroupController extends AbstractApiController
public function putGroup(ComponentGroup $group)
{
try {
$group = $this->dispatch(new UpdateComponentGroupCommand(
$group = dispatch(new UpdateComponentGroupCommand(
$group,
Binput::get('name'),
Binput::get('order', 0)
@@ -99,7 +96,7 @@ class ComponentGroupController extends AbstractApiController
*/
public function deleteGroup(ComponentGroup $group)
{
$this->dispatch(new RemoveComponentGroupCommand($group));
dispatch(new RemoveComponentGroupCommand($group));
return $this->noContent();
}
@@ -18,14 +18,11 @@ use CachetHQ\Cachet\Models\Incident;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class IncidentController extends AbstractApiController
{
use DispatchesJobs;
/**
* Get all incidents.
*
@@ -60,7 +57,7 @@ class IncidentController extends AbstractApiController
public function postIncidents()
{
try {
$incident = $this->dispatch(new ReportIncidentCommand(
$incident = dispatch(new ReportIncidentCommand(
Binput::get('name'),
Binput::get('status'),
Binput::get('message'),
@@ -89,7 +86,7 @@ class IncidentController extends AbstractApiController
public function putIncident(Incident $incident)
{
try {
$incident = $this->dispatch(new UpdateIncidentCommand(
$incident = dispatch(new UpdateIncidentCommand(
$incident,
Binput::get('name'),
Binput::get('status'),
@@ -118,7 +115,7 @@ class IncidentController extends AbstractApiController
*/
public function deleteIncident(Incident $incident)
{
$this->dispatch(new RemoveIncidentCommand($incident));
dispatch(new RemoveIncidentCommand($incident));
return $this->noContent();
}
@@ -17,14 +17,11 @@ use CachetHQ\Cachet\Commands\Metric\UpdateMetricCommand;
use CachetHQ\Cachet\Models\Metric;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class MetricController extends AbstractApiController
{
use DispatchesJobs;
/**
* Get all metrics.
*
@@ -69,7 +66,7 @@ class MetricController extends AbstractApiController
public function postMetrics()
{
try {
$metric = $this->dispatch(new AddMetricCommand(
$metric = dispatch(new AddMetricCommand(
Binput::get('name'),
Binput::get('suffix'),
Binput::get('description'),
@@ -95,7 +92,7 @@ class MetricController extends AbstractApiController
public function putMetric(Metric $metric)
{
try {
$metric = $this->dispatch(new UpdateMetricCommand(
$metric = dispatch(new UpdateMetricCommand(
$metric,
Binput::get('name'),
Binput::get('suffix'),
@@ -121,7 +118,7 @@ class MetricController extends AbstractApiController
*/
public function deleteMetric(Metric $metric)
{
$this->dispatch(new RemoveMetricCommand($metric));
dispatch(new RemoveMetricCommand($metric));
return $this->noContent();
}
@@ -18,13 +18,10 @@ use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\MetricPoint;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class MetricPointController extends AbstractApiController
{
use DispatchesJobs;
/**
* Get a single metric point.
*
@@ -48,7 +45,7 @@ class MetricPointController extends AbstractApiController
public function postMetricPoints(Metric $metric)
{
try {
$metricPoint = $this->dispatch(new AddMetricPointCommand(
$metricPoint = dispatch(new AddMetricPointCommand(
$metric,
Binput::get('value'),
Binput::get('timestamp'))
@@ -70,7 +67,7 @@ class MetricPointController extends AbstractApiController
*/
public function putMetricPoint(Metric $metric, MetricPoint $metricPoint)
{
$metricPoint = $this->dispatch(new UpdateMetricPointCommand(
$metricPoint = dispatch(new UpdateMetricPointCommand(
$metricPoint,
$metric,
Binput::get('value'),
@@ -90,7 +87,7 @@ class MetricPointController extends AbstractApiController
*/
public function deleteMetricPoint(Metric $metric, MetricPoint $metricPoint)
{
$this->dispatch(new RemoveMetricPointCommand($metricPoint));
dispatch(new RemoveMetricPointCommand($metricPoint));
return $this->noContent();
}
@@ -16,14 +16,11 @@ use CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand;
use CachetHQ\Cachet\Models\Subscriber;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class SubscriberController extends AbstractApiController
{
use DispatchesJobs;
/**
* Get all subscribers.
*
@@ -44,7 +41,7 @@ class SubscriberController extends AbstractApiController
public function postSubscribers()
{
try {
$subscriber = $this->dispatch(new SubscribeSubscriberCommand(Binput::get('email'), Binput::get('verify', false)));
$subscriber = dispatch(new SubscribeSubscriberCommand(Binput::get('email'), Binput::get('verify', false)));
} catch (QueryException $e) {
throw new BadRequestHttpException();
}
@@ -61,7 +58,7 @@ class SubscriberController extends AbstractApiController
*/
public function deleteSubscriber(Subscriber $subscriber)
{
$this->dispatch(new UnsubscribeSubscriberCommand($subscriber));
dispatch(new UnsubscribeSubscriberCommand($subscriber));
return $this->noContent();
}