public function create($params = [], ClassMetadata $metadata = null)
    {
        $params = new ArrayObject($params);
        $builder = $this->getEntityBuilder();
        /** @var Entity $entity */
        $entity = $builder->getEntity();
        $preEventArgs = new HydrationEvent($params, ['entity' => $entity, 'repository' => $this]);
        $this->event()->dispatch(StorageEvents::PRE_HYDRATE, $preEventArgs);
        $builder->create($params, $entity);
        $postEventArgs = new HydrationEvent($params, ['entity' => $entity, 'repository' => $this]);
        $this->event()->dispatch(StorageEvents::POST_HYDRATE, $postEventArgs);

        return $entity;
    }
public function create($params = [], ClassMetadata $metadata = null)
    {
        $params = new ArrayObject($params);
        $builder = $this->getEntityBuilder();
        /** @var Entity $entity */
        $entity = $builder->getEntity();
        $preEventArgs = new HydrationEvent($params, ['entity' => $entity, 'repository' => $this]);
        $this->event()->dispatch(StorageEvents::PRE_HYDRATE, $preEventArgs);
        $builder->create($params, $entity);
        $postEventArgs = new HydrationEvent($params, ['entity' => $entity, 'repository' => $this]);
        $this->event()->dispatch(StorageEvents::POST_HYDRATE, $postEventArgs);

        return $entity;
    }
public function create ( $ params = [ ] , ClassMetadata $ metadata = null ) { $ params = new ArrayObject ( $ params ) ; $ builder = $ this -> getEntityBuilder ( ) ; /** @var Entity $entity */ $ entity = $ builder -> getEntity ( ) ; $ preEventArgs = new HydrationEvent ( $ params , [ 'entity' => $ entity , 'repository' => $ this ] ) ; $ this -> event ( ) -> dispatch ( StorageEvents :: PRE_HYDRATE , $ preEventArgs ) ; $ builder -> create ( $ params , $ entity ) ; $ postEventArgs = new HydrationEvent ( $ params , [ 'entity' => $ entity , 'repository' => $ this ] ) ; $ this -> event ( ) -> dispatch ( StorageEvents :: POST_HYDRATE , $ postEventArgs ) ; return $ entity ; }
Creates a new empty entity and passes the supplied data to the constructor.

@param array         $params
@param ClassMetadata $metadata

@return Entity
Creates a new empty entity and passes the supplied data to the constructor .