src/Repository.php
protected function createObject($data, $options = [])
    {
        $object = null;
        if ($data != null) {
            $id = isset($data['_id']) ? serialize($data['_id']) . $this->getCollection() : null;
            $model = $this->getModelName();

            $softHydrate = false;
            if (null !== $this->documentManager->getObject($id)) {
                $softHydrate = true;
                $object = $this->documentManager->getObject($id);
            } else {
                $object = new $this->modelName();
            }

            $this->hydrator->hydrate($object, $data, $softHydrate);

            $this->classMetadata->getEventManager()->execute(EventManager::EVENT_POST_LOAD, $object);
            if (!isset($options['readOnly']) || $options['readOnly'] != true) {
                $oid = spl_object_hash($object);
                $data = $this->hydrator->unhydrate($object);
                $id = isset($data['_id']) ? serialize($data['_id']) . $this->getCollection() : $oid;
                $projection = isset($options['projection']) ? $options['projection'] : [];
                $this->lastProjectionCache->save($id, $projection);
                $this->cacheObject($object);
                $this->documentManager->addObject($object, DocumentManager::OBJ_MANAGED, $this);
            }
            return $object;
        }
        return $object;
    }
protected function createObject($data, $options = [])
    {
        $object = null;
        if ($data != null) {
            $id = isset($data['_id']) ? serialize($data['_id']) . $this->getCollection() : null;
            $model = $this->getModelName();

            $softHydrate = false;
            if (null !== $this->documentManager->getObject($id)) {
                $softHydrate = true;
                $object = $this->documentManager->getObject($id);
            } else {
                $object = new $this->modelName();
            }

            $this->hydrator->hydrate($object, $data, $softHydrate);

            $this->classMetadata->getEventManager()->execute(EventManager::EVENT_POST_LOAD, $object);
            if (!isset($options['readOnly']) || $options['readOnly'] != true) {
                $oid = spl_object_hash($object);
                $data = $this->hydrator->unhydrate($object);
                $id = isset($data['_id']) ? serialize($data['_id']) . $this->getCollection() : $oid;
                $projection = isset($options['projection']) ? $options['projection'] : [];
                $this->lastProjectionCache->save($id, $projection);
                $this->cacheObject($object);
                $this->documentManager->addObject($object, DocumentManager::OBJ_MANAGED, $this);
            }
            return $object;
        }
        return $object;
    }
protected function createObject ( $ data , $ options = [ ] ) { $ object = null ; if ( $ data != null ) { $ id = isset ( $ data [ '_id' ] ) ? serialize ( $ data [ '_id' ] ) . $ this -> getCollection ( ) : null ; $ model = $ this -> getModelName ( ) ; $ softHydrate = false ; if ( null !== $ this -> documentManager -> getObject ( $ id ) ) { $ softHydrate = true ; $ object = $ this -> documentManager -> getObject ( $ id ) ; } else { $ object = new $ this -> modelName ( ) ; } $ this -> hydrator -> hydrate ( $ object , $ data , $ softHydrate ) ; $ this -> classMetadata -> getEventManager ( ) -> execute ( EventManager :: EVENT_POST_LOAD , $ object ) ; if ( ! isset ( $ options [ 'readOnly' ] ) || $ options [ 'readOnly' ] != true ) { $ oid = spl_object_hash ( $ object ) ; $ data = $ this -> hydrator -> unhydrate ( $ object ) ; $ id = isset ( $ data [ '_id' ] ) ? serialize ( $ data [ '_id' ] ) . $ this -> getCollection ( ) : $ oid ; $ projection = isset ( $ options [ 'projection' ] ) ? $ options [ 'projection' ] : [ ] ; $ this -> lastProjectionCache -> save ( $ id , $ projection ) ; $ this -> cacheObject ( $ object ) ; $ this -> documentManager -> addObject ( $ object , DocumentManager :: OBJ_MANAGED , $ this ) ; } return $ object ; } return $ object ; }
Create object based on provided data

@param   array   $data       Array of data which will hydrate object
@param   array   $options    Options
@return  void
Create object based on provided data