From 32998439f320ad0b36f91b7e508f8039ee0caa95 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sun, 22 Jul 2018 19:55:25 +0200 Subject: Tidy identation for stringify replacement with var_export --- .../plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php index c70be2e..eb4b1df 100644 --- a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php +++ b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php @@ -61,6 +61,8 @@ class BakeExtraHelper extends Helper return $extraModels; } public function stringifySearchManagerConfig($filterConfig) { + $indent = 2; + $tab = ' '; // Do not output Model & Template specific options here unset($filterConfig['mode']); unset($filterConfig['colspan']); @@ -68,7 +70,16 @@ class BakeExtraHelper extends Helper //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, '[]') . ' '; + $s = preg_replace_callback( + // for each text line, replace ' ' idents by $tab, adding a $indent offset + '/^([ ]+)/m', + function($ms) use ($indent, $tab) { + return str_repeat($tab, $indent+floor(strlen($ms[1])/2)); + }, + $s + ); + $s = trim($s, '[]'); + return $s . str_repeat($tab, $indent); } public function hasAction($action, $controllerName) { -- cgit v1.1