src/DocumentManager.php
public function persist($object, $collection = null)
    {
        $repository = $this->getRepository(get_class($object), $collection);
        $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_PRE_PERSIST, $object);
        $this->addObject($object, ObjectManager::OBJ_NEW, $repository);
        $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_POST_PERSIST, $object);

        return $this;
    }
public function persist($object, $collection = null)
    {
        $repository = $this->getRepository(get_class($object), $collection);
        $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_PRE_PERSIST, $object);
        $this->addObject($object, ObjectManager::OBJ_NEW, $repository);
        $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_POST_PERSIST, $object);

        return $this;
    }
public function persist ( $ object , $ collection = null ) { $ repository = $ this -> getRepository ( get_class ( $ object ) , $ collection ) ; $ repository -> getClassMetadata ( ) -> getEventManager ( ) -> execute ( EventManager :: EVENT_PRE_PERSIST , $ object ) ; $ this -> addObject ( $ object , ObjectManager :: OBJ_NEW , $ repository ) ; $ repository -> getClassMetadata ( ) -> getEventManager ( ) -> execute ( EventManager :: EVENT_POST_PERSIST , $ object ) ; return $ this ; }
Persist object in document manager

@param   mixed   $object Object to persist
@param   string  $collection Collection where object is persisted
@return  void
Persist object in document manager