summaryrefslogtreecommitdiff
path: root/fai_gestion/plugins/CustomTheme/src/View/Helper
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2018-07-20 00:41:45 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2018-07-20 00:41:45 +0200
commitb59164b0b7451905adcca244e6395281eb0633ca (patch)
tree098111b525b796221a931aaae5c1688cf1a45d88 /fai_gestion/plugins/CustomTheme/src/View/Helper
parent76ab63096a25f5bf7b9d076cdc9ab3fc5218d216 (diff)
downloadchd_gestion-b59164b0b7451905adcca244e6395281eb0633ca.zip
chd_gestion-b59164b0b7451905adcca244e6395281eb0633ca.tar.gz
chd_gestion-b59164b0b7451905adcca244e6395281eb0633ca.tar.bz2
bake add Search filter support
Diffstat (limited to 'fai_gestion/plugins/CustomTheme/src/View/Helper')
-rw-r--r--fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php
index 0e94b55..f58de2a 100644
--- a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php
+++ b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php
@@ -26,6 +26,8 @@ use Cake\Utility\Hash;
class BakeExtraHelper extends Helper
{
+ public $helpers = ['Bake'];
+
public function hello()
{
return "<!-- BakeExtra::hello()\n" . print_r($this->_config, true) . "\n-->\n";
@@ -42,6 +44,38 @@ class BakeExtraHelper extends Helper
return Hash::get($this->_config, "templateExtra.$controllerName.filters");
}
+ public function getFiltersExtraModels($controllerName, $modelObj) {
+ $extraModels=[];
+ $filters = $this->getFilters($controllerName);
+ if ( is_array($filters) && is_object($modelObj) ) {
+ $searchFields = [];
+ foreach ($filters as $k => $filter) {
+ $searchFields += array_keys( $this->getFilters($controllerName) );
+ }
+ foreach ($modelObj->associations()->getByType('BelongsTo') as $model) {
+ if ( in_array($model->getForeignKey(), $searchFields) ) {
+ $extraModels[] = $model;
+ }
+ }
+ }
+ return $extraModels;
+ }
+ public function stringifySearchManagerConfig($filterConfig) {
+ $field = array_key_exists('field', $filterConfig)?$filterConfig['field']:FALSE;
+ unset($filterConfig['field']);
+ 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;
+ }
+
public function hasAction($action, $controllerName) {
if ( ! is_string($controllerName) ) return FALSE;
return in_array($action, $this->getActions($controllerName));
@@ -60,4 +94,5 @@ class BakeExtraHelper extends Helper
if ( ! is_string($controllerName) ) return FALSE;
return Hash::get($this->_config, "templateExtra.$controllerName.title");
}
+
}