Add new activity logging code to replace audit log

This commit is contained in:
DaneEveritt 2022-05-28 15:36:26 -04:00
parent c14c7b436e
commit 5bb66a00d8
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
11 changed files with 534 additions and 0 deletions

View file

@ -0,0 +1,47 @@
<?php
namespace Pterodactyl\Services\Activity;
use InvalidArgumentException;
use Illuminate\Database\Eloquent\Model;
class ActivityLogTargetableService
{
protected ?Model $actor = null;
protected ?Model $subject = null;
public function setActor(Model $actor): void
{
if (!is_null($this->actor)) {
throw new InvalidArgumentException('Cannot call ' . __METHOD__ . ' when an actor is already set on the instance.');
}
$this->actor = $actor;
}
public function setSubject(Model $subject): void
{
if (!is_null($this->subject)) {
throw new InvalidArgumentException('Cannot call ' . __METHOD__ . ' when a target is already set on the instance.');
}
$this->subject = $subject;
}
public function actor(): ?Model
{
return $this->actor;
}
public function subject(): ?Model
{
return $this->subject;
}
public function reset(): void
{
$this->actor = null;
$this->subject = null;
}
}