Add event action storage. Closes #2344

This commit is contained in:
James Brooks
2017-02-03 22:34:13 +00:00
parent c2790e29cc
commit 3dc154dff1
92 changed files with 1512 additions and 128 deletions
@@ -14,9 +14,29 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\Component;
use CachetHQ\Cachet\Bus\Commands\Component\AddComponentCommand;
use CachetHQ\Cachet\Bus\Events\Component\ComponentWasAddedEvent;
use CachetHQ\Cachet\Models\Component;
use Illuminate\Contracts\Auth\Guard;
class AddComponentCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new remove component command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the add component command.
*
@@ -28,7 +48,7 @@ class AddComponentCommandHandler
{
$component = Component::create($this->filter($command));
event(new ComponentWasAddedEvent($component));
event(new ComponentWasAddedEvent($this->auth->user(), $component));
return $component;
}
@@ -13,9 +13,29 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\Component;
use CachetHQ\Cachet\Bus\Commands\Component\RemoveComponentCommand;
use CachetHQ\Cachet\Bus\Events\Component\ComponentWasRemovedEvent;
use Illuminate\Contracts\Auth\Guard;
class RemoveComponentCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new remove component command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the remove component command.
*
@@ -27,7 +47,7 @@ class RemoveComponentCommandHandler
{
$component = $command->component;
event(new ComponentWasRemovedEvent($component));
event(new ComponentWasRemovedEvent($this->auth->user(), $component));
$component->delete();
}
@@ -15,9 +15,29 @@ use CachetHQ\Cachet\Bus\Commands\Component\UpdateComponentCommand;
use CachetHQ\Cachet\Bus\Events\Component\ComponentStatusWasUpdatedEvent;
use CachetHQ\Cachet\Bus\Events\Component\ComponentWasUpdatedEvent;
use CachetHQ\Cachet\Models\Component;
use Illuminate\Contracts\Auth\Guard;
class UpdateComponentCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new update component command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the update component command.
*
@@ -30,11 +50,11 @@ class UpdateComponentCommandHandler
$component = $command->component;
$originalStatus = $component->status;
event(new ComponentStatusWasUpdatedEvent($component, $originalStatus, $command->status));
event(new ComponentStatusWasUpdatedEvent($this->auth->user(), $component, $originalStatus, $command->status));
$component->update($this->filter($command));
event(new ComponentWasUpdatedEvent($component));
event(new ComponentWasUpdatedEvent($this->auth->user(), $component));
return $component;
}
@@ -14,9 +14,29 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\ComponentGroup;
use CachetHQ\Cachet\Bus\Commands\ComponentGroup\AddComponentGroupCommand;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasAddedEvent;
use CachetHQ\Cachet\Models\ComponentGroup;
use Illuminate\Contracts\Auth\Guard;
class AddComponentGroupCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new add component group command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the add component group command.
*
@@ -33,7 +53,7 @@ class AddComponentGroupCommandHandler
'visible' => $command->visible,
]);
event(new ComponentGroupWasAddedEvent($group));
event(new ComponentGroupWasAddedEvent($this->auth->user(), $group));
return $group;
}
@@ -13,9 +13,29 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\ComponentGroup;
use CachetHQ\Cachet\Bus\Commands\ComponentGroup\RemoveComponentGroupCommand;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasRemovedEvent;
use Illuminate\Contracts\Auth\Guard;
class RemoveComponentGroupCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new remove component group command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the remove component group command.
*
@@ -27,7 +47,7 @@ class RemoveComponentGroupCommandHandler
{
$group = $command->group;
event(new ComponentGroupWasRemovedEvent($group));
event(new ComponentGroupWasRemovedEvent($this->auth->user(), $group));
// Remove the group id from all component.
$group->components->map(function ($component) {
@@ -13,9 +13,29 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\ComponentGroup;
use CachetHQ\Cachet\Bus\Commands\ComponentGroup\UpdateComponentGroupCommand;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasUpdatedEvent;
use Illuminate\Contracts\Auth\Guard;
class UpdateComponentGroupCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new update component command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the update component group command.
*
@@ -28,7 +48,7 @@ class UpdateComponentGroupCommandHandler
$group = $command->group;
$group->update($this->filter($command));
event(new ComponentGroupWasUpdatedEvent($group));
event(new ComponentGroupWasUpdatedEvent($this->auth->user(), $group));
return $group;
}
@@ -13,9 +13,29 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\Incident;
use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasRemovedEvent;
use Illuminate\Contracts\Auth\Guard;
class RemoveIncidentCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new remove incident command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the remove incident command.
*
@@ -27,7 +47,7 @@ class RemoveIncidentCommandHandler
{
$incident = $command->incident;
event(new IncidentWasRemovedEvent($incident));
event(new IncidentWasRemovedEvent($this->auth->user(), $incident));
$incident->delete();
}
@@ -20,6 +20,7 @@ use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
use CachetHQ\Cachet\Services\Dates\DateFactory;
use Carbon\Carbon;
use Illuminate\Contracts\Auth\Guard;
use Twig_Environment;
use Twig_Loader_Array;
@@ -30,6 +31,13 @@ use Twig_Loader_Array;
*/
class ReportIncidentCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* The date factory instance.
*
@@ -40,12 +48,14 @@ class ReportIncidentCommandHandler
/**
* Create a new report incident command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \CachetHQ\Cachet\Services\Dates\DateFactory $dates
*
* @return void
*/
public function __construct(DateFactory $dates)
public function __construct(Guard $auth, DateFactory $dates)
{
$this->auth = $auth;
$this->dates = $dates;
}
@@ -105,7 +115,7 @@ class ReportIncidentCommandHandler
));
}
event(new IncidentWasReportedEvent($incident, (bool) $command->notify));
event(new IncidentWasReportedEvent($this->auth->user(), $incident, (bool) $command->notify));
return $incident;
}
@@ -19,6 +19,7 @@ use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
use CachetHQ\Cachet\Services\Dates\DateFactory;
use Illuminate\Contracts\Auth\Guard;
use Twig_Environment;
use Twig_Loader_Array;
@@ -29,6 +30,13 @@ use Twig_Loader_Array;
*/
class UpdateIncidentCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* The date factory instance.
*
@@ -39,12 +47,14 @@ class UpdateIncidentCommandHandler
/**
* Create a new update incident command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \CachetHQ\Cachet\Services\Dates\DateFactory $dates
*
* @return void
*/
public function __construct(DateFactory $dates)
public function __construct(Guard $auth, DateFactory $dates)
{
$this->auth = $auth;
$this->dates = $dates;
}
@@ -91,7 +101,7 @@ class UpdateIncidentCommandHandler
));
}
event(new IncidentWasUpdatedEvent($incident));
event(new IncidentWasUpdatedEvent($this->auth->user(), $incident));
return $incident;
}
@@ -13,6 +13,7 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\RemoveIncidentUpdateCommand;
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasRemovedEvent;
use Illuminate\Contracts\Auth\Guard;
/**
* This is the remove incident update command handler.
@@ -21,6 +22,25 @@ use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasRemovedEvent;
*/
class RemoveIncidentUpdateCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new remove incident update command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the remove incident update command.
*
@@ -32,7 +52,7 @@ class RemoveIncidentUpdateCommandHandler
{
$update = $command->incidentUpdate;
event(new IncidentUpdateWasRemovedEvent($update));
event(new IncidentUpdateWasRemovedEvent($this->auth->user(), $update));
$update->delete();
}
@@ -15,6 +15,7 @@ use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand;
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasReportedEvent;
use CachetHQ\Cachet\Models\IncidentUpdate;
use Illuminate\Contracts\Auth\Guard;
/**
* This is the report incident update command handler.
@@ -23,6 +24,25 @@ use CachetHQ\Cachet\Models\IncidentUpdate;
*/
class ReportIncidentUpdateCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new report incident update command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the report incident command.
*
@@ -58,7 +78,7 @@ class ReportIncidentUpdateCommandHandler
[]
));
event(new IncidentUpdateWasReportedEvent($update));
event(new IncidentUpdateWasReportedEvent($this->auth->user(), $update));
return $update;
}
@@ -13,6 +13,7 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand;
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasUpdatedEvent;
use Illuminate\Contracts\Auth\Guard;
/**
* This is the update incident update command handler.
@@ -21,6 +22,25 @@ use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasUpdatedEvent;
*/
class UpdateIncidentUpdateCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new update incident update command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the update incident update command.
*
@@ -32,7 +52,7 @@ class UpdateIncidentUpdateCommandHandler
{
$command->update->update($this->filter($command));
event(new IncidentUpdateWasUpdatedEvent($command->update));
event(new IncidentUpdateWasUpdatedEvent($this->auth->user(), $command->update));
return $command->update;
}
@@ -14,9 +14,29 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\Metric;
use CachetHQ\Cachet\Bus\Commands\Metric\AddMetricCommand;
use CachetHQ\Cachet\Bus\Events\Metric\MetricWasAddedEvent;
use CachetHQ\Cachet\Models\Metric;
use Illuminate\Contracts\Auth\Guard;
class AddMetricCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new add metric command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the add metric command.
*
@@ -40,7 +60,7 @@ class AddMetricCommandHandler
'visible' => $command->visible,
]);
event(new MetricWasAddedEvent($metric));
event(new MetricWasAddedEvent($this->auth->user(), $metric));
return $metric;
}
@@ -16,9 +16,17 @@ use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasAddedEvent;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Cachet\Services\Dates\DateFactory;
use Carbon\Carbon;
use Illuminate\Contracts\Auth\Guard;
class AddMetricPointCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* The date factory instance.
*
@@ -29,12 +37,14 @@ class AddMetricPointCommandHandler
/**
* Create a new add metric point command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \CachetHQ\Cachet\Services\Dates\DateFactory $dates
*
* @return void
*/
public function __construct(DateFactory $dates)
public function __construct(Guard $auth, DateFactory $dates)
{
$this->auth = $auth;
$this->dates = $dates;
}
@@ -55,7 +65,7 @@ class AddMetricPointCommandHandler
$point->increment('counter', 1);
event(new MetricPointWasAddedEvent($point));
event(new MetricPointWasAddedEvent($this->auth->user(), $point));
return $point;
}
@@ -14,9 +14,29 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\Metric;
use CachetHQ\Cachet\Bus\Commands\Metric\RemoveMetricCommand;
use CachetHQ\Cachet\Bus\Events\Metric\MetricWasRemovedEvent;
use CachetHQ\Cachet\Models\Metric;
use Illuminate\Contracts\Auth\Guard;
class RemoveMetricCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new remove metric command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the remove metric command.
*
@@ -28,7 +48,7 @@ class RemoveMetricCommandHandler
{
$metric = $command->metric;
event(new MetricWasRemovedEvent($metric));
event(new MetricWasRemovedEvent($this->auth->user(), $metric));
$metric->delete();
}
@@ -14,9 +14,29 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\Metric;
use CachetHQ\Cachet\Bus\Commands\Metric\RemoveMetricPointCommand;
use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasRemovedEvent;
use CachetHQ\Cachet\Models\Metric;
use Illuminate\Contracts\Auth\Guard;
class RemoveMetricPointCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new remove metric point command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the remove metric point command.
*
@@ -28,7 +48,7 @@ class RemoveMetricPointCommandHandler
{
$metricPoint = $command->metricPoint;
event(new MetricPointWasRemovedEvent($metricPoint));
event(new MetricPointWasRemovedEvent($this->auth->user(), $metricPoint));
$metricPoint->delete();
}
@@ -14,9 +14,29 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\Metric;
use CachetHQ\Cachet\Bus\Commands\Metric\UpdateMetricCommand;
use CachetHQ\Cachet\Bus\Events\Metric\MetricWasUpdatedEvent;
use CachetHQ\Cachet\Models\Metric;
use Illuminate\Contracts\Auth\Guard;
class UpdateMetricCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new update metric command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the update metric command.
*
@@ -30,7 +50,7 @@ class UpdateMetricCommandHandler
$metric->update($this->filter($command));
event(new MetricWasUpdatedEvent($metric));
event(new MetricWasUpdatedEvent($this->auth->user(), $metric));
return $metric;
}
@@ -14,9 +14,17 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\Metric;
use CachetHQ\Cachet\Bus\Commands\Metric\UpdateMetricPointCommand;
use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasUpdatedEvent;
use CachetHQ\Cachet\Services\Dates\DateFactory;
use Illuminate\Contracts\Auth\Guard;
class UpdateMetricPointCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* The date factory instance.
*
@@ -27,12 +35,14 @@ class UpdateMetricPointCommandHandler
/**
* Create a new update metric point command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \CachetHQ\Cachet\Services\Dates\DateFactory $dates
*
* @return void
*/
public function __construct(DateFactory $dates)
public function __construct(Guard $auth, DateFactory $dates)
{
$this->auth = $auth;
$this->dates = $dates;
}
@@ -60,7 +70,7 @@ class UpdateMetricPointCommandHandler
$point->update($data);
event(new MetricPointWasUpdatedEvent($point));
event(new MetricPointWasUpdatedEvent($this->auth->user(), $point));
return $point;
}
@@ -15,6 +15,7 @@ use CachetHQ\Cachet\Bus\Commands\Schedule\CreateScheduleCommand;
use CachetHQ\Cachet\Bus\Events\Schedule\ScheduleWasCreatedEvent;
use CachetHQ\Cachet\Models\Schedule;
use CachetHQ\Cachet\Services\Dates\DateFactory;
use Illuminate\Contracts\Auth\Guard;
/**
* This is the create schedule command handler.
@@ -23,6 +24,13 @@ use CachetHQ\Cachet\Services\Dates\DateFactory;
*/
class CreateScheduleCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* The date factory instance.
*
@@ -33,12 +41,14 @@ class CreateScheduleCommandHandler
/**
* Create a new update schedule command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \CachetHQ\Cachet\Services\Dates\DateFactory $dates
*
* @return void
*/
public function __construct(DateFactory $dates)
public function __construct(Guard $auth, DateFactory $dates)
{
$this->auth = $auth;
$this->dates = $dates;
}
@@ -53,7 +63,7 @@ class CreateScheduleCommandHandler
{
$schedule = Schedule::create($this->filter($command));
event(new ScheduleWasCreatedEvent($schedule));
event(new ScheduleWasCreatedEvent($this->auth->user(), $schedule));
return $schedule;
}
@@ -13,6 +13,7 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\Schedule;
use CachetHQ\Cachet\Bus\Commands\Schedule\DeleteScheduleCommand;
use CachetHQ\Cachet\Bus\Events\Schedule\ScheduleWasRemovedEvent;
use Illuminate\Contracts\Auth\Guard;
/**
* This is the delete schedule command handler.
@@ -21,6 +22,25 @@ use CachetHQ\Cachet\Bus\Events\Schedule\ScheduleWasRemovedEvent;
*/
class DeleteScheduleCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* Create a new delete schedule command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle the delete schedule command.
*
@@ -32,7 +52,7 @@ class DeleteScheduleCommandHandler
{
$schedule = $command->schedule;
event(new ScheduleWasRemovedEvent($schedule));
event(new ScheduleWasRemovedEvent($this->auth->user(), $schedule));
$schedule->delete();
}
@@ -15,6 +15,7 @@ use CachetHQ\Cachet\Bus\Commands\Schedule\UpdateScheduleCommand;
use CachetHQ\Cachet\Bus\Events\Schedule\ScheduleWasUpdatedEvent;
use CachetHQ\Cachet\Models\Schedule;
use CachetHQ\Cachet\Services\Dates\DateFactory;
use Illuminate\Contracts\Auth\Guard;
/**
* This is the update schedule command handler.
@@ -23,6 +24,13 @@ use CachetHQ\Cachet\Services\Dates\DateFactory;
*/
class UpdateScheduleCommandHandler
{
/**
* The authentication guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* The date factory instance.
*
@@ -33,12 +41,14 @@ class UpdateScheduleCommandHandler
/**
* Create a new update schedule command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \CachetHQ\Cachet\Services\Dates\DateFactory $dates
*
* @return void
*/
public function __construct(DateFactory $dates)
public function __construct(Guard $auth, DateFactory $dates)
{
$this->auth = $auth;
$this->dates = $dates;
}
@@ -55,7 +65,7 @@ class UpdateScheduleCommandHandler
$schedule->update($this->filter($command));
event(new ScheduleWasUpdatedEvent($schedule));
event(new ScheduleWasUpdatedEvent($this->auth->user(), $schedule));
return $schedule;
}
@@ -0,0 +1,49 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Bus\Handlers\Events;
use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\Action;
/**
* This is the action storage handler class.
*
* @author Graham Campbell <graham@alt-three.com>
* @author James Brooks <james@alt-three.com>
*/
class ActionStorageHandler
{
/**
* Handle the any actions that need storing.
*
* @param \CachetHQ\Cachet\Bus\Events\ActionInterface $event
*
* @return void
*/
public function handle(ActionInterface $event)
{
$data = $event->getAction();
$action = [
'class_name' => get_class($event),
'user_id' => $data['user']->id,
'username' => $data['user']->username,
'description' => $data['description'],
];
if ($data['information'] ?? null) {
$action['information'] = $data['information'];
}
Action::create($action);
}
}