lib/Doctrine/MongoDB/Collection.php
public function findAndUpdate(array $query, array $newObj, array $options = [])
    {
        if ($this->eventManager->hasListeners(Events::preFindAndUpdate)) {
            $updateEventArgs = new UpdateEventArgs($this, $query, $newObj, $options);
            $this->eventManager->dispatchEvent(Events::preFindAndUpdate, $updateEventArgs);
            $query = $updateEventArgs->getQuery();
            $newObj = $updateEventArgs->getNewObj();
            $options = $updateEventArgs->getOptions();
        }

        $result = $this->doFindAndUpdate($query, $newObj, $options);

        if ($this->eventManager->hasListeners(Events::postFindAndUpdate)) {
            $eventArgs = new MutableEventArgs($this, $result);
            $this->eventManager->dispatchEvent(Events::postFindAndUpdate, $eventArgs);
            $result = $eventArgs->getData();
        }

        return $result;
    }
public function findAndUpdate(array $query, array $newObj, array $options = [])
    {
        if ($this->eventManager->hasListeners(Events::preFindAndUpdate)) {
            $updateEventArgs = new UpdateEventArgs($this, $query, $newObj, $options);
            $this->eventManager->dispatchEvent(Events::preFindAndUpdate, $updateEventArgs);
            $query = $updateEventArgs->getQuery();
            $newObj = $updateEventArgs->getNewObj();
            $options = $updateEventArgs->getOptions();
        }

        $result = $this->doFindAndUpdate($query, $newObj, $options);

        if ($this->eventManager->hasListeners(Events::postFindAndUpdate)) {
            $eventArgs = new MutableEventArgs($this, $result);
            $this->eventManager->dispatchEvent(Events::postFindAndUpdate, $eventArgs);
            $result = $eventArgs->getData();
        }

        return $result;
    }
public function findAndUpdate ( array $ query , array $ newObj , array $ options = [ ] ) { if ( $ this -> eventManager -> hasListeners ( Events :: preFindAndUpdate ) ) { $ updateEventArgs = new UpdateEventArgs ( $ this , $ query , $ newObj , $ options ) ; $ this -> eventManager -> dispatchEvent ( Events :: preFindAndUpdate , $ updateEventArgs ) ; $ query = $ updateEventArgs -> getQuery ( ) ; $ newObj = $ updateEventArgs -> getNewObj ( ) ; $ options = $ updateEventArgs -> getOptions ( ) ; } $ result = $ this -> doFindAndUpdate ( $ query , $ newObj , $ options ) ; if ( $ this -> eventManager -> hasListeners ( Events :: postFindAndUpdate ) ) { $ eventArgs = new MutableEventArgs ( $ this , $ result ) ; $ this -> eventManager -> dispatchEvent ( Events :: postFindAndUpdate , $ eventArgs ) ; $ result = $ eventArgs -> getData ( ) ; } return $ result ; }
Invokes the findAndModify command with the update option.

This method will dispatch preFindAndUpdate and postFindAndUpdate events.

@see http://docs.mongodb.org/manual/reference/command/findAndModify/
@param array $query
@param array $newObj
@param array $options
@return array|null
@throws ResultException if the command fails
Invokes the findAndModify command with the update option .