Fix command dispatching
This commit is contained in:
@@ -116,7 +116,7 @@ class CreateIncidentCommandHandler
|
||||
|
||||
// Update the component.
|
||||
if ($component = Component::find($command->component_id)) {
|
||||
dispatch(new UpdateComponentCommand(
|
||||
execute(new UpdateComponentCommand(
|
||||
Component::find($command->component_id),
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -88,7 +88,7 @@ class UpdateIncidentCommandHandler
|
||||
|
||||
// Update the component.
|
||||
if ($component = Component::find($command->component_id)) {
|
||||
dispatch(new UpdateComponentCommand(
|
||||
execute(new UpdateComponentCommand(
|
||||
Component::find($command->component_id),
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -63,7 +63,7 @@ class CreateIncidentUpdateCommandHandler
|
||||
$update = IncidentUpdate::create($data);
|
||||
|
||||
// Update the original incident with the new status.
|
||||
dispatch(new UpdateIncidentCommand(
|
||||
execute(new UpdateIncidentCommand(
|
||||
$command->incident,
|
||||
null,
|
||||
$command->status,
|
||||
|
||||
@@ -58,7 +58,7 @@ class SubscribeSubscriberCommandHandler
|
||||
});
|
||||
|
||||
if ($command->verified) {
|
||||
dispatch(new VerifySubscriberCommand($subscriber));
|
||||
execute(new VerifySubscriberCommand($subscriber));
|
||||
} else {
|
||||
$subscriber->notify(new VerifySubscriptionNotification());
|
||||
}
|
||||
|
||||
@@ -42,6 +42,6 @@ class BeaconCommand extends Command
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
dispatch(new SendBeaconJob());
|
||||
execute(new SendBeaconJob());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class ApiFilter
|
||||
*
|
||||
* @return \GrahamCampbell\Exceptions\Displayers\DisplayerInterface[]
|
||||
*/
|
||||
public function filter(array $displayers, Request $request, Exception $original, Exception $transformed, $code)
|
||||
public function filter(array $displayers, Request $request, Exception $original, Exception $transformed, int $code)
|
||||
{
|
||||
if ($request->is('api*')) {
|
||||
foreach ($displayers as $index => $displayer) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class ApiController extends AbstractApiController
|
||||
public function postUpdateComponent(Component $component)
|
||||
{
|
||||
try {
|
||||
dispatch(new UpdateComponentCommand(
|
||||
execute(new UpdateComponentCommand(
|
||||
$component,
|
||||
$component->name,
|
||||
$component->description,
|
||||
@@ -68,7 +68,7 @@ class ApiController extends AbstractApiController
|
||||
try {
|
||||
$component = Component::find($componentId);
|
||||
|
||||
dispatch(new UpdateComponentCommand(
|
||||
execute(new UpdateComponentCommand(
|
||||
$component,
|
||||
$component->name,
|
||||
$component->description,
|
||||
@@ -100,7 +100,7 @@ class ApiController extends AbstractApiController
|
||||
foreach ($groupData as $order => $groupId) {
|
||||
$group = ComponentGroup::find($groupId);
|
||||
|
||||
dispatch(new UpdateComponentGroupCommand(
|
||||
execute(new UpdateComponentGroupCommand(
|
||||
$group,
|
||||
$group->name,
|
||||
$order + 1,
|
||||
|
||||
@@ -115,7 +115,7 @@ class ComponentController extends Controller
|
||||
$tags = array_pull($componentData, 'tags');
|
||||
|
||||
try {
|
||||
$component = dispatch(new UpdateComponentCommand(
|
||||
$component = execute(new UpdateComponentCommand(
|
||||
$component,
|
||||
$componentData['name'],
|
||||
$componentData['description'],
|
||||
@@ -140,9 +140,9 @@ class ComponentController extends Controller
|
||||
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));
|
||||
});
|
||||
|
||||
return cachet_redirect('dashboard.components.edit', [$component->id])
|
||||
@@ -172,7 +172,7 @@ class ComponentController extends Controller
|
||||
$tags = array_pull($componentData, 'tags');
|
||||
|
||||
try {
|
||||
$component = dispatch(new CreateComponentCommand(
|
||||
$component = execute(new CreateComponentCommand(
|
||||
$componentData['name'],
|
||||
$componentData['description'],
|
||||
$componentData['status'],
|
||||
@@ -193,9 +193,9 @@ class ComponentController extends Controller
|
||||
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));
|
||||
});
|
||||
|
||||
return cachet_redirect('dashboard.components')
|
||||
@@ -211,7 +211,7 @@ class ComponentController extends Controller
|
||||
*/
|
||||
public function deleteComponentAction(Component $component)
|
||||
{
|
||||
dispatch(new RemoveComponentCommand($component));
|
||||
execute(new RemoveComponentCommand($component));
|
||||
|
||||
return cachet_redirect('dashboard.components')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success')));
|
||||
|
||||
@@ -87,7 +87,7 @@ class ComponentGroupController extends Controller
|
||||
*/
|
||||
public function deleteComponentGroupAction(ComponentGroup $group)
|
||||
{
|
||||
dispatch(new RemoveComponentGroupCommand($group));
|
||||
execute(new RemoveComponentGroupCommand($group));
|
||||
|
||||
return cachet_redirect('dashboard.components.groups')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success')));
|
||||
@@ -126,7 +126,7 @@ class ComponentGroupController extends Controller
|
||||
public function postAddComponentGroup()
|
||||
{
|
||||
try {
|
||||
$group = dispatch(new CreateComponentGroupCommand(
|
||||
$group = execute(new CreateComponentGroupCommand(
|
||||
Binput::get('name'),
|
||||
Binput::get('order', 0),
|
||||
Binput::get('collapsed'),
|
||||
@@ -153,7 +153,7 @@ class ComponentGroupController extends Controller
|
||||
public function updateComponentGroupAction(ComponentGroup $group)
|
||||
{
|
||||
try {
|
||||
$group = dispatch(new UpdateComponentGroupCommand(
|
||||
$group = execute(new UpdateComponentGroupCommand(
|
||||
$group,
|
||||
Binput::get('name'),
|
||||
$group->order,
|
||||
|
||||
@@ -101,7 +101,7 @@ class DashboardController extends Controller
|
||||
|
||||
$welcomeUser = !Auth::user()->welcomed;
|
||||
if ($welcomeUser) {
|
||||
dispatch(new WelcomeUserCommand(Auth::user()));
|
||||
execute(new WelcomeUserCommand(Auth::user()));
|
||||
}
|
||||
|
||||
$entries = null;
|
||||
|
||||
@@ -117,7 +117,7 @@ class IncidentController extends Controller
|
||||
public function createIncidentAction()
|
||||
{
|
||||
try {
|
||||
$incident = dispatch(new CreateIncidentCommand(
|
||||
$incident = execute(new CreateIncidentCommand(
|
||||
Binput::get('name'),
|
||||
Binput::get('status'),
|
||||
Binput::get('message', null, false, false),
|
||||
@@ -213,7 +213,7 @@ class IncidentController extends Controller
|
||||
*/
|
||||
public function deleteIncidentAction(Incident $incident)
|
||||
{
|
||||
dispatch(new RemoveIncidentCommand($incident));
|
||||
execute(new RemoveIncidentCommand($incident));
|
||||
|
||||
return cachet_redirect('dashboard.incidents')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success')));
|
||||
@@ -246,7 +246,7 @@ class IncidentController extends Controller
|
||||
public function editIncidentAction(Incident $incident)
|
||||
{
|
||||
try {
|
||||
$incident = dispatch(new UpdateIncidentCommand(
|
||||
$incident = execute(new UpdateIncidentCommand(
|
||||
$incident,
|
||||
Binput::get('name'),
|
||||
Binput::get('status'),
|
||||
|
||||
@@ -101,7 +101,7 @@ class IncidentUpdateController extends Controller
|
||||
public function createIncidentUpdateAction(Incident $incident)
|
||||
{
|
||||
try {
|
||||
$incidentUpdate = dispatch(new CreateIncidentUpdateCommand(
|
||||
$incidentUpdate = execute(new CreateIncidentUpdateCommand(
|
||||
$incident,
|
||||
Binput::get('status'),
|
||||
Binput::get('message'),
|
||||
@@ -151,7 +151,7 @@ class IncidentUpdateController extends Controller
|
||||
public function editIncidentUpdateAction(Incident $incident, IncidentUpdate $incidentUpdate)
|
||||
{
|
||||
try {
|
||||
$incidentUpdate = dispatch(new UpdateIncidentUpdateCommand(
|
||||
$incidentUpdate = execute(new UpdateIncidentUpdateCommand(
|
||||
$incidentUpdate,
|
||||
Binput::get('status'),
|
||||
Binput::get('message'),
|
||||
|
||||
@@ -71,7 +71,7 @@ class MetricController extends Controller
|
||||
$metricData = Binput::get('metric');
|
||||
|
||||
try {
|
||||
dispatch(new CreateMetricCommand(
|
||||
execute(new CreateMetricCommand(
|
||||
$metricData['name'],
|
||||
$metricData['suffix'],
|
||||
$metricData['description'],
|
||||
@@ -115,7 +115,7 @@ class MetricController extends Controller
|
||||
*/
|
||||
public function deleteMetricAction(Metric $metric)
|
||||
{
|
||||
dispatch(new RemoveMetricCommand($metric));
|
||||
execute(new RemoveMetricCommand($metric));
|
||||
|
||||
return cachet_redirect('dashboard.metrics')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.delete.success')));
|
||||
@@ -146,7 +146,7 @@ class MetricController extends Controller
|
||||
public function editMetricAction(Metric $metric)
|
||||
{
|
||||
try {
|
||||
dispatch(new UpdateMetricCommand(
|
||||
execute(new UpdateMetricCommand(
|
||||
$metric,
|
||||
Binput::get('name', null, false),
|
||||
Binput::get('suffix', null, false),
|
||||
|
||||
@@ -81,7 +81,7 @@ class ScheduleController extends Controller
|
||||
public function addScheduleAction()
|
||||
{
|
||||
try {
|
||||
dispatch(new CreateScheduleCommand(
|
||||
execute(new CreateScheduleCommand(
|
||||
Binput::get('name'),
|
||||
Binput::get('message', null, false, false),
|
||||
Binput::get('status', Schedule::UPCOMING),
|
||||
@@ -127,7 +127,7 @@ class ScheduleController extends Controller
|
||||
public function editScheduleAction(Schedule $schedule)
|
||||
{
|
||||
try {
|
||||
$schedule = dispatch(new UpdateScheduleCommand(
|
||||
$schedule = execute(new UpdateScheduleCommand(
|
||||
$schedule,
|
||||
Binput::get('name', null),
|
||||
Binput::get('message', null),
|
||||
@@ -156,7 +156,7 @@ class ScheduleController extends Controller
|
||||
*/
|
||||
public function deleteScheduleAction(Schedule $schedule)
|
||||
{
|
||||
dispatch(new DeleteScheduleCommand($schedule));
|
||||
execute(new DeleteScheduleCommand($schedule));
|
||||
|
||||
return cachet_redirect('dashboard.schedule')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.delete.success')));
|
||||
|
||||
@@ -319,7 +319,7 @@ class SettingsController extends Controller
|
||||
{
|
||||
$config = Binput::get('config');
|
||||
|
||||
dispatch(new UpdateConfigCommand($config));
|
||||
execute(new UpdateConfigCommand($config));
|
||||
|
||||
return cachet_redirect('dashboard.settings.mail')
|
||||
->withInput(Binput::all())
|
||||
|
||||
@@ -58,7 +58,7 @@ class SubscriberController extends Controller
|
||||
$subscribers = preg_split("/\r\n|\n|\r/", Binput::get('email'));
|
||||
|
||||
foreach ($subscribers as $subscriber) {
|
||||
dispatch(new SubscribeSubscriberCommand($subscriber, $verified));
|
||||
execute(new SubscribeSubscriberCommand($subscriber, $verified));
|
||||
}
|
||||
} catch (ValidationException $e) {
|
||||
return cachet_redirect('dashboard.subscribers.create')
|
||||
@@ -82,7 +82,7 @@ class SubscriberController extends Controller
|
||||
*/
|
||||
public function deleteSubscriberAction(Subscriber $subscriber)
|
||||
{
|
||||
dispatch(new UnsubscribeSubscriberCommand($subscriber));
|
||||
execute(new UnsubscribeSubscriberCommand($subscriber));
|
||||
|
||||
return cachet_redirect('dashboard.subscribers');
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class TeamController extends Controller
|
||||
public function postAddUser()
|
||||
{
|
||||
try {
|
||||
dispatch(new CreateUserCommand(
|
||||
execute(new CreateUserCommand(
|
||||
Binput::get('username'),
|
||||
Binput::get('password'),
|
||||
Binput::get('email'),
|
||||
@@ -129,7 +129,7 @@ class TeamController extends Controller
|
||||
public function postInviteUser()
|
||||
{
|
||||
try {
|
||||
dispatch(new InviteUserCommand(
|
||||
execute(new InviteUserCommand(
|
||||
array_unique(array_filter((array) Binput::get('emails')))
|
||||
));
|
||||
} catch (ValidationException $e) {
|
||||
@@ -152,7 +152,7 @@ class TeamController extends Controller
|
||||
*/
|
||||
public function deleteUser(User $user)
|
||||
{
|
||||
dispatch(new RemoveUserCommand($user));
|
||||
execute(new RemoveUserCommand($user));
|
||||
|
||||
return cachet_redirect('dashboard.team')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.delete.success')));
|
||||
|
||||
@@ -258,7 +258,7 @@ class SetupController extends Controller
|
||||
$envData = array_pull($postData, 'env');
|
||||
|
||||
// Write the env to the .env file.
|
||||
dispatch(new UpdateConfigCommand($envData));
|
||||
execute(new UpdateConfigCommand($envData));
|
||||
|
||||
if (Request::ajax()) {
|
||||
return Response::json(['status' => 1]);
|
||||
|
||||
@@ -69,7 +69,7 @@ class SignupController extends Controller
|
||||
}
|
||||
|
||||
try {
|
||||
dispatch(new SignupUserCommand(
|
||||
execute(new SignupUserCommand(
|
||||
Binput::get('username'),
|
||||
Binput::get('password'),
|
||||
Binput::get('email'),
|
||||
@@ -82,7 +82,7 @@ class SignupController extends Controller
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
dispatch(new ClaimInviteCommand($invite));
|
||||
execute(new ClaimInviteCommand($invite));
|
||||
|
||||
return cachet_redirect('status-page')
|
||||
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.success')));
|
||||
|
||||
@@ -80,7 +80,7 @@ class SubscribeController extends Controller
|
||||
$verified = app(Repository::class)->get('setting.skip_subscriber_verification');
|
||||
|
||||
try {
|
||||
$subscription = dispatch(new SubscribeSubscriberCommand($email, $verified));
|
||||
$subscription = execute(new SubscribeSubscriberCommand($email, $verified));
|
||||
} catch (ValidationException $e) {
|
||||
return cachet_redirect('status-page')
|
||||
->withInput(Binput::all())
|
||||
@@ -116,7 +116,7 @@ class SubscribeController extends Controller
|
||||
}
|
||||
|
||||
if (!$subscriber->is_verified) {
|
||||
dispatch(new VerifySubscriberCommand($subscriber));
|
||||
execute(new VerifySubscriberCommand($subscriber));
|
||||
}
|
||||
|
||||
return cachet_redirect('status-page')
|
||||
@@ -144,9 +144,9 @@ class SubscribeController extends Controller
|
||||
}
|
||||
|
||||
if ($subscription) {
|
||||
dispatch(new UnsubscribeSubscriptionCommand(Subscription::forSubscriber($subscriber->id)->firstOrFail()));
|
||||
execute(new UnsubscribeSubscriptionCommand(Subscription::forSubscriber($subscriber->id)->firstOrFail()));
|
||||
} else {
|
||||
dispatch(new UnsubscribeSubscriberCommand($subscriber));
|
||||
execute(new UnsubscribeSubscriberCommand($subscriber));
|
||||
}
|
||||
|
||||
return cachet_redirect('status-page')
|
||||
@@ -204,7 +204,7 @@ class SubscribeController extends Controller
|
||||
}
|
||||
|
||||
try {
|
||||
dispatch(new UpdateSubscriberSubscriptionCommand($subscriber, Binput::get('subscriptions')));
|
||||
execute(new UpdateSubscriberSubscriptionCommand($subscriber, Binput::get('subscriptions')));
|
||||
} catch (ValidationException $e) {
|
||||
return cachet_redirect('subscribe.manage', $subscriber->verify_code)
|
||||
->withInput(Binput::all())
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use CachetHQ\Cachet\Settings\Repository;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Jenssegers\Date\Date;
|
||||
@@ -159,3 +160,17 @@ if (!function_exists('cachet_redirect')) {
|
||||
return app('redirect')->to($url, $status, $headers);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('execute')) {
|
||||
/**
|
||||
* Send the given command to the dispatcher for execution.
|
||||
*
|
||||
* @param object $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function execute($command)
|
||||
{
|
||||
app(Dispatcher::class)->execute($command);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user