mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-14 13:16:37 +00:00
This commit is contained in:
parent
94f0015b22
commit
a7a779f9f1
|
@ -9,13 +9,13 @@ use App\Enums\SupportedLocales;
|
|||
use App\Http\Factory\ResponseFactory;
|
||||
use App\Http\Factory\ServerRequestFactory;
|
||||
use DI;
|
||||
use Invoker\Invoker;
|
||||
use Monolog\ErrorHandler;
|
||||
use Monolog\Registry;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Slim\App;
|
||||
use Slim\Factory\ServerRequestCreatorFactory;
|
||||
use Slim\Handlers\Strategies\RequestResponseNamedArgs;
|
||||
|
||||
class AppFactory
|
||||
{
|
||||
|
@ -53,7 +53,8 @@ class AppFactory
|
|||
$container->set(App::class, $app);
|
||||
|
||||
$routeCollector = $app->getRouteCollector();
|
||||
$routeCollector->setDefaultInvocationStrategy(new RequestResponseNamedArgs());
|
||||
|
||||
$routeCollector->setDefaultInvocationStrategy(new ControllerInvoker(new Invoker()));
|
||||
|
||||
$environment = $container->get(Environment::class);
|
||||
if ($environment->isProduction()) {
|
||||
|
|
33
src/ControllerInvoker.php
Normal file
33
src/ControllerInvoker.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App;
|
||||
|
||||
use Invoker\InvokerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Slim\Interfaces\InvocationStrategyInterface;
|
||||
|
||||
class ControllerInvoker implements InvocationStrategyInterface
|
||||
{
|
||||
public function __construct(
|
||||
protected InvokerInterface $invoker
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
callable $callable,
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $routeArguments
|
||||
): ResponseInterface {
|
||||
$parameters = [
|
||||
'request' => $request,
|
||||
'response' => $response,
|
||||
];
|
||||
$parameters += $routeArguments;
|
||||
|
||||
return $this->invoker->call($callable, $parameters);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user