Skip to content

Commit

Permalink
Add extra fields and indices to audit tables, based on configuration D…
Browse files Browse the repository at this point in the history
  • Loading branch information
wouter-toppy committed Nov 30, 2023
1 parent 3101c09 commit 882d317
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Model/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ final class Entry

private string $diffs;

private array $extra_fields = [];

private int|null|string $blame_id = null;

private ?string $blame_user = null;
Expand All @@ -43,6 +45,28 @@ public function getId(): int
return $this->id;
}

public function setExtraField($key, $value = null): void
{
if ($key === (array)$key) {
$this->extra_fields = $key;
} else {
$this->extra_fields[$key] = $value;
}
}

public function getExtraField($key = ''): mixed
{
if ('' === $key) {
return $this->extra_fields;
}

if (isset($this->extra_fields[$key])) {
return $this->extra_fields[$key];
}

return null;
}

/**
* Get the value of type.
*/
Expand Down Expand Up @@ -137,6 +161,8 @@ public static function fromArray(array $row): self
foreach ($row as $key => $value) {
if (property_exists($entry, $key)) {
$entry->{$key} = 'id' === $key ? (int) $value : $value;
} else {
$entry->extra_fields[$key] = $value;
}
}

Expand Down

0 comments on commit 882d317

Please sign in to comment.