Skip to content

Commit

Permalink
include server request and stream factories
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed Dec 23, 2019
1 parent f8be0a1 commit 6ef6ae9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Slim\App;
use Slim\Factory\AppFactory;
use Slim\Factory\Psr17\Psr17FactoryProvider;
use Slim\Factory\ServerRequestCreatorFactory;
use Slim\Interfaces\CallableResolverInterface;
use Slim\Interfaces\DispatcherInterface;
use Slim\Interfaces\InvocationStrategyInterface;
use Slim\Interfaces\MiddlewareDispatcherInterface;
use Slim\Interfaces\RouteCollectorInterface;
use Slim\Interfaces\RouteResolverInterface;
use Slim\Interfaces\ServerRequestCreatorInterface;
use Slim\MiddlewareDispatcher;
use Slim\Routing\Dispatcher;
use Slim\Routing\RouteCollector;
Expand All @@ -46,9 +50,22 @@
// Replaced by container itself
ContainerInterface::class => null,

ServerRequestCreatorInterface::class => function (): ServerRequestCreatorInterface {
return ServerRequestCreatorFactory::create();
},
ResponseFactoryInterface::class => function (): ResponseFactoryInterface {
return AppFactory::determineResponseFactory();
},
StreamFactoryInterface::class => function (): StreamFactoryInterface {
/** @var \Slim\Factory\Psr17\Psr17Factory $psr17factory */
foreach (Psr17FactoryProvider::getFactories() as $psr17factory) {
if ($psr17factory::isStreamFactoryAvailable()) {
return $psr17factory::getStreamFactory();
}
}

throw new RuntimeException('Could not detect any PSR-17 StreamFactory implementation');
},

CallableResolverInterface::class => function (ContainerInterface $container): CallableResolverInterface {
return new CallableResolver(new InvokerCallableResolver($container));
Expand Down

0 comments on commit 6ef6ae9

Please sign in to comment.