41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Lean;
|
|
|
|
use League\Route\Http\Exception\MethodNotAllowedException;
|
|
use League\Route\Strategy;
|
|
use League\Route\Http\Exception\NotFoundException;
|
|
use Lean\ApplicationStrategy\MethodNotAllowedInterface;
|
|
use Lean\ApplicationStrategy\NotFoundDecoratorInterface;
|
|
use Lean\ApplicationStrategy\ThrowableHandlerInterface;
|
|
use Lean\Factory\HttpFactoryInterface;
|
|
use Psr\Container\ContainerInterface;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
use Psr\Http\Server\MiddlewareInterface;
|
|
use Psr\Http\Server\RequestHandlerInterface;
|
|
use function DI\get;
|
|
|
|
class ApplicationStrategy extends Strategy\ApplicationStrategy {
|
|
|
|
public function __construct(
|
|
ContainerInterface $di,
|
|
) {
|
|
$this->setContainer($di);
|
|
}
|
|
|
|
public function getNotFoundDecorator(NotFoundException $exception): MiddlewareInterface
|
|
{
|
|
return $this->getContainer()->get(NotFoundDecoratorInterface::class);
|
|
}
|
|
|
|
public function getThrowableHandler(): MiddlewareInterface
|
|
{
|
|
return $this->getContainer()->get(ThrowableHandlerInterface::class);
|
|
}
|
|
|
|
public function getMethodNotAllowedDecorator(MethodNotAllowedException $exception): MiddlewareInterface
|
|
{
|
|
return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception);
|
|
}
|
|
} |