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

View File

@ -16,12 +16,9 @@ use CachetHQ\Cachet\Commands\Subscriber\VerifySubscriberCommand;
use CachetHQ\Cachet\Events\Subscriber\SubscriberHasSubscribedEvent;
use CachetHQ\Cachet\Exceptions\AlreadySubscribedException;
use CachetHQ\Cachet\Models\Subscriber;
use Illuminate\Foundation\Bus\DispatchesJobs;
class SubscribeSubscriberCommandHandler
{
use DispatchesJobs;
/**
* Handle the subscribe subscriber command.
*
@ -40,7 +37,7 @@ class SubscribeSubscriberCommandHandler
$subscriber = Subscriber::create(['email' => $command->email]);
if ($command->verified) {
$this->dispatch(new VerifySubscriberCommand($subscriber));
dispatch(new VerifySubscriberCommand($subscriber));
} else {
event(new SubscriberHasSubscribedEvent($subscriber));
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -22,15 +22,12 @@ use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Tag;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
class ComponentController extends Controller
{
use DispatchesJobs;
/**
* Array of sub-menu items.
*
@ -130,7 +127,7 @@ class ComponentController extends Controller
$tags = array_pull($componentData, 'tags');
try {
$component = $this->dispatch(new UpdateComponentCommand(
$component = dispatch(new UpdateComponentCommand(
$component,
$componentData['name'],
$componentData['description'],
@ -184,7 +181,7 @@ class ComponentController extends Controller
$tags = array_pull($componentData, 'tags');
try {
$component = $this->dispatch(new AddComponentCommand(
$component = dispatch(new AddComponentCommand(
$componentData['name'],
$componentData['description'],
$componentData['status'],
@ -223,7 +220,7 @@ class ComponentController extends Controller
*/
public function deleteComponentAction(Component $component)
{
$this->dispatch(new RemoveComponentCommand($component));
dispatch(new RemoveComponentCommand($component));
return Redirect::route('dashboard.components.index')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success')));
@ -238,7 +235,7 @@ class ComponentController extends Controller
*/
public function deleteComponentGroupAction(ComponentGroup $group)
{
$this->dispatch(new RemoveComponentGroupCommand($group));
dispatch(new RemoveComponentGroupCommand($group));
return Redirect::route('dashboard.components.index')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success')));
@ -277,7 +274,7 @@ class ComponentController extends Controller
public function postAddComponentGroup()
{
try {
$group = $this->dispatch(new AddComponentGroupCommand(
$group = dispatch(new AddComponentGroupCommand(
Binput::get('name'),
Binput::get('order', 0)
));
@ -302,7 +299,7 @@ class ComponentController extends Controller
public function updateComponentGroupAction(ComponentGroup $group)
{
try {
$group = $this->dispatch(new UpdateComponentGroupCommand(
$group = dispatch(new UpdateComponentGroupCommand(
$group,
Binput::get('name'),
Binput::get('order', 0)

View File

@ -20,15 +20,12 @@ use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
class IncidentController extends Controller
{
use DispatchesJobs;
/**
* Stores the sub-sidebar tree list.
*
@ -110,7 +107,7 @@ class IncidentController extends Controller
public function createIncidentAction()
{
try {
$incident = $this->dispatch(new ReportIncidentCommand(
$incident = dispatch(new ReportIncidentCommand(
Binput::get('name'),
Binput::get('status'),
Binput::get('message'),
@ -202,7 +199,7 @@ class IncidentController extends Controller
*/
public function deleteIncidentAction(Incident $incident)
{
$this->dispatch(new RemoveIncidentCommand($incident));
dispatch(new RemoveIncidentCommand($incident));
return Redirect::route('dashboard.incidents.index')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success')));
@ -234,7 +231,7 @@ class IncidentController extends Controller
public function editIncidentAction(Incident $incident)
{
try {
$incident = $this->dispatch(new UpdateIncidentCommand(
$incident = dispatch(new UpdateIncidentCommand(
$incident,
Binput::get('name'),
Binput::get('status'),

View File

@ -18,15 +18,12 @@ use CachetHQ\Cachet\Commands\Metric\UpdateMetricCommand;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\MetricPoint;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
class MetricController extends Controller
{
use DispatchesJobs;
/**
* Shows the metrics view.
*
@ -74,7 +71,7 @@ class MetricController extends Controller
$metricData = Binput::get('metric');
try {
$this->dispatch(new AddMetricCommand(
dispatch(new AddMetricCommand(
$metricData['name'],
$metricData['suffix'],
$metricData['description'],
@ -114,7 +111,7 @@ class MetricController extends Controller
*/
public function deleteMetricAction(Metric $metric)
{
$this->dispatch(new RemoveMetricCommand($metric));
dispatch(new RemoveMetricCommand($metric));
return Redirect::route('dashboard.metrics.index')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.delete.success')));
@ -144,7 +141,7 @@ class MetricController extends Controller
public function editMetricAction(Metric $metric)
{
try {
$this->dispatch(new UpdateMetricCommand(
dispatch(new UpdateMetricCommand(
$metric,
Binput::get('metric.name', null, false),
Binput::get('metric.suffix', null, false),

View File

@ -17,7 +17,6 @@ use CachetHQ\Cachet\Dates\DateFactory;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
@ -26,8 +25,6 @@ use Jenssegers\Date\Date;
class ScheduleController extends Controller
{
use DispatchesJobs;
/**
* Stores the sub-sidebar tree list.
*
@ -97,7 +94,7 @@ class ScheduleController extends Controller
public function addScheduleAction()
{
try {
$incident = $this->dispatch(new ReportMaintenanceCommand(
$incident = dispatch(new ReportMaintenanceCommand(
Binput::get('incident.name'),
Binput::get('incident.message'),
Binput::get('incident.notify'),

View File

@ -16,15 +16,12 @@ use CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand;
use CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand;
use CachetHQ\Cachet\Models\Subscriber;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
class SubscriberController extends Controller
{
use DispatchesJobs;
/**
* Shows the subscribers view.
*
@ -56,7 +53,7 @@ class SubscriberController extends Controller
public function createSubscriberAction()
{
try {
$this->dispatch(new SubscribeSubscriberCommand(Binput::get('email')));
dispatch(new SubscribeSubscriberCommand(Binput::get('email')));
} catch (ValidationException $e) {
return Redirect::route('dashboard.subscribers.add')
->withInput(Binput::all())
@ -79,7 +76,7 @@ class SubscriberController extends Controller
*/
public function deleteSubscriberAction(Subscriber $subscriber)
{
$this->dispatch(new UnsubscribeSubscriberCommand($subscriber));
dispatch(new UnsubscribeSubscriberCommand($subscriber));
return Redirect::route('dashboard.subscribers.index');
}

View File

@ -17,15 +17,12 @@ use CachetHQ\Cachet\Commands\User\InviteTeamMemberCommand;
use CachetHQ\Cachet\Commands\User\RemoveUserCommand;
use CachetHQ\Cachet\Models\User;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
class TeamController extends Controller
{
use DispatchesJobs;
/**
* Shows the team members view.
*
@ -84,7 +81,7 @@ class TeamController extends Controller
public function postAddUser()
{
try {
$this->dispatch(new AddTeamMemberCommand(
dispatch(new AddTeamMemberCommand(
Binput::get('username'),
Binput::get('password'),
Binput::get('email'),
@ -133,7 +130,7 @@ class TeamController extends Controller
public function postInviteUser()
{
try {
$this->dispatch(new InviteTeamMemberCommand(
dispatch(new InviteTeamMemberCommand(
array_unique(array_filter((array) Binput::get('emails')))
));
} catch (ValidationException $e) {
@ -156,7 +153,7 @@ class TeamController extends Controller
*/
public function deleteUser(User $user)
{
$this->dispatch(new RemoveUserCommand($user));
dispatch(new RemoveUserCommand($user));
return Redirect::route('dashboard.team.index')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.delete.success')));

View File

@ -16,7 +16,6 @@ use CachetHQ\Cachet\Commands\Invite\ClaimInviteCommand;
use CachetHQ\Cachet\Commands\User\SignupUserCommand;
use CachetHQ\Cachet\Models\Invite;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
@ -25,8 +24,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class SignupController extends Controller
{
use DispatchesJobs;
/**
* Handle the signup with invite.
*
@ -72,7 +69,7 @@ class SignupController extends Controller
}
try {
$this->dispatch(new SignupUserCommand(
dispatch(new SignupUserCommand(
Binput::get('username'),
Binput::get('password'),
Binput::get('email'),
@ -85,7 +82,7 @@ class SignupController extends Controller
->withErrors($e->getMessageBag());
}
$this->dispatch(new ClaimInviteCommand($invite));
dispatch(new ClaimInviteCommand($invite));
return Redirect::route('status-page')
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.success')));

View File

@ -20,7 +20,6 @@ use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\Subscriber;
use GrahamCampbell\Binput\Facades\Binput;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
@ -29,8 +28,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class SubscribeController extends Controller
{
use DispatchesJobs;
/**
* Show the subscribe by email page.
*
@ -52,7 +49,7 @@ class SubscribeController extends Controller
$email = Binput::get('email');
try {
$this->dispatch(new SubscribeSubscriberCommand($email));
dispatch(new SubscribeSubscriberCommand($email));
} catch (AlreadySubscribedException $e) {
return Redirect::route('subscribe.subscribe')
->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
@ -87,7 +84,7 @@ class SubscribeController extends Controller
throw new BadRequestHttpException();
}
$this->dispatch(new VerifySubscriberCommand($subscriber));
dispatch(new VerifySubscriberCommand($subscriber));
return Redirect::route('status-page')
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.verified')));
@ -112,7 +109,7 @@ class SubscribeController extends Controller
throw new BadRequestHttpException();
}
$this->dispatch(new UnsubscribeSubscriberCommand($subscriber));
dispatch(new UnsubscribeSubscriberCommand($subscriber));
return Redirect::route('status-page')
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsubscribed')));