-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from liayn/typo3-request-usage
[BUGFIX] Use TYPO3 request factory and request
- Loading branch information
Showing
3 changed files
with
59 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Causal\Oidc\Factory; | ||
|
||
use GuzzleHttp\Psr7\Utils; | ||
use League\OAuth2\Client\Tool\RequestFactory as Oauth2RequestFactory; | ||
use Psr\Http\Message\RequestFactoryInterface; | ||
|
||
class RequestFactory extends Oauth2RequestFactory | ||
{ | ||
protected RequestFactoryInterface $requestFactory; | ||
|
||
public function __construct(RequestFactoryInterface $requestFactory) | ||
{ | ||
$this->requestFactory = $requestFactory; | ||
} | ||
|
||
public function getRequest( | ||
$method, | ||
$uri, | ||
array $headers = [], | ||
$body = null, | ||
$version = '1.1' | ||
) { | ||
$request = $this->requestFactory->createRequest($method, $uri); | ||
foreach ($headers as $name => $value) { | ||
$request = $request->withHeader((string)$name, $value); | ||
} | ||
if ($body !== '' && $body !== null) { | ||
$request = $request->withBody(Utils::streamFor($body)); | ||
} | ||
return $request->withProtocolVersion($version); | ||
} | ||
} |
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