src/Repository/AbstractRepository.php
public function create(array $data = null, $persist = false)
    {
        if (null === $this->entityPrototype) {
            throw new \RuntimeException('Could not create an entity. No prototype is set!');
        }

        $entity = clone $this->entityPrototype;
        
        $eventArgs = new DoctrineMongoODM\Event\EventArgs([
            'entity' => $entity
        ]);
        $this->dm->getEventManager()
            ->dispatchEvent(DoctrineMongoODM\Event\RepositoryEventsSubscriber::postCreate, $eventArgs);
        
        if (null !== $data) {
            foreach ($data as $property => $value) {
                $setter = "set$property";

                if (method_exists($entity, $setter)) {
                    $entity->$setter($value);
                }
            }
        }

        if ($persist) {
            $this->dm->persist($entity);
        }

        return $entity;
    }
public function create(array $data = null, $persist = false)
    {
        if (null === $this->entityPrototype) {
            throw new \RuntimeException('Could not create an entity. No prototype is set!');
        }

        $entity = clone $this->entityPrototype;
        
        $eventArgs = new DoctrineMongoODM\Event\EventArgs([
            'entity' => $entity
        ]);
        $this->dm->getEventManager()
            ->dispatchEvent(DoctrineMongoODM\Event\RepositoryEventsSubscriber::postCreate, $eventArgs);
        
        if (null !== $data) {
            foreach ($data as $property => $value) {
                $setter = "set$property";

                if (method_exists($entity, $setter)) {
                    $entity->$setter($value);
                }
            }
        }

        if ($persist) {
            $this->dm->persist($entity);
        }

        return $entity;
    }
@param array $data

@return mixed