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

View File

@@ -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,

View File

@@ -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')));

View File

@@ -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,

View File

@@ -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;

View File

@@ -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'),

View File

@@ -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'),

View File

@@ -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),

View File

@@ -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')));

View File

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

View File

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

View File

@@ -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')));