public function getDocumentState($document)
    {
        $oid = spl_object_hash($document);
        if (!isset($this->documentState[$oid])) {
            // this will only use the metadata if id is mapped
            $id = $this->determineDocumentId($document);

            if (!$id) {
                return self::STATE_NEW;
            }

            if ($this->getDocumentById($id)) {
                return self::STATE_DETACHED;
            }

            return $this->dm->getPhpcrSession()->nodeExists($id)
                ? self::STATE_DETACHED : self::STATE_NEW;
        }

        return $this->documentState[$oid];
    }
public function getDocumentState($document)
    {
        $oid = spl_object_hash($document);
        if (!isset($this->documentState[$oid])) {
            // this will only use the metadata if id is mapped
            $id = $this->determineDocumentId($document);

            if (!$id) {
                return self::STATE_NEW;
            }

            if ($this->getDocumentById($id)) {
                return self::STATE_DETACHED;
            }

            return $this->dm->getPhpcrSession()->nodeExists($id)
                ? self::STATE_DETACHED : self::STATE_NEW;
        }

        return $this->documentState[$oid];
    }
public function getDocumentState ( $ document ) { $ oid = spl_object_hash ( $ document ) ; if ( ! isset ( $ this -> documentState [ $ oid ] ) ) { // this will only use the metadata if id is mapped $ id = $ this -> determineDocumentId ( $ document ) ; if ( ! $ id ) { return self :: STATE_NEW ; } if ( $ this -> getDocumentById ( $ id ) ) { return self :: STATE_DETACHED ; } return $ this -> dm -> getPhpcrSession ( ) -> nodeExists ( $ id ) ? self :: STATE_DETACHED : self :: STATE_NEW ; } return $ this -> documentState [ $ oid ] ; }
Get the state of this document.

STATE_NEW:      the document is not persisted, but a valid mapped document
STATE_MANAGED:  the document is tracked and will be updated on flush
STATE_REMOVED:  the document is scheduled for removal
STATE_DETACHED: there is a corresponding Node in storage, but this document is not bound to it

@param object $document the document to get the state of

@return int one of the STATE_* constants of this class
Get the state of this document .