Compare commits
2 Commits
ad5ef3fd48
...
ab3e52dc3b
Author | SHA1 | Date | |
---|---|---|---|
ab3e52dc3b | |||
8ed2f4c15c |
@ -7,6 +7,7 @@ const ROOT = __DIR__;
|
||||
class Container
|
||||
{
|
||||
static SokoWeb\Interfaces\Database\IConnection $dbConnection;
|
||||
static SokoWeb\Interfaces\Database\IAuditLogger $auditLogger;
|
||||
static SokoWeb\Routing\RouteCollection $routeCollection;
|
||||
static SokoWeb\Interfaces\Session\ISessionHandler $sessionHandler;
|
||||
static SokoWeb\Interfaces\Request\IRequest $request;
|
||||
|
@ -1,8 +1,9 @@
|
||||
<?php namespace SokoWeb\Database;
|
||||
|
||||
use SokoWeb\Interfaces\Database\IAuditLogger;
|
||||
use SokoWeb\Interfaces\Database\IConnection;
|
||||
|
||||
abstract class AuditLoggerBase
|
||||
abstract class AuditLoggerBase implements IAuditLogger
|
||||
{
|
||||
const LOG_TYPE_INSERT = 'insert';
|
||||
const LOG_TYPE_UPDATE = 'update';
|
||||
@ -18,7 +19,7 @@ abstract class AuditLoggerBase
|
||||
$this->logTable = $logTable;
|
||||
}
|
||||
|
||||
public function logInsert(string $localTable, $localId)
|
||||
public function logInsert(string $localTable, $localId): void
|
||||
{
|
||||
$data = [
|
||||
'local_table' => $localTable,
|
||||
@ -32,7 +33,7 @@ abstract class AuditLoggerBase
|
||||
$stmt->execute($data);
|
||||
}
|
||||
|
||||
public function logUpdate(string $localTable, $localId, array $diff)
|
||||
public function logUpdate(string $localTable, $localId, array $diff): void
|
||||
{
|
||||
$data = [
|
||||
'local_table' => $localTable,
|
||||
@ -55,7 +56,7 @@ abstract class AuditLoggerBase
|
||||
}
|
||||
}
|
||||
|
||||
public function logDelete(string $localTable, $localId, array $attributes)
|
||||
public function logDelete(string $localTable, $localId, array $attributes): void
|
||||
{
|
||||
$data = [
|
||||
'local_table' => $localTable,
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
use SokoWeb\Interfaces\Database\IConnection;
|
||||
use SokoWeb\Database\Utils;
|
||||
use SokoWeb\Database\AuditLoggerBase;
|
||||
use SokoWeb\Interfaces\Database\IAuditLogger;
|
||||
use SokoWeb\Interfaces\Database\IResultSet;
|
||||
|
||||
@ -12,7 +11,7 @@ class Modify
|
||||
|
||||
private string $table;
|
||||
|
||||
private ?AuditLoggerBase $auditLogger;
|
||||
private ?IAuditLogger $auditLogger;
|
||||
|
||||
private string $idName = 'id';
|
||||
|
||||
@ -24,7 +23,7 @@ class Modify
|
||||
|
||||
private ?array $diff = null;
|
||||
|
||||
public function __construct(IConnection $connection, string $table, ?AuditLoggerBase $auditLogger = null)
|
||||
public function __construct(IConnection $connection, string $table, ?IAuditLogger $auditLogger = null)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->table = $table;
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
interface IAuditLogger
|
||||
{
|
||||
public function auditInsert(): void;
|
||||
public function logInsert(string $localTable, $localId): void;
|
||||
|
||||
public function auditUpdate(): void;
|
||||
public function logUpdate(string $localTable, $localId, array $diff): void;
|
||||
|
||||
public function auditDelete(): void;
|
||||
public function logDelete(string $localTable, $localId, array $attributes): void;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class PersistentDataManager
|
||||
$modified = $model->toArray();
|
||||
$id = $model->getId();
|
||||
|
||||
$modify = new Modify(\Container::$dbConnection, $model::getTable());
|
||||
$modify = new Modify(\Container::$dbConnection, $model::getTable(), \Container::$auditLogger);
|
||||
|
||||
if ($id !== null) {
|
||||
$original = $model->getSnapshot();
|
||||
@ -149,7 +149,7 @@ class PersistentDataManager
|
||||
|
||||
public function deleteFromDb(Model $model): void
|
||||
{
|
||||
$modify = new Modify(\Container::$dbConnection, $model::getTable());
|
||||
$modify = new Modify(\Container::$dbConnection, $model::getTable(), \Container::$auditLogger);
|
||||
$modify->setId($model->getId());
|
||||
$modify->delete();
|
||||
|
||||
|
@ -15,7 +15,7 @@ $dotenv->load();
|
||||
class Container
|
||||
{
|
||||
static SokoWeb\Interfaces\Database\IConnection $dbConnection;
|
||||
static SokoWeb\Database\AuditLoggerBase $auditLogger;
|
||||
static SokoWeb\Interfaces\Database\IAuditLogger $auditLogger;
|
||||
static SokoWeb\Routing\RouteCollection $routeCollection;
|
||||
static SokoWeb\Interfaces\Session\ISessionHandler $sessionHandler;
|
||||
static SokoWeb\Interfaces\Request\IRequest $request;
|
||||
|
Loading…
Reference in New Issue
Block a user