protected function tryConvertArrayToObject($data, $object)
    {
        $metadata         = $this->metadata;
        $identifierNames  = $metadata->getIdentifierFieldNames($object);
        $identifierValues = array();

        if (empty($identifierNames)) {
            return $object;
        }

        foreach ($identifierNames as $identifierName) {
            if (!isset($data[$identifierName])) {
                return $object;
            }

            $identifierValues[$identifierName] = $data[$identifierName];
        }

        return $this->find($identifierValues, $metadata->getName());
    }
protected function tryConvertArrayToObject($data, $object)
    {
        $metadata         = $this->metadata;
        $identifierNames  = $metadata->getIdentifierFieldNames($object);
        $identifierValues = array();

        if (empty($identifierNames)) {
            return $object;
        }

        foreach ($identifierNames as $identifierName) {
            if (!isset($data[$identifierName])) {
                return $object;
            }

            $identifierValues[$identifierName] = $data[$identifierName];
        }

        return $this->find($identifierValues, $metadata->getName());
    }
protected function tryConvertArrayToObject ( $ data , $ object ) { $ metadata = $ this -> metadata ; $ identifierNames = $ metadata -> getIdentifierFieldNames ( $ object ) ; $ identifierValues = array ( ) ; if ( empty ( $ identifierNames ) ) { return $ object ; } foreach ( $ identifierNames as $ identifierName ) { if ( ! isset ( $ data [ $ identifierName ] ) ) { return $ object ; } $ identifierValues [ $ identifierName ] = $ data [ $ identifierName ] ; } return $ this -> find ( $ identifierValues , $ metadata -> getName ( ) ) ; }
This function tries, given an array of data, to convert it to an object if the given array contains
an identifier for the object. This is useful in a context of updating existing entities, without ugly
tricks like setting manually the existing id directly into the entity

@param  array  $data   The data that may contain identifiers keys
@param  object $object
@return object
This function tries given an array of data to convert it to an object if the given array contains an identifier for the object . This is useful in a context of updating existing entities without ugly tricks like setting manually the existing id directly into the entity