LightnCandy\Context::updateHelperTable PHP Method

updateHelperTable() protected static method

update specific custom helper table from options
protected static updateHelperTable ( array\arraystring | integer> &$context, array\arraystring | integer> $options, string $tname = 'helpers' ) : array\arraystring | integer>
$context array\arraystring | integer>
$options array\arraystring | integer>
$tname string helper table name
return array\arraystring | integer>
    protected static function updateHelperTable(&$context, $options, $tname = 'helpers')
    {
        if (isset($options[$tname]) && is_array($options[$tname])) {
            foreach ($options[$tname] as $name => $func) {
                $tn = is_int($name) ? $func : $name;
                if (is_callable($func)) {
                    $context[$tname][$tn] = $func;
                } else {
                    if (is_array($func)) {
                        $context['error'][] = "I found an array in {$tname} with key as {$name}, please fix it.";
                    } else {
                        if ($context['flags']['exhlp']) {
                            // Regist helper names only
                            $context[$tname][$tn] = 1;
                        } else {
                            $context['error'][] = "You provide a custom helper named as '{$tn}' in options['{$tname}'], but the function {$func}() is not defined!";
                        }
                    }
                }
            }
        }
        return $context;
    }