private function computeReferenceChanges($mapping, $reference)
    {
        $targetClass = $this->dm->getClassMetadata(get_class($reference));
        $state = $this->getDocumentState($reference);

        switch ($state) {
            case self::STATE_NEW:
                if (!($mapping['cascade'] & ClassMetadata::CASCADE_PERSIST)) {
                    throw CascadeException::newDocumentFound(self::objToStr($reference));
                }
                $this->persistNew($targetClass, $reference);
                $this->computeChangeSet($targetClass, $reference);
                break;
            case self::STATE_DETACHED:
                throw new InvalidArgumentException('A detached document was found through a reference during cascading a persist operation: '.self::objToStr($reference, $this->dm));
        }
    }
private function computeReferenceChanges($mapping, $reference)
    {
        $targetClass = $this->dm->getClassMetadata(get_class($reference));
        $state = $this->getDocumentState($reference);

        switch ($state) {
            case self::STATE_NEW:
                if (!($mapping['cascade'] & ClassMetadata::CASCADE_PERSIST)) {
                    throw CascadeException::newDocumentFound(self::objToStr($reference));
                }
                $this->persistNew($targetClass, $reference);
                $this->computeChangeSet($targetClass, $reference);
                break;
            case self::STATE_DETACHED:
                throw new InvalidArgumentException('A detached document was found through a reference during cascading a persist operation: '.self::objToStr($reference, $this->dm));
        }
    }
private function computeReferenceChanges ( $ mapping , $ reference ) { $ targetClass = $ this -> dm -> getClassMetadata ( get_class ( $ reference ) ) ; $ state = $ this -> getDocumentState ( $ reference ) ; switch ( $ state ) { case self :: STATE_NEW : if ( ! ( $ mapping [ 'cascade' ] & ClassMetadata :: CASCADE_PERSIST ) ) { throw CascadeException :: newDocumentFound ( self :: objToStr ( $ reference ) ) ; } $ this -> persistNew ( $ targetClass , $ reference ) ; $ this -> computeChangeSet ( $ targetClass , $ reference ) ; break ; case self :: STATE_DETACHED : throw new InvalidArgumentException ( 'A detached document was found through a reference during cascading a persist operation: ' . self :: objToStr ( $ reference , $ this -> dm ) ) ; } }
Computes the changes of a reference.

@param array $mapping   the mapping data
@param mixed $reference the referenced document.
Computes the changes of a reference .