From 069bb613121de4dba65a8e0a371687c9235270ad Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 15 Apr 2017 18:23:04 +0200 Subject: [PATCH] More actions implemented --- Admin/Routes/Web/Api.php | 8 ++++++++ Controller.php | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php index f14f21f..6f70a3a 100644 --- a/Admin/Routes/Web/Api.php +++ b/Admin/Routes/Web/Api.php @@ -34,6 +34,14 @@ return [ ], ], + // todo: the order of find and account is bad but needed for now. otherwise the admin/account.* also matches and we match two routes = bad + '^.*/api/admin/find/account.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:apiAccountFind', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/api/admin/account.*$' => [ [ 'dest' => '\Modules\Admin\Controller:apiAccountCreate', diff --git a/Controller.php b/Controller.php index 03885d1..206c5cb 100644 --- a/Controller.php +++ b/Controller.php @@ -359,10 +359,10 @@ class Controller extends ModuleAbstract implements WebInterface $response->set('account', array_values(AccountMapper::getByRequest($request))); } - public function apiAccountFind() + public function apiAccountFind(RequestAbstract $request, ResponseAbstract $response, $data = null) { $response->getHeader()->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set('account', array_values(AccountMapper::find($request->getData('search')))); + $response->set('account', array_values(AccountMapper::find($request->getData('search') ?? ''))); } private function validateAccountCreate(RequestAbstract $request) : array