Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
533 additions
and
49 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 |
---|---|---|
|
@@ -9,6 +9,7 @@ matrix: | |
- php: 7.2 | ||
- php: 7.3 | ||
- php: nightly | ||
|
||
allow_failures: | ||
- php: nightly | ||
|
||
|
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
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,43 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Slim\Factory\Psr17; | ||
|
||
use Slim\Interfaces\Psr17FactoryProviderInterface; | ||
|
||
class Psr17FactoryProvider implements Psr17FactoryProviderInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected static $factories = [ | ||
SlimPsr17Factory::class, | ||
NyholmPsr17Factory::class, | ||
ZendDiactorosPsr17Factory::class, | ||
GuzzlePsr17Factory::class, | ||
]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getFactories(): array | ||
{ | ||
return static::$factories; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function setFactories(array $factories): void | ||
{ | ||
static::$factories = $factories; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function addFactory(string $factory): void | ||
{ | ||
array_unshift(static::$factories, $factory); | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
/** | ||
* Slim Framework (https://slimframework.com) | ||
* | ||
* @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Slim\Factory\Psr17; | ||
|
||
use Psr\Http\Message\ResponseFactoryInterface; | ||
use Psr\Http\Message\StreamFactoryInterface; | ||
|
||
class SlimHttpPsr17Factory extends Psr17Factory | ||
{ | ||
protected static $responseFactoryClass = 'Slim\Http\Factory\DecoratedResponseFactory'; | ||
|
||
/** | ||
* @param ResponseFactoryInterface $responseFactory | ||
* @param StreamFactoryInterface $streamFactory | ||
* @return ResponseFactoryInterface | ||
*/ | ||
public static function createDecoratedResponseFactory( | ||
ResponseFactoryInterface $responseFactory, | ||
StreamFactoryInterface $streamFactory | ||
): ResponseFactoryInterface { | ||
return new static::$responseFactoryClass($responseFactory, $streamFactory); | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
/** | ||
* Slim Framework (https://slimframework.com) | ||
* | ||
* @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Slim\Factory\Psr17; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use RuntimeException; | ||
use Slim\Interfaces\ServerRequestCreatorInterface; | ||
|
||
class SlimHttpServerRequestCreator implements ServerRequestCreatorInterface | ||
{ | ||
/** | ||
* @var ServerRequestCreatorInterface | ||
*/ | ||
protected $serverRequestCreator; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected static $serverRequestDecoratorClass = 'Slim\Http\ServerRequest'; | ||
|
||
/** | ||
* @param ServerRequestCreatorInterface $serverRequestCreator | ||
*/ | ||
public function __construct(ServerRequestCreatorInterface $serverRequestCreator) | ||
{ | ||
$this->serverRequestCreator = $serverRequestCreator; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createServerRequestFromGlobals(): ServerRequestInterface | ||
{ | ||
if (!static::isServerRequestDecoratorAvailable()) { | ||
throw new RuntimeException('The Slim-Http ServerRequest decorator is not available.'); | ||
} | ||
|
||
$request = $this->serverRequestCreator->createServerRequestFromGlobals(); | ||
|
||
return new static::$serverRequestDecoratorClass($request); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public static function isServerRequestDecoratorAvailable(): bool | ||
{ | ||
return class_exists(static::$serverRequestDecoratorClass); | ||
} | ||
} |
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
Oops, something went wrong.