From b49f4d5ccd5a61e901c448ad94495750bb2d0269 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sun, 22 Jul 2018 11:19:39 +0200 Subject: bake: fix Search filter support (bad stringifyList()) --- .../src/View/Helper/BakeExtraHelper.php | 36 ++++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'fai_gestion/plugins') diff --git a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php index 6063ba5..c70be2e 100644 --- a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php +++ b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php @@ -61,19 +61,14 @@ class BakeExtraHelper extends Helper return $extraModels; } public function stringifySearchManagerConfig($filterConfig) { - $field = array_key_exists('field', $filterConfig)?$filterConfig['field']:FALSE; - unset($filterConfig['field']); + // Do not output Model & Template specific options here unset($filterConfig['mode']); unset($filterConfig['colspan']); unset($filterConfig['hint']); - $s = ''; - if ($field) { - $s .= "\n 'field' => ["; - $s .= $this->Bake->stringifyList($field, ['indent'=>4]); - $s .= "],"; - } - $s .= $this->Bake->stringifyList($filterConfig, ['indent'=>3]); - return $s; + //Bake::stringifyList() has bugs with nested array + option quotes in Cake 3.6.7 + $s = var_export($filterConfig, true); + $s = str_replace([ 'array (', ')'], ['[', ']'], $s); + return trim($s, '[]') . ' '; } public function hasAction($action, $controllerName) { @@ -103,4 +98,25 @@ class BakeExtraHelper extends Helper return Hash::get($this->_config, "templateExtra.$controllerName.title"); } + public function hasOrderOpts($controllerName) { + if ( ! is_string($controllerName) ) return FALSE; + $orderOpts = $this->getOrderOpts($controllerName); + return (is_array($orderOpts) && count($orderOpts) > 0); + } + + public function getOrderOpts($controllerName) { + if ( ! is_string($controllerName) ) return FALSE; + return Hash::get($this->_config, "templateExtra.$controllerName.order"); + } + + public function hasOrderHooks($controllerName) { + if ( ! is_string($controllerName) ) return FALSE; + $orderHooks = $this->getOrderHooks($controllerName); + return (is_array($orderHooks) && count($orderHooks) > 0); + } + + public function getOrderHooks($controllerName) { + if ( ! is_string($controllerName) ) return FALSE; + return Hash::get($this->_config, "templateExtra.$controllerName.orderHook"); + } } -- cgit v1.1