From c9ce56eea5e68a8c5c6755f477b00da05ddf9193 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 1 May 2018 18:16:44 +0200 Subject: [PATCH] Added public method in AbstractRestAction which builds route definition --- module/Rest/src/Action/AbstractRestAction.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/module/Rest/src/Action/AbstractRestAction.php b/module/Rest/src/Action/AbstractRestAction.php index a9f491b6..1879ef12 100644 --- a/module/Rest/src/Action/AbstractRestAction.php +++ b/module/Rest/src/Action/AbstractRestAction.php @@ -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, + ]; + } }