method getCfg documentation in bbn\Appui\Option

Returns a formatted content of the cfg column as an array

Checks if the parent option has inheritance and sets array accordingly Parent rules will be applied if with the following inheritance values:

Example

X::dump($opt->getCfg(25)); /* array [ 'sortable' => true, 'cascade' => true, 'id_alias' => null, ] function($code = NULL) { if (bbn\Str::isUid($id = $this->fromCode(\func_get_args()))) { if ($tmp = $this->cacheGet($id, __FUNCTION__)) { return $tmp; } $c =& $this->class_cfg; $f =& $this->fields; $cfg = $this->db->selectOne($c['table'], $f['cfg'], [$f['id'] => $id]); $cfg = bbn\Str::isJson($cfg) ? json_decode($cfg, true) : []; $perm = $cfg['permissions'] ?? false; // Looking for parent with inheritance $parents = array_reverse($this->parents($id)); $last = \count($parents) - 1; foreach ($parents as $i => $p){ $parent_cfg = $this->db->selectOne($c['table'], $f['cfg'], [$f['id'] => $p]); $parent_cfg = bbn\Str::isJson($parent_cfg) ? json_decode($parent_cfg, true) : []; if (!empty($parent_cfg['scfg']) && ($i === $last)) { $cfg = array_merge((array)$cfg, $parent_cfg['scfg']); $cfg['inherit_from'] = $p; $cfg['frozen'] = 1; break; } if (!empty($parent_cfg['inheritance']) || !empty($parent_cfg['scfg']['inheritance'])) { if ( (($i === $last) && ( (($parent_cfg['inheritance'] ?? null) === 'children') || (!empty($parent_cfg['scfg']) && (($parent_cfg['scfg']['inheritance'] ?? null) === 'children'))) ) || ( (($parent_cfg['inheritance'] ?? null) === 'cascade') || (!empty($parent_cfg['scfg']) && (($parent_cfg['scfg']['inheritance'] ?? null) === 'cascade')) ) ) { // Keeping in the option cfg properties which don't exist in the parent $cfg = array_merge((array)$cfg, $parent_cfg['scfg'] ?? $parent_cfg); $cfg['inherit_from'] = $p; $cfg['frozen'] = 1; break; } elseif (!count($cfg) && ((($parent_cfg['inheritance'] ?? null) === 'default') || (!empty($parent_cfg['scfg']) && (($parent_cfg['scfg']['inheritance'] ?? null) === 'default')) ) ) { $cfg = $parent_cfg['scfg'] ?? $parent_cfg; $cfg['inherit_from'] = $p; } } } if ($perm) { $cfg['permissions'] = $perm; } $mandatories = ['show_code', 'show_alias', 'show_value', 'show_icon', 'sortable', 'allow_children', 'frozen']; foreach ($mandatories as $m){ $cfg[$m] = empty($cfg[$m]) ? 0 : 1; } $mandatories = ['desc', 'inheritance', 'permissions']; foreach ($mandatories as $m){ $cfg[$m] = empty($cfg[$m]) ? '' : $cfg[$m]; } $mandatories = ['controller', 'schema', 'form', 'default_value']; foreach ($mandatories as $m){ $cfg[$m] = empty($cfg[$m]) ? null : $cfg[$m]; } $this->cacheSet($id, __FUNCTION__, $cfg); return $cfg; } return null; }

Returns a formatted content of the cfg column as an array BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.