public function hydrateEntity(ClassMetadata $class, $document)
    {
        // TODO: add support for different result set types from different clients
        // perhaps by wrapping documents in a layer of abstraction
        $data = $document->getData();
        $fields = array_merge(
            $document->hasFields() ? $document->getFields() : array(),
            array('_version' => $document->getVersion())
        );

        foreach ($fields as $name => $value) {
            if (isset($class->parameters[$name])) {
                $data[$name] = $value;
            } else {
                foreach ($class->parameters as $param => $mapping) {
                    if (isset($mapping['fieldName']) && $mapping['fieldName'] == $name) {
                        $data[$param] = $value;
                        break;
                    }
                }
            }
        }

        $data[$class->getIdentifier()] = $document->getId();

        $entity = $this->sm->getSerializer()->deserialize($class->className, json_encode($data));

        if ($this->evm->hasListeners(Events::postLoad)) {
            $this->evm->dispatchEvent(Events::postLoad, new Event\LifecycleEventArgs($entity, $this->sm));
        }

        return $entity;
    }
public function hydrateEntity(ClassMetadata $class, $document)
    {
        // TODO: add support for different result set types from different clients
        // perhaps by wrapping documents in a layer of abstraction
        $data = $document->getData();
        $fields = array_merge(
            $document->hasFields() ? $document->getFields() : array(),
            array('_version' => $document->getVersion())
        );

        foreach ($fields as $name => $value) {
            if (isset($class->parameters[$name])) {
                $data[$name] = $value;
            } else {
                foreach ($class->parameters as $param => $mapping) {
                    if (isset($mapping['fieldName']) && $mapping['fieldName'] == $name) {
                        $data[$param] = $value;
                        break;
                    }
                }
            }
        }

        $data[$class->getIdentifier()] = $document->getId();

        $entity = $this->sm->getSerializer()->deserialize($class->className, json_encode($data));

        if ($this->evm->hasListeners(Events::postLoad)) {
            $this->evm->dispatchEvent(Events::postLoad, new Event\LifecycleEventArgs($entity, $this->sm));
        }

        return $entity;
    }
public function hydrateEntity ( ClassMetadata $ class , $ document ) { // TODO: add support for different result set types from different clients // perhaps by wrapping documents in a layer of abstraction $ data = $ document -> getData ( ) ; $ fields = array_merge ( $ document -> hasFields ( ) ? $ document -> getFields ( ) : array ( ) , array ( '_version' => $ document -> getVersion ( ) ) ) ; foreach ( $ fields as $ name => $ value ) { if ( isset ( $ class -> parameters [ $ name ] ) ) { $ data [ $ name ] = $ value ; } else { foreach ( $ class -> parameters as $ param => $ mapping ) { if ( isset ( $ mapping [ 'fieldName' ] ) && $ mapping [ 'fieldName' ] == $ name ) { $ data [ $ param ] = $ value ; break ; } } } } $ data [ $ class -> getIdentifier ( ) ] = $ document -> getId ( ) ; $ entity = $ this -> sm -> getSerializer ( ) -> deserialize ( $ class -> className , json_encode ( $ data ) ) ; if ( $ this -> evm -> hasListeners ( Events :: postLoad ) ) { $ this -> evm -> dispatchEvent ( Events :: postLoad , new Event \ LifecycleEventArgs ( $ entity , $ this -> sm ) ) ; } return $ entity ; }
Construct an entity object

@param ClassMetadata $class
@param object $document
Construct an entity object