【发布时间】:2014-05-30 05:23:57
【问题描述】:
我需要在 Sonata Admin 的 postPersist 回调中保留一个非关联实体的对象。我无法在 Sonata Admin 中获得$em = $this->getDoctrine()->getEntityManager();。
【问题讨论】:
标签: doctrine-orm sonata-admin symfony-2.4
我需要在 Sonata Admin 的 postPersist 回调中保留一个非关联实体的对象。我无法在 Sonata Admin 中获得$em = $this->getDoctrine()->getEntityManager();。
【问题讨论】:
标签: doctrine-orm sonata-admin symfony-2.4
您可以使用$this->getModelManager()->create($object); 来持久化 Sonata Admin Bundle 中的任何对象。
【讨论】:
你可以用这个太像巴兰回答
$query = $this->getModelManager()->createQuery('AppBundle:testEntity', 'entity');
$results = $query->execute();
【讨论】: