protected function mapObjectToEntity(array $mapping, \stdClass $data, $entity)
    {
        foreach ($mapping as $dataProperty => $map) {
            if (property_exists($data, $dataProperty)) {
                if (is_string($map) || is_object($map) || is_int($map)) {
                    try {
                        $setter = $this->getEntitySetter($entity, $map);
                        if ($data->{$dataProperty}) {
                            // Inject data into entity
                            call_user_func([$entity, $setter], $data->{$dataProperty});
                        }
                    } catch (\LogicException $e) {
                        //no stter
                    }
                } else {
                    // Retrieve the entity setter

                    call_user_func($map, $entity, $data);
                }
            }
        }

        return $entity;
    }
protected function mapObjectToEntity(array $mapping, \stdClass $data, $entity)
    {
        foreach ($mapping as $dataProperty => $map) {
            if (property_exists($data, $dataProperty)) {
                if (is_string($map) || is_object($map) || is_int($map)) {
                    try {
                        $setter = $this->getEntitySetter($entity, $map);
                        if ($data->{$dataProperty}) {
                            // Inject data into entity
                            call_user_func([$entity, $setter], $data->{$dataProperty});
                        }
                    } catch (\LogicException $e) {
                        //no stter
                    }
                } else {
                    // Retrieve the entity setter

                    call_user_func($map, $entity, $data);
                }
            }
        }

        return $entity;
    }
protected function mapObjectToEntity ( array $ mapping , \ stdClass $ data , $ entity ) { foreach ( $ mapping as $ dataProperty => $ map ) { if ( property_exists ( $ data , $ dataProperty ) ) { if ( is_string ( $ map ) || is_object ( $ map ) || is_int ( $ map ) ) { try { $ setter = $ this -> getEntitySetter ( $ entity , $ map ) ; if ( $ data -> { $ dataProperty } ) { // Inject data into entity call_user_func ( [ $ entity , $ setter ] , $ data -> { $ dataProperty } ) ; } } catch ( \ LogicException $ e ) { //no stter } } else { // Retrieve the entity setter call_user_func ( $ map , $ entity , $ data ) ; } } } return $ entity ; }
Maps raw object data into entity properties.

Mapping array format :
- key   : the name of the property in the \stdClass
- value : either an entity property (accessible with a setter) or a callback

@param array     $mapping
@param \stdClass $data
@param mixed     $entity

@return mixed the updated entity

@throws \LogicException
Maps raw object data into entity properties .