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
@@ -13,6 +13,12 @@ namespace CachetHQ\Cachet\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\EventInterface;
/**
* This is the metric event interface.
*
* @author Graham Campbell <graham@alt-three.com>
* @author James Brooks <james@alt-three.com>
*/
interface MetricEventInterface extends EventInterface
{
//
@@ -11,10 +11,19 @@
namespace CachetHQ\Cachet\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Cachet\Models\User;
final class MetricPointWasAddedEvent implements MetricEventInterface
final class MetricPointWasAddedEvent implements ActionInterface, MetricEventInterface
{
/**
* The user who added the metric point.
*
* @var \CachetHQ\Cachet\Models\User
*/
public $user;
/**
* The metric point that was added.
*
@@ -25,12 +34,14 @@ final class MetricPointWasAddedEvent implements MetricEventInterface
/**
* Create a new metric point was added event instance.
*
* @param \CachetHQ\Cachet\Models\User $user
* @param \CachetHQ\Cachet\Models\MetricPoint $metricPoint
*
* @return void
*/
public function __construct(MetricPoint $metricPoint)
public function __construct(User $user, MetricPoint $metricPoint)
{
$this->user = $user;
$this->metricPoint = $metricPoint;
}
@@ -43,4 +54,17 @@ final class MetricPointWasAddedEvent implements MetricEventInterface
{
return 'Metric Point was added.';
}
/**
* Get the event action.
*
* @return array
*/
public function getAction()
{
return [
'user' => $this->user,
'description' => (string) $this,
];
}
}
@@ -11,10 +11,19 @@
namespace CachetHQ\Cachet\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Cachet\Models\User;
final class MetricPointWasRemovedEvent implements MetricEventInterface
final class MetricPointWasRemovedEvent implements ActionInterface, MetricEventInterface
{
/**
* The user who removed the metric point.
*
* @var \CachetHQ\Cachet\Models\User
*/
public $user;
/**
* The metric point that was removed.
*
@@ -25,12 +34,14 @@ final class MetricPointWasRemovedEvent implements MetricEventInterface
/**
* Create a new metric point was removed event instance.
*
* @param \CachetHQ\Cachet\Models\User $user
* @param \CachetHQ\Cachet\Models\MetricPoint $memtricPoint
*
* @return void
*/
public function __construct(MetricPoint $metricPoint)
public function __construct(User $user, MetricPoint $metricPoint)
{
$this->user = $user;
$this->metricPoint = $metricPoint;
}
@@ -43,4 +54,17 @@ final class MetricPointWasRemovedEvent implements MetricEventInterface
{
return 'Metric Point was removed.';
}
/**
* Get the event action.
*
* @return array
*/
public function getAction()
{
return [
'user' => $this->user,
'description' => (string) $this,
];
}
}
@@ -11,10 +11,19 @@
namespace CachetHQ\Cachet\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Cachet\Models\User;
final class MetricPointWasUpdatedEvent implements MetricEventInterface
final class MetricPointWasUpdatedEvent implements ActionInterface, MetricEventInterface
{
/**
* The user who updated the metric point.
*
* @var \CachetHQ\Cachet\Models\User
*/
public $user;
/**
* The metric point that was updated.
*
@@ -25,12 +34,14 @@ final class MetricPointWasUpdatedEvent implements MetricEventInterface
/**
* Create a new metric point was updated event instance.
*
* @param \CachetHQ\Cachet\Models\User $user
* @param \CachetHQ\Cachet\Models\MetricPoint $metricPoint
*
* @return void
*/
public function __construct(MetricPoint $metricPoint)
public function __construct(User $user, MetricPoint $metricPoint)
{
$this->user = $user;
$this->metricPoint = $metricPoint;
}
@@ -43,4 +54,17 @@ final class MetricPointWasUpdatedEvent implements MetricEventInterface
{
return 'Metric Point was updated.';
}
/**
* Get the event action.
*
* @return array
*/
public function getAction()
{
return [
'user' => $this->user,
'description' => (string) $this,
];
}
}
+26 -2
View File
@@ -11,10 +11,19 @@
namespace CachetHQ\Cachet\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\User;
final class MetricWasAddedEvent implements MetricEventInterface
final class MetricWasAddedEvent implements ActionInterface, MetricEventInterface
{
/**
* The user who added the metric.
*
* @var \CachetHQ\Cachet\Models\User
*/
public $user;
/**
* The metric that was added.
*
@@ -25,12 +34,14 @@ final class MetricWasAddedEvent implements MetricEventInterface
/**
* Create a new metric was added event instance.
*
* @param \CachetHQ\Cachet\Models\User $user
* @param \CachetHQ\Cachet\Models\Metric $metric
*
* @return void
*/
public function __construct(Metric $metric)
public function __construct(User $user, Metric $metric)
{
$this->user = $user;
$this->metric = $metric;
}
@@ -43,4 +54,17 @@ final class MetricWasAddedEvent implements MetricEventInterface
{
return 'Metric was added.';
}
/**
* Get the event action.
*
* @return array
*/
public function getAction()
{
return [
'user' => $this->user,
'description' => (string) $this,
];
}
}
@@ -11,10 +11,19 @@
namespace CachetHQ\Cachet\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\User;
final class MetricWasRemovedEvent implements MetricEventInterface
final class MetricWasRemovedEvent implements ActionInterface, MetricEventInterface
{
/**
* The user who removed the metric.
*
* @var \CachetHQ\Cachet\Models\User
*/
public $user;
/**
* The metric that was removed.
*
@@ -25,12 +34,14 @@ final class MetricWasRemovedEvent implements MetricEventInterface
/**
* Create a new metric was removed event instance.
*
* @param \CachetHQ\Cachet\Models\User $user
* @param \CachetHQ\Cachet\Models\Metric $metric
*
* @return void
*/
public function __construct(Metric $metric)
public function __construct(User $user, Metric $metric)
{
$this->user = $user;
$this->metric = $metric;
}
@@ -43,4 +54,17 @@ final class MetricWasRemovedEvent implements MetricEventInterface
{
return 'Metric was removed.';
}
/**
* Get the event action.
*
* @return array
*/
public function getAction()
{
return [
'user' => $this->user,
'description' => (string) $this,
];
}
}
@@ -11,10 +11,19 @@
namespace CachetHQ\Cachet\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\User;
final class MetricWasUpdatedEvent implements MetricEventInterface
final class MetricWasUpdatedEvent implements ActionInterface, MetricEventInterface
{
/**
* The user who update the metric.
*
* @var \CachetHQ\Cachet\Models\User
*/
public $user;
/**
* The metric that was updated.
*
@@ -25,12 +34,14 @@ final class MetricWasUpdatedEvent implements MetricEventInterface
/**
* Create a new metric was updated event instance.
*
* @param \CachetHQ\Cachet\Models\User $user
* @param \CachetHQ\Cachet\Models\Metric $metric
*
* @return void
*/
public function __construct(Metric $metric)
public function __construct(User $user, Metric $metric)
{
$this->user = $user;
$this->metric = $metric;
}
@@ -43,4 +54,17 @@ final class MetricWasUpdatedEvent implements MetricEventInterface
{
return 'Metric was updated.';
}
/**
* Get the event action.
*
* @return array
*/
public function getAction()
{
return [
'user' => $this->user,
'description' => (string) $this,
];
}
}