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