feature/audit-logger #7
@ -15,9 +15,11 @@ $dotenv->load();
 | 
				
			|||||||
class Container
 | 
					class Container
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SokoWeb\Interfaces\Database\IConnection $dbConnection;
 | 
					    static SokoWeb\Interfaces\Database\IConnection $dbConnection;
 | 
				
			||||||
 | 
					    static SokoWeb\Interfaces\Database\IAuditLogger $auditLogger;
 | 
				
			||||||
    static SokoWeb\Routing\RouteCollection $routeCollection;
 | 
					    static SokoWeb\Routing\RouteCollection $routeCollection;
 | 
				
			||||||
    static SokoWeb\Interfaces\Session\ISessionHandler $sessionHandler;
 | 
					    static SokoWeb\Interfaces\Session\ISessionHandler $sessionHandler;
 | 
				
			||||||
    static SokoWeb\Interfaces\Request\IRequest $request;
 | 
					    static SokoWeb\Interfaces\Request\IRequest $request;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Container::$dbConnection = new SokoWeb\Database\Mysql\Connection($_ENV['DB_HOST'], $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $_ENV['DB_NAME']);
 | 
					Container::$dbConnection = new SokoWeb\Database\Mysql\Connection($_ENV['DB_HOST'], $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $_ENV['DB_NAME']);
 | 
				
			||||||
 | 
					Container::$auditLogger = new {app}\Database\AuditLogger(Container::$dbConnection, 'audit_log');
 | 
				
			||||||
 | 
				
			|||||||
@ -13,3 +13,16 @@ CREATE TABLE `users` (
 | 
				
			|||||||
  UNIQUE KEY `email` (`email`),
 | 
					  UNIQUE KEY `email` (`email`),
 | 
				
			||||||
  UNIQUE KEY `google_sub` (`google_sub`)
 | 
					  UNIQUE KEY `google_sub` (`google_sub`)
 | 
				
			||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
 | 
					) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CREATE TABLE `audit_log` (
 | 
				
			||||||
 | 
					  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 | 
				
			||||||
 | 
					  `local_table` varchar(255) NOT NULL,
 | 
				
			||||||
 | 
					  `local_id` int(10) unsigned NOT NULL,
 | 
				
			||||||
 | 
					  `type` enum('insert','update','delete') NOT NULL,
 | 
				
			||||||
 | 
					  `date` timestamp NOT NULL DEFAULT current_timestamp(),
 | 
				
			||||||
 | 
					  `modifier_id` int(10) unsigned NULL,
 | 
				
			||||||
 | 
					  `column` varchar(255) NULL,
 | 
				
			||||||
 | 
					  `old` text NULL,
 | 
				
			||||||
 | 
					  `new` text NULL,
 | 
				
			||||||
 | 
					  PRIMARY KEY (`id`)
 | 
				
			||||||
 | 
					) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										11
									
								
								templates/src/Database/AuditLogger.php.tpl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								templates/src/Database/AuditLogger.php.tpl
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					<?php namespace {app}\Database;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use SokoWeb\Database\AuditLoggerBase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AuditLogger extends AuditLoggerBase
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    protected function getModifierId()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        \Container::$request->user()->getUniqueId();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user