diff --git a/dummy.php b/dummy.php index f3e0693..0437e18 100644 --- a/dummy.php +++ b/dummy.php @@ -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; diff --git a/src/Database/AuditLoggerBase.php b/src/Database/AuditLoggerBase.php index d8310fa..e50f43c 100644 --- a/src/Database/AuditLoggerBase.php +++ b/src/Database/AuditLoggerBase.php @@ -1,8 +1,9 @@ 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, diff --git a/src/Database/Query/Modify.php b/src/Database/Query/Modify.php index fa5d7a4..8246e0e 100755 --- a/src/Database/Query/Modify.php +++ b/src/Database/Query/Modify.php @@ -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; diff --git a/src/Interfaces/Database/IAuditLogger.php b/src/Interfaces/Database/IAuditLogger.php index e60d4cc..1bb8d6d 100644 --- a/src/Interfaces/Database/IAuditLogger.php +++ b/src/Interfaces/Database/IAuditLogger.php @@ -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; } diff --git a/src/PersistentData/PersistentDataManager.php b/src/PersistentData/PersistentDataManager.php index b199548..42dcb33 100644 --- a/src/PersistentData/PersistentDataManager.php +++ b/src/PersistentData/PersistentDataManager.php @@ -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();