src/DocumentManager.php
public function refresh(&$object)
    {
        if (!isset($this->objectsRepository[spl_object_hash($object)])) {
            return;
        }
        $repository = $this->objectsRepository[spl_object_hash($object)];
        $id = $repository->getHydrator()->unhydrate($object)["_id"];
        $projection = $repository->getLastProjection($object);
        $collection = $repository->getCollection();
        $hydrator = $repository->getHydrator();

        if (null !== ($data = $collection->findOne(['_id' => $id], ['projection' => $projection]))) {
            $hydrator->hydrate($object, $data);
            $repository->cacheObject($object);
        } else {
            $object = null;
        }
        return $object;
    }
public function refresh(&$object)
    {
        if (!isset($this->objectsRepository[spl_object_hash($object)])) {
            return;
        }
        $repository = $this->objectsRepository[spl_object_hash($object)];
        $id = $repository->getHydrator()->unhydrate($object)["_id"];
        $projection = $repository->getLastProjection($object);
        $collection = $repository->getCollection();
        $hydrator = $repository->getHydrator();

        if (null !== ($data = $collection->findOne(['_id' => $id], ['projection' => $projection]))) {
            $hydrator->hydrate($object, $data);
            $repository->cacheObject($object);
        } else {
            $object = null;
        }
        return $object;
    }
public function refresh ( & $ object ) { if ( ! isset ( $ this -> objectsRepository [ spl_object_hash ( $ object ) ] ) ) { return ; } $ repository = $ this -> objectsRepository [ spl_object_hash ( $ object ) ] ; $ id = $ repository -> getHydrator ( ) -> unhydrate ( $ object ) [ "_id" ] ; $ projection = $ repository -> getLastProjection ( $ object ) ; $ collection = $ repository -> getCollection ( ) ; $ hydrator = $ repository -> getHydrator ( ) ; if ( null !== ( $ data = $ collection -> findOne ( [ '_id' => $ id ] , [ 'projection' => $ projection ] ) ) ) { $ hydrator -> hydrate ( $ object , $ data ) ; $ repository -> cacheObject ( $ object ) ; } else { $ object = null ; } return $ object ; }
Refresh an object to last MongoDB values

@param   mixed       $object     Object to refresh
Refresh an object to last MongoDB values