-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Конвертор битриксового Response/Request в Symfony Response/Request.
- Loading branch information
Showing
14 changed files
with
982 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
$_SERVER['DOCUMENT_ROOT'] = __DIR__. "/.."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="../vendor/autoload.php" colors="true" executionOrder="random" resolveDependencies="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Tests"> | ||
<directory>Tests/Cases</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<server name='HTTP_HOST' value='localhost' /> | ||
<server name='SERVER_NAME' value='localhost' /> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Prokl\ServiceProvider\Services\PSR; | ||
|
||
use Bitrix\Main\HttpRequest; | ||
use Prokl\ServiceProvider\Services\PSR\PSR7\ServerPsrRequest; | ||
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* Class BitrixRequestConvertor | ||
* @package Prokl\ServiceProvider\Services\PSR | ||
* | ||
* @since 24.05.2021 | ||
*/ | ||
class BitrixRequestConvertor | ||
{ | ||
/** | ||
* @var HttpRequest $bitrixRequest Битриксовый Request. | ||
*/ | ||
private $bitrixRequest; | ||
|
||
/** | ||
* @var ServerPsrRequest $psrRequest | ||
*/ | ||
private $psrRequest; | ||
|
||
/** | ||
* BitrixRequestConvertor constructor. | ||
* | ||
* @param HttpRequest $bitrixRequest Битриксовый Request. | ||
*/ | ||
public function __construct(HttpRequest $bitrixRequest) | ||
{ | ||
$this->bitrixRequest = $bitrixRequest; | ||
$this->psrRequest = new ServerPsrRequest($this->bitrixRequest); | ||
} | ||
|
||
/** | ||
* Request. | ||
* | ||
* @return Request | ||
*/ | ||
public function request() : Request | ||
{ | ||
$httpFoundationFactory = new HttpFoundationFactory(); | ||
|
||
return $httpFoundationFactory->createRequest($this->psrRequest); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Prokl\ServiceProvider\Services\PSR; | ||
|
||
use Bitrix\Main\HttpResponse; | ||
use Prokl\ServiceProvider\Services\PSR\PSR7\PsrResponse; | ||
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
/** | ||
* Class BitrixResponseConvertor | ||
* @package Prokl\ServiceProvider\Services\PSR | ||
* | ||
* @since 24.05.2021 | ||
*/ | ||
class BitrixResponseConvertor | ||
{ | ||
/** | ||
* @var HttpResponse $bitrixResponse Битриксовый Response. | ||
*/ | ||
private $bitrixResponse; | ||
|
||
/** | ||
* @var PsrResponse $psrResponse | ||
*/ | ||
private $psrResponse; | ||
|
||
/** | ||
* BitrixResponseConvertor constructor. | ||
* | ||
* @param HttpResponse $bitrixResponse Битриксовый Response. | ||
*/ | ||
public function __construct(HttpResponse $bitrixResponse) | ||
{ | ||
$this->bitrixResponse = $bitrixResponse; | ||
$this->psrResponse = new PsrResponse($this->bitrixResponse); | ||
} | ||
|
||
/** | ||
* Response. | ||
* | ||
* @return Response | ||
*/ | ||
public function response() : Response | ||
{ | ||
$httpFoundationFactory = new HttpFoundationFactory(); | ||
|
||
return $httpFoundationFactory->createResponse($this->psrResponse); | ||
} | ||
} |
Oops, something went wrong.