code/object/config/factory.php
public function createFormat($format, $options = array())
    {
        $name = strtolower($format);

        if (!isset($this->_formats[$name])) {
            throw new \RuntimeException(sprintf('Unsupported config format: %s ', $name));
        }

        if(!isset($this->__prototypes[$name]))
        {
            $class    = $this->_formats[$name];
            $instance = new $class();

            if(!$instance instanceof ObjectConfigSerializable)
            {
                throw new \UnexpectedValueException(
                    'Format: '.get_class($instance).' does not implement ObjectConfigSerializable Interface'
                );
            }

            $this->__prototypes[$name] = $instance;
        }

        //Clone the object
        $result = clone $this->__prototypes[$name];
        $result->merge($options);

        return $result;
    }
public function createFormat($format, $options = array())
    {
        $name = strtolower($format);

        if (!isset($this->_formats[$name])) {
            throw new \RuntimeException(sprintf('Unsupported config format: %s ', $name));
        }

        if(!isset($this->__prototypes[$name]))
        {
            $class    = $this->_formats[$name];
            $instance = new $class();

            if(!$instance instanceof ObjectConfigSerializable)
            {
                throw new \UnexpectedValueException(
                    'Format: '.get_class($instance).' does not implement ObjectConfigSerializable Interface'
                );
            }

            $this->__prototypes[$name] = $instance;
        }

        //Clone the object
        $result = clone $this->__prototypes[$name];
        $result->merge($options);

        return $result;
    }
public function createFormat ( $ format , $ options = array ( ) ) { $ name = strtolower ( $ format ) ; if ( ! isset ( $ this -> _formats [ $ name ] ) ) { throw new \ RuntimeException ( sprintf ( 'Unsupported config format: %s ' , $ name ) ) ; } if ( ! isset ( $ this -> __prototypes [ $ name ] ) ) { $ class = $ this -> _formats [ $ name ] ; $ instance = new $ class ( ) ; if ( ! $ instance instanceof ObjectConfigSerializable ) { throw new \ UnexpectedValueException ( 'Format: ' . get_class ( $ instance ) . ' does not implement ObjectConfigSerializable Interface' ) ; } $ this -> __prototypes [ $ name ] = $ instance ; } //Clone the object $ result = clone $ this -> __prototypes [ $ name ] ; $ result -> merge ( $ options ) ; return $ result ; }
Get a registered config object.

@param  string $format The format name
@param  array|ObjectConfig $options An associative array of configuration options or a ObjectConfig instance.
@throws \InvalidArgumentException    If the format isn't registered
@throws \UnexpectedValueException   If the format object doesn't implement the ObjectConfigSerializable
@return ObjectConfigSerializable
Get a registered config object .