luya\console\commands\BlockController::varCreator PHP Method

varCreator() private method

Create a variable based of user input.
private varCreator ( string $prefix, string $typeCast ) : array
$prefix string
$typeCast string 'var', 'cfg'
return array
    private function varCreator($prefix, $typeCast)
    {
        $this->output(PHP_EOL . '-> Create new ' . $prefix, Console::FG_YELLOW);
        $name = $this->prompt('Variable Name:', ['required' => true]);
        $label = $this->prompt('End-User Label:', ['required' => true]);
        $type = $this->select('Variable Type:', $this->getVariableTypes());
        $v = ['var' => Inflector::variablize($name), 'label' => $label, 'type' => 'zaa-' . $type];
        if ($this->hasVariableTypeOption($type)) {
            $v['options'] = $this->getVariableTypeOption($type);
        }
        if ($typeCast == 'var') {
            $func = 'getVarValue';
        } else {
            $func = 'getCfgValue';
        }
        $extra = $this->getExtraVarDef($type, $v['var'], $func);
        if ($extra !== false) {
            $this->phpdoc[] = '{{extras.' . $v['var'] . '}}';
            $this->viewFileDoc[] = '$this->extraValue(\'' . $v['var'] . '\');';
            $this->extras[] = $extra;
        }
        $this->output('Added ' . $prefix . PHP_EOL, Console::FG_GREEN);
        return $v;
    }