From c76fbd03c7a630b6620997585968b717caddc68c Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 27 May 2015 23:59:41 +0200 Subject: [PATCH] Implement helper for generating routes in API actions. --- framework/core/src/Api/Actions/JsonApiAction.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/framework/core/src/Api/Actions/JsonApiAction.php b/framework/core/src/Api/Actions/JsonApiAction.php index e5d4b7c6c..844c229a0 100644 --- a/framework/core/src/Api/Actions/JsonApiAction.php +++ b/framework/core/src/Api/Actions/JsonApiAction.php @@ -46,6 +46,14 @@ abstract class JsonApiAction implements ActionInterface return new Response($data, $status); } + protected function route($name, array $parameters = []) + { + /** @var \Flarum\Http\UrlGeneratorInterface $generator */ + $generator = app('Flarum\Http\UrlGeneratorInterface'); + + return $generator->toRoute($name, $parameters); + } + /** * Handle an API request and return an API response. *