feature/database-transactions #9
@ -4,6 +4,7 @@ use SokoWeb\Interfaces\Response\IRedirect;
|
||||
use SokoWeb\Interfaces\Response\IContent;
|
||||
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
||||
use SokoWeb\Interfaces\Database\IConnection;
|
||||
use SokoWeb\Interfaces\Request\IRequest;
|
||||
use SokoWeb\Response\Redirect;
|
||||
use SokoWeb\Response\HtmlContent;
|
||||
@ -14,6 +15,8 @@ class HttpResponse
|
||||
{
|
||||
private IRequest $request;
|
||||
|
||||
private IConnection $dbConnection;
|
||||
|
||||
private RouteCollection $routeCollection;
|
||||
|
||||
private array $appConfig;
|
||||
@ -26,12 +29,14 @@ class HttpResponse
|
||||
|
||||
public function __construct(
|
||||
IRequest $request,
|
||||
IConnection $dbConnection,
|
||||
RouteCollection $routeCollection,
|
||||
array $appConfig,
|
||||
string $requestMethod,
|
||||
string $requestUrl
|
||||
) {
|
||||
$this->request = $request;
|
||||
$this->dbConnection = $dbConnection;
|
||||
$this->routeCollection = $routeCollection;
|
||||
$this->appConfig = $appConfig;
|
||||
$this->method = strtolower($requestMethod);
|
||||
@ -75,7 +80,10 @@ class HttpResponse
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dbConnection->startTransaction();
|
||||
$response = call_user_func([$controller, $handler[1]]);
|
||||
$this->dbConnection->commit();
|
||||
|
||||
if ($response instanceof IContent) {
|
||||
header('Content-Type: ' . $response->getContentType() . '; charset=UTF-8');
|
||||
$response->render();
|
||||
|
Loading…
Reference in New Issue
Block a user