feature/database-transactions #9

Merged
bence merged 2 commits from feature/database-transactions into master 2023-04-18 23:07:18 +02:00
Showing only changes of commit 51801d4228 - Show all commits

View File

@ -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();