Compare commits

..

No commits in common. "ab3e52dc3bfdbd26d1f7b976d9f510708ca79f62" and "ad5ef3fd48ec043eec30e63e0054fb9e2247b2a2" have entirely different histories.

6 changed files with 13 additions and 14 deletions

View File

@ -7,7 +7,6 @@ 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;

View File

@ -1,9 +1,8 @@
<?php namespace SokoWeb\Database;
use SokoWeb\Interfaces\Database\IAuditLogger;
use SokoWeb\Interfaces\Database\IConnection;
abstract class AuditLoggerBase implements IAuditLogger
abstract class AuditLoggerBase
{
const LOG_TYPE_INSERT = 'insert';
const LOG_TYPE_UPDATE = 'update';
@ -19,7 +18,7 @@ abstract class AuditLoggerBase implements IAuditLogger
$this->logTable = $logTable;
}
public function logInsert(string $localTable, $localId): void
public function logInsert(string $localTable, $localId)
{
$data = [
'local_table' => $localTable,
@ -33,7 +32,7 @@ abstract class AuditLoggerBase implements IAuditLogger
$stmt->execute($data);
}
public function logUpdate(string $localTable, $localId, array $diff): void
public function logUpdate(string $localTable, $localId, array $diff)
{
$data = [
'local_table' => $localTable,
@ -56,7 +55,7 @@ abstract class AuditLoggerBase implements IAuditLogger
}
}
public function logDelete(string $localTable, $localId, array $attributes): void
public function logDelete(string $localTable, $localId, array $attributes)
{
$data = [
'local_table' => $localTable,

View File

@ -2,6 +2,7 @@
use SokoWeb\Interfaces\Database\IConnection;
use SokoWeb\Database\Utils;
use SokoWeb\Database\AuditLoggerBase;
use SokoWeb\Interfaces\Database\IAuditLogger;
use SokoWeb\Interfaces\Database\IResultSet;
@ -11,7 +12,7 @@ class Modify
private string $table;
private ?IAuditLogger $auditLogger;
private ?AuditLoggerBase $auditLogger;
private string $idName = 'id';
@ -23,7 +24,7 @@ class Modify
private ?array $diff = null;
public function __construct(IConnection $connection, string $table, ?IAuditLogger $auditLogger = null)
public function __construct(IConnection $connection, string $table, ?AuditLoggerBase $auditLogger = null)
{
$this->connection = $connection;
$this->table = $table;

View File

@ -2,9 +2,9 @@
interface IAuditLogger
{
public function logInsert(string $localTable, $localId): void;
public function auditInsert(): void;
public function logUpdate(string $localTable, $localId, array $diff): void;
public function auditUpdate(): void;
public function logDelete(string $localTable, $localId, array $attributes): void;
public function auditDelete(): void;
}

View File

@ -117,7 +117,7 @@ class PersistentDataManager
$modified = $model->toArray();
$id = $model->getId();
$modify = new Modify(\Container::$dbConnection, $model::getTable(), \Container::$auditLogger);
$modify = new Modify(\Container::$dbConnection, $model::getTable());
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(), \Container::$auditLogger);
$modify = new Modify(\Container::$dbConnection, $model::getTable());
$modify->setId($model->getId());
$modify->delete();

View File

@ -15,7 +15,7 @@ $dotenv->load();
class Container
{
static SokoWeb\Interfaces\Database\IConnection $dbConnection;
static SokoWeb\Interfaces\Database\IAuditLogger $auditLogger;
static SokoWeb\Database\AuditLoggerBase $auditLogger;
static SokoWeb\Routing\RouteCollection $routeCollection;
static SokoWeb\Interfaces\Session\ISessionHandler $sessionHandler;
static SokoWeb\Interfaces\Request\IRequest $request;