Static factory method to create a field element object from a field config array

@param  string $name
@param  array  $field
@throws Exception
@return Element\AbstractElement
771787
public static function create($name, array $field)
    {
        if (!isset($field['type'])) {
            throw new Exception('Error: The field type was not set.');
        }
        $type         = $field['type'];
        $value        = (isset($field['value']))      ? $field['value']      : null;
        $values       = (isset($field['values']))     ? $field['values']     : [];
        $label        = (isset($field['label']))      ? $field['label']      : null;
        $indent       = (isset($field['indent']))     ? $field['indent']     : null;
        $checked      = (isset($field['checked']))    ? $field['checked']    : null;
        $selected     = (isset($field['selected']))   ? $field['selected']   : null;
        $required     = (isset($field['required']))   ? $field['required']   : null;
        $disabled     = (isset($field['disabled']))   ? $field['disabled']   : null;
        $readonly     = (isset($field['readonly']))   ? $field['readonly']   : null;
        $attributes   = (isset($field['attributes'])) ? $field['attributes'] : null;
        $validators   = (isset($field['validators'])) ? $field['validators'] : null;
        $render       = (isset($field['render']))     ? $field['render']     : false;
        $expire       = (isset($field['expire']))     ? $field['expire']     : 300;
        $captcha      = (isset($field['captcha']))    ? $field['captcha']    : null;
        $answer       = (isset($field['answer']))     ? $field['answer']     : null;
        $min          = (isset($field['min']))        ? $field['min']        : false;
        $max          = (isset($field['max']))        ? $field['max']        : false;
        $xmlFile      = (isset($field['xml']))        ? $field['xml']        : null;
        $hint         = (isset($field['hint']))       ? $field['hint']       : null;
        $hintAttribs  = (isset($field['hint-attributes'])) ? $field['hint-attributes']   : null;
        $labelAttribs = (isset($field['label-attributes'])) ? $field['label-attributes'] : null;
        $errorPre = (isset($field['error']) && ($field['error'] == 'pre'));
        // Initialize the form element.
        switch (strtolower($type)) {
            case 'button':
                $element = new Element\Button($name, $value, $indent);
                break;
            case 'select':
                $element = new Element\Select($name, $values, $selected, $xmlFile, $indent);
                break;
            case 'select-multiple':
                $element = new Element\SelectMultiple($name, $values, $selected, $xmlFile, $indent);
                break;
            case 'textarea':
                $element = new Element\Textarea($name, $value, $indent);
                break;
            case 'checkbox':
            case 'checkboxset':
                $element = new Element\CheckboxSet($name, $values, $checked, $indent);
                break;
            case 'radio':
            case 'radioset':
                $element = new Element\RadioSet($name, $values, $checked, $indent);
                break;
            case 'csrf':
                $element = new Element\Input\Csrf($name, $value, $expire, $indent);
                break;
            case 'captcha':
                $element = new Element\Input\Captcha($name, $value, $captcha, $answer, $expire, $indent);
                break;
            case 'input-button':
                $element = new Element\Input\Button($name, $value);
                break;
            case 'datetime':
                $element = new Element\Input\DateTime($name, $value);
                break;
            case 'datetime-local':
                $element = new Element\Input\DateTimeLocal($name, $value);
                break;
            case 'number':
                $element = new Element\Input\Number($name, $min, $max, $value);
                break;
            case 'range':
                $element = new Element\Input\Range($name, $min, $max, $value);
                break;
            default:
                $class = 'Pop\\Form\\Element\\Input\\' . ucfirst(strtolower($type));
                if (!class_exists($class)) {
                    throw new Exception('Error: That class for that form element does not exist.');
                }
                $element = new $class($name, $value);
                if ($class == 'Pop\\Form\\Element\\Input\\Password') {
                    $element->setRenderValue($render);
                }
        }
        // Set the label.
        if (null !== $label) {
            $element->setLabel($label);
        }
        // Set the label attributes.
        if ((null !== $labelAttribs) && is_array($labelAttribs)) {
            $element->setLabelAttributes($labelAttribs);
        }
        // Set the hint.
        if (null !== $hint) {
            $element->setHint($hint);
        }
        // Set the hint attributes.
        if ((null !== $hintAttribs) && is_array($hintAttribs)) {
            $element->setHintAttributes($hintAttribs);
        }
        // Set if required.
        if ((null !== $required) && ($required)) {
            $element->setRequired($required);
        }
        // Set if disabled.
        if ((null !== $disabled) && ($disabled)) {
            $element->setDisabled($disabled);
        }
        // Set if readonly.
        if ((null !== $readonly) && ($readonly)) {
            $element->setReadonly($readonly);
        }
        $element->setErrorPre($errorPre);
        // Set any attributes.
        if (null !== $attributes) {
            if ($element instanceof Element\CheckboxSet) {
                $element->setCheckboxAttributes($attributes);
            } else if ($element instanceof Element\RadioSet) {
                $element->setRadioAttributes($attributes);
            } else {
                $element->setAttributes($attributes);
            }
        }
        // Set any validators.
        if (null !== $validators) {
            if (is_array($validators)) {
                $element->addValidators($validators);
            } else {
                $element->addValidator($validators);
            }
        }
        return $element;
    }
121010
public function getField($name)
    {
        if ($this->has($name)) {
            return $this->fields[$name];
        }

        $this->fieldDoesNotExist($name);
    }
1010340
public function getField($name)
    {
        if (isset($this->typeClasses[$name])) {
            return $this->inject(new $this->typeClasses[$name]);
        } else {
            throw new ParserException('Unknown field type: '.$name);
        }
    }
350952
public function createElement(Node $parent, $name)
    {
        if (array_key_exists($name, $this->elementMap)) {
            $class = $this->elementMap[$name];

            return new $class($parent);
        }

        return null;
    }
648081
public function insertFieldAfter($name, Element\AbstractElement $field)
    {
        foreach ($this->fields as $i => $group) {
            $fields = [];
            foreach ($group as $key => $value) {
                if ($key == $name) {
                    $fields[$key] = $value;
                    $fields[$field->getName()] = $field;
                } else {
                    $fields[$key] = $value;
                }
            }
            $this->fields[$i] = $fields;
        }
        return $this;
    }
713045
public static function field($name, $id = null)
    {
        return self::getInstance()
                     ->getBuilder(FieldBehavior::class)
                     ->field($name)
                     ->id($id);
    }
1014655
protected function makeField($name, $type = 'text', array $options = [])
    {
        $this->setupFieldOptions($name, $options);

        $fieldName = $this->getFieldName($name);

        $fieldType = $this->getFieldType($type);

        $field = new $fieldType($fieldName, $type, $this, $options);

        $this->eventDispatcher->dispatch(new AfterFieldCreation($this, $field));

        return $field;
    }
134250
public void putField(String name) throws IOException
    {
        VariableElement field = El.getField(subClass, name);
        if (field == null)
        {
            throw new IllegalArgumentException("field "+name+" not found");
        }
        putField(field);
    }
193315
public function removeFieldByName($name)
    {
        foreach ($this->fields as $i => $field) {
            if ($field->getName() == $name) {
                unset($this->fields[$i]);
                break;
            }
        }

        return $this;
    }
147709
public static function get(string $name, string $key, string $field = null)
    {
        return static::getInstance($name)->get($key, $field);
    }
533847
public function retrieveRule($field, $name = null)
    {
        $key = $this->generateKey(self::DYNAMIC_RULE_KEY, $field);
        $allRules = self::storage()->get($key, []);
        if (empty($name)) {
            return $allRules;
        }

        return isset($allRules[$name]) ? $allRules[$name] : null;
    }
419354
public function getField(string $name): FieldInterface
    {
        if (!$this->hasField($name)) {
            throw new DefinitionException("Field '$name' is not defined.");
        }

        return $this->fields[$name];
    }
344299
public function addElement($element, $name = null, $attrsTerm = null, $attrsDesc = null) {
		if ($element instanceof DescListElement) {
			return parent::addElement($element, $name);
		}
		
		if (! is_array($element)) {
			throw new Exception('Element must be an array or the "ListElement" instance');
		}
		
		if (! isset($element[0], $element[1])) {
			throw new Exception('Element definition array must contain "0" and "1" offsets');
		}
		
		$newElement = new DescListElement($element[0], $element[1], $attrsTerm, $attrsDesc);
		
		return parent::addElement($newElement, $name);
	}
336465
public static function make($name, $type = 'text')
    {
        $input = 'Terranet\\Administrator\\Filters\\Element\\'.ucfirst($type);

        if (!class_exists($input)) {
            throw new Exception(sprintf('Unknown type: %s', $type));
        }

        return new $input($name);
    }
1289404
public function createElement($name, $value = null, array $attributes = [])
    {
        $node = $this->document->createElement($name);

        return new Element($node, $value, $attributes);
    }
1025187
public function createElement($type, $name, $options = null) {
        $element = parent::createElement($type, $name, $options);
        return $element;
    }
53775
static function createElementNodeFromArray( $name, $array )
    {
        $dom = new DOMDocument( '1.0', 'utf-8' );
        $node = $dom->createElement( $name );
        $dom->appendChild( $node );

        foreach ( $array as $arrayKey => $value )
        {
            if ( is_array( $value ) and
                 count( $valueKeys = array_keys( $value ) ) > 0 )
            {
                if ( is_int( $valueKeys[0] ) )
                {
                    foreach( $value as $child )
                    {
                        unset( $childNode );
                        unset( $importedChildNode );
                        $childNode = eZContentObjectPackageHandler::createElementNodeFromArray( $arrayKey, $child );
                        $importedChildNode = $dom->importNode( $childNode, true );
                        $node->appendChild( $importedChildNode );
                    }
                }
                else
                {
                        unset( $valueNode );
                        unset( $importedValueNode );
                        $valueNode = eZContentObjectPackageHandler::createElementNodeFromArray( $arrayKey, $value );
                        $importedValueNode = $dom->importNode( $valueNode, true );
                        $node->appendChild( $importedValueNode );
                }
            }
            else
            {
                $node->setAttribute( $arrayKey, $value );
            }
        }
        return $node;
    }