Habari\FormControl::from_args PHP Method

from_args() public static method

Take an array of parameters, use the first as the FormControl class/type, and run the constructor with the rest
public static from_args ( array $arglist ) : FormControl
$arglist array The array of arguments
return FormControl The created control.
    public static function from_args($arglist)
    {
        $arglist = array_pad($arglist, 6, null);
        list($type, $name, $storage, $properties, $settings) = $arglist;
        if (class_exists('\\Habari\\FormControl' . ucwords($type))) {
            $type = '\\Habari\\FormControl' . ucwords($type);
        }
        if (!class_exists($type)) {
            throw new \Exception(_t('The FormControl type "%s" is invalid.', array($type)));
        }
        if (is_null($properties)) {
            $properties = array();
        }
        if (is_null($settings)) {
            $settings = array();
        }
        if (is_string($properties)) {
            $bt = debug_backtrace(false, 4);
            $x = reset($bt);
            while ($x['function'] != 'append' && count($bt) > 0) {
                array_shift($bt);
                $x = reset($bt);
            }
            $params = implode("\n\t", $arglist);
            $err = <<<ERR
<div class="error">Fixup for {$x['file']}[{$x['line']}]:<br/><code style="font-family:monospace;color:#c00;">{$type}::create('{$name}', '{$storage}')->label('{$properties}');</code></div>
\t<!-- {$params} -->
ERR;
            return FormControlStatic::create(uniqid('fc', true))->set_static($err);
        }
        return new $type($name, $storage, $properties, $settings);
    }