protected function defineData($var, $type = 'scalar', $options = null, $updateAccept = true)
    {
        if (true === $updateAccept) {
            $this->_addAcceptedType($type, $var);
        }

        if (!empty($options)) {
            $this->defaultOptions[$var] = $options;
        }

        if (!array_key_exists($var, $this->_data)) {
            $this->_data[$var] = [];
            $this->_maxentry[$var] = (!is_null($options) && isset($options['maxentry'])) ? $options['maxentry'] : 1;
            $this->_minentry[$var] = (!is_null($options) && isset($options['minentry'])) ? $options['minentry'] : 0;

            $values = [];
            if (is_array($options) && array_key_exists('default', $options)) {
                $values = (array) $options['default'];

                if ('scalar' !== $type) {
                    foreach ($values as &$value) {
                        $value = new $type(null, $options);
                    }
                    unset($value);
                }
            } else {
                try {
                    $values[] = ('scalar' === $type) ? '' : new $type(null, $options);
                } catch (ClassNotFoundException $ex) {
                    self::onUnknownClassname(sprintf('Unknown classname `%s`.', $type), $ex);
                }
            }

            return $this->__set($var, $values);
        }

        return $this;
    }
protected function defineData($var, $type = 'scalar', $options = null, $updateAccept = true)
    {
        if (true === $updateAccept) {
            $this->_addAcceptedType($type, $var);
        }

        if (!empty($options)) {
            $this->defaultOptions[$var] = $options;
        }

        if (!array_key_exists($var, $this->_data)) {
            $this->_data[$var] = [];
            $this->_maxentry[$var] = (!is_null($options) && isset($options['maxentry'])) ? $options['maxentry'] : 1;
            $this->_minentry[$var] = (!is_null($options) && isset($options['minentry'])) ? $options['minentry'] : 0;

            $values = [];
            if (is_array($options) && array_key_exists('default', $options)) {
                $values = (array) $options['default'];

                if ('scalar' !== $type) {
                    foreach ($values as &$value) {
                        $value = new $type(null, $options);
                    }
                    unset($value);
                }
            } else {
                try {
                    $values[] = ('scalar' === $type) ? '' : new $type(null, $options);
                } catch (ClassNotFoundException $ex) {
                    self::onUnknownClassname(sprintf('Unknown classname `%s`.', $type), $ex);
                }
            }

            return $this->__set($var, $values);
        }

        return $this;
    }
protected function defineData ( $ var , $ type = 'scalar' , $ options = null , $ updateAccept = true ) { if ( true === $ updateAccept ) { $ this -> _addAcceptedType ( $ type , $ var ) ; } if ( ! empty ( $ options ) ) { $ this -> defaultOptions [ $ var ] = $ options ; } if ( ! array_key_exists ( $ var , $ this -> _data ) ) { $ this -> _data [ $ var ] = [ ] ; $ this -> _maxentry [ $ var ] = ( ! is_null ( $ options ) && isset ( $ options [ 'maxentry' ] ) ) ? $ options [ 'maxentry' ] : 1 ; $ this -> _minentry [ $ var ] = ( ! is_null ( $ options ) && isset ( $ options [ 'minentry' ] ) ) ? $ options [ 'minentry' ] : 0 ; $ values = [ ] ; if ( is_array ( $ options ) && array_key_exists ( 'default' , $ options ) ) { $ values = ( array ) $ options [ 'default' ] ; if ( 'scalar' !== $ type ) { foreach ( $ values as & $ value ) { $ value = new $ type ( null , $ options ) ; } unset ( $ value ) ; } } else { try { $ values [ ] = ( 'scalar' === $ type ) ? '' : new $ type ( null , $ options ) ; } catch ( ClassNotFoundException $ ex ) { self :: onUnknownClassname ( sprintf ( 'Unknown classname `%s`.' , $ type ) , $ ex ) ; } } return $ this -> __set ( $ var , $ values ) ; } return $ this ; }
Dynamically adds and sets new element to this content.

@param string  $var          The name of the element
@param string  $type         Optional, the type of the element, scalar by default
@param array   $options      Optional, initial options for the content (see this constructor)
@param Boolean $updateAccept Optional, dynamically accept (default) or not the type for the new element.

@return AbstractClassContent The current instance.
Dynamically adds and sets new element to this content .