public function getData($var = null, $forceArray = false)
    {
        if (null === $var) {
            $datas = array();
            foreach (array_keys($this->_data) as $key) {
                $datas[$key] = $this->getData($key);
            }

            return $datas;
        }

        if (!array_key_exists($var, $this->_data)) {
            if ($this->getContentInstance() instanceof ContentSet) {
                return;
            } else {
                throw new UnknownPropertyException(sprintf(
                    'Unknown property %s in %s.',
                    $var,
                    ClassUtils::getRealClass($this)
                ));
            }
        }

        $data = array();
        foreach ($this->_data[$var] as $type => $value) {
            if (is_array($value)) {
                $keys = array_keys($value);
                $values = array_values($value);

                $type = end($keys);
                $value = end($values);
            }

            if ('scalar' === $type) {
                $decode = json_decode($value, true);
                $data[] = (JSON_ERROR_NONE === json_last_error()) ? ((null === $decode) ? $value : $decode) : $value;
            } elseif ('array' !== $type) {
                try {
                    $type = self::getFullClassname($type);
                    if (false == $type) {
                        continue;
                    }
                } catch (\InvalidArgumentException $e) {
                    throw new ClassNotFoundException(sprintf('Unknown class content %s.', $type), 0, $e);
                }

                $value = (null !== $value) ? $value : md5($this->getUid().$var);

                $data[] = $this->getContentByDataValue($type, $value);
            } else {
                $data[] = $value;
            }
        }

        if (false === $forceArray) {
            switch (count($data)) {
                case 0:
                    $data = null;
                    break;
                case 1:
                    $data = array_pop($data);
                    break;
            }
        }

        return $data;
    }
public function getData($var = null, $forceArray = false)
    {
        if (null === $var) {
            $datas = array();
            foreach (array_keys($this->_data) as $key) {
                $datas[$key] = $this->getData($key);
            }

            return $datas;
        }

        if (!array_key_exists($var, $this->_data)) {
            if ($this->getContentInstance() instanceof ContentSet) {
                return;
            } else {
                throw new UnknownPropertyException(sprintf(
                    'Unknown property %s in %s.',
                    $var,
                    ClassUtils::getRealClass($this)
                ));
            }
        }

        $data = array();
        foreach ($this->_data[$var] as $type => $value) {
            if (is_array($value)) {
                $keys = array_keys($value);
                $values = array_values($value);

                $type = end($keys);
                $value = end($values);
            }

            if ('scalar' === $type) {
                $decode = json_decode($value, true);
                $data[] = (JSON_ERROR_NONE === json_last_error()) ? ((null === $decode) ? $value : $decode) : $value;
            } elseif ('array' !== $type) {
                try {
                    $type = self::getFullClassname($type);
                    if (false == $type) {
                        continue;
                    }
                } catch (\InvalidArgumentException $e) {
                    throw new ClassNotFoundException(sprintf('Unknown class content %s.', $type), 0, $e);
                }

                $value = (null !== $value) ? $value : md5($this->getUid().$var);

                $data[] = $this->getContentByDataValue($type, $value);
            } else {
                $data[] = $value;
            }
        }

        if (false === $forceArray) {
            switch (count($data)) {
                case 0:
                    $data = null;
                    break;
                case 1:
                    $data = array_pop($data);
                    break;
            }
        }

        return $data;
    }
public function getData ( $ var = null , $ forceArray = false ) { if ( null === $ var ) { $ datas = array ( ) ; foreach ( array_keys ( $ this -> _data ) as $ key ) { $ datas [ $ key ] = $ this -> getData ( $ key ) ; } return $ datas ; } if ( ! array_key_exists ( $ var , $ this -> _data ) ) { if ( $ this -> getContentInstance ( ) instanceof ContentSet ) { return ; } else { throw new UnknownPropertyException ( sprintf ( 'Unknown property %s in %s.' , $ var , ClassUtils :: getRealClass ( $ this ) ) ) ; } } $ data = array ( ) ; foreach ( $ this -> _data [ $ var ] as $ type => $ value ) { if ( is_array ( $ value ) ) { $ keys = array_keys ( $ value ) ; $ values = array_values ( $ value ) ; $ type = end ( $ keys ) ; $ value = end ( $ values ) ; } if ( 'scalar' === $ type ) { $ decode = json_decode ( $ value , true ) ; $ data [ ] = ( JSON_ERROR_NONE === json_last_error ( ) ) ? ( ( null === $ decode ) ? $ value : $ decode ) : $ value ; } elseif ( 'array' !== $ type ) { try { $ type = self :: getFullClassname ( $ type ) ; if ( false == $ type ) { continue ; } } catch ( \ InvalidArgumentException $ e ) { throw new ClassNotFoundException ( sprintf ( 'Unknown class content %s.' , $ type ) , 0 , $ e ) ; } $ value = ( null !== $ value ) ? $ value : md5 ( $ this -> getUid ( ) . $ var ) ; $ data [ ] = $ this -> getContentByDataValue ( $ type , $ value ) ; } else { $ data [ ] = $ value ; } } if ( false === $ forceArray ) { switch ( count ( $ data ) ) { case 0 : $ data = null ; break ; case 1 : $ data = array_pop ( $ data ) ; break ; } } return $ data ; }
Returns the set of data.

@param string  $var        The element to be return, if NULL, all datas are returned
@param boolean $forceArray Force the return as array

@return mixed Could be either one or array of scalar, array, AbstractClassContent instance
@throws UnknownPropertyException Occurs when $var does not match an element
@throws ClassNotFoundException   Occurs if the class of a subcontent can not be loaded
Returns the set of data .