public function determineDocumentId($document, ClassMetadata $metadata = null)
    {
        if (!$metadata) {
            $metadata = $this->dm->getClassMetadata(get_class($document));
        }
        if ($metadata->identifier) {
            $id = $metadata->getIdentifierValue($document);
            if ($id) {
                return $id;
            }
        }

        return $this->getDocumentId($document, false);
    }
public function determineDocumentId($document, ClassMetadata $metadata = null)
    {
        if (!$metadata) {
            $metadata = $this->dm->getClassMetadata(get_class($document));
        }
        if ($metadata->identifier) {
            $id = $metadata->getIdentifierValue($document);
            if ($id) {
                return $id;
            }
        }

        return $this->getDocumentId($document, false);
    }
public function determineDocumentId ( $ document , ClassMetadata $ metadata = null ) { if ( ! $ metadata ) { $ metadata = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; } if ( $ metadata -> identifier ) { $ id = $ metadata -> getIdentifierValue ( $ document ) ; if ( $ id ) { return $ id ; } } return $ this -> getDocumentId ( $ document , false ) ; }
Try to determine the document id first by looking into the document,
but if not mapped, look into the document id cache.

@param object        $document
@param ClassMetadata $metadata

@return string|null the current or stored id, or null if nothing can be found.
Try to determine the document id first by looking into the document but if not mapped look into the document id cache .