This repository has been archived by the owner on Jan 17, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(response-processor): hiding Swoole StreamedResponse support from…
… Symfony
- Loading branch information
Showing
10 changed files
with
165 additions
and
69 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
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
31 changes: 31 additions & 0 deletions
31
src/Bridge/Symfony/HttpFoundation/ResponseProcessorInjector.php
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,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace K911\Swoole\Bridge\Symfony\HttpFoundation; | ||
|
||
use Swoole\Http\Response as SwooleResponse; | ||
use Symfony\Component\HttpFoundation\Request as HttpFoundationRequest; | ||
use Symfony\Component\HttpFoundation\Response as HttpFoundationResponse; | ||
|
||
final class ResponseProcessorInjector implements ResponseProcessorInjectorInterface | ||
{ | ||
private $responseProcessor; | ||
|
||
public function __construct(ResponseProcessorInterface $responseProcessor) | ||
{ | ||
$this->responseProcessor = $responseProcessor; | ||
} | ||
|
||
public function injectProcessor( | ||
HttpFoundationRequest $request, | ||
SwooleResponse $swooleResponse | ||
): void { | ||
$request->attributes->set( | ||
self::ATTR_KEY_RESPONSE_PROCESSOR, | ||
function (HttpFoundationResponse $httpFoundationResponse) use ($swooleResponse): void { | ||
$this->responseProcessor->process($httpFoundationResponse, $swooleResponse); | ||
} | ||
); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Bridge/Symfony/HttpFoundation/ResponseProcessorInjectorInterface.php
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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace K911\Swoole\Bridge\Symfony\HttpFoundation; | ||
|
||
use Swoole\Http\Response as SwooleResponse; | ||
use Symfony\Component\HttpFoundation\Request as HttpFoundationRequest; | ||
|
||
interface ResponseProcessorInjectorInterface | ||
{ | ||
public const ATTR_KEY_RESPONSE_PROCESSOR = 'swoole_streamed_response_processor'; | ||
|
||
public function injectProcessor(HttpFoundationRequest $request, SwooleResponse $swooleResponse): void; | ||
} |
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
36 changes: 0 additions & 36 deletions
36
src/Bridge/Symfony/HttpFoundation/SwooleRequestResponseContextManager.php
This file was deleted.
Oops, something went wrong.
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
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