Added public method in AbstractRestAction which builds route definition

This commit is contained in:
Alejandro Celaya 2018-05-01 18:16:44 +02:00
parent 4fee656f96
commit c9ce56eea5

View file

@ -11,6 +11,9 @@ use Psr\Log\NullLogger;
abstract class AbstractRestAction implements RequestHandlerInterface, RequestMethodInterface, StatusCodeInterface
{
protected const ROUTE_PATH = '';
protected const ALLOWED_METHODS = [];
/**
* @var LoggerInterface
*/
@ -20,4 +23,14 @@ abstract class AbstractRestAction implements RequestHandlerInterface, RequestMet
{
$this->logger = $logger ?: new NullLogger();
}
public static function getRouteDef(array $prevMiddleware = [], array $postMiddleware = []): array
{
return [
'name' => static::class,
'middleware' => \array_merge($prevMiddleware, [static::class], $postMiddleware),
'path' => static::ROUTE_PATH,
'allowed_methods' => static::ALLOWED_METHODS,
];
}
}