From e61b7911b43a24b3c23da85b79cde1c528481177 Mon Sep 17 00:00:00 2001 From: iglocska Date: Sun, 16 Sep 2018 22:06:40 +0200 Subject: [PATCH] new: [blacklisting] pass parameters via named parameters to filter the index - /eventBlacklists/index/event_uuid:[my_event_uuid] --- app/Controller/Component/BlackListComponent.php | 5 ++++- app/Controller/EventBlacklistsController.php | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Controller/Component/BlackListComponent.php b/app/Controller/Component/BlackListComponent.php index 37ce72788..6cbb20765 100644 --- a/app/Controller/Component/BlackListComponent.php +++ b/app/Controller/Component/BlackListComponent.php @@ -10,8 +10,11 @@ class BlackListComponent extends Component public $defaultModel = ''; - public function index($rest = false) + public function index($rest = false, $filters = array()) { + if (!empty($filters)) { + $this->controller->paginate['conditions'] = $filters; + } if ($this->controller->response->type() === 'application/json' || $this->controller->response->type() == 'application/xml' || $rest) { $blackList = $this->controller->paginate(); $blacklist= array(); diff --git a/app/Controller/EventBlacklistsController.php b/app/Controller/EventBlacklistsController.php index 0a26869fa..e27bd784f 100644 --- a/app/Controller/EventBlacklistsController.php +++ b/app/Controller/EventBlacklistsController.php @@ -27,7 +27,14 @@ class EventBlacklistsController extends AppController public function index() { - $this->BlackList->index($this->_isRest()); + $params = array(); + $validParams = array('event_uuid', 'comment'); + foreach ($validParams as $validParam) { + if (!empty($this->params['named'][$validParam])) { + $params[$validParam] = $this->params['named'][$validParam]; + } + } + $this->BlackList->index($this->_isRest(), $params); } public function add()