【问题标题】:Sonata Admin Bundle saving non-associated recordSonata Admin Bundle 保存非关联记录
【发布时间】:2014-05-30 05:23:57
【问题描述】:

我需要在 Sonata Admin 的 postPersist 回调中保留一个非关联实体的对象。我无法在 Sonata Admin 中获得$em = $this->getDoctrine()->getEntityManager();

【问题讨论】:

    标签: doctrine-orm sonata-admin symfony-2.4


    【解决方案1】:

    您可以使用$this->getModelManager()->create($object); 来持久化 Sonata Admin Bundle 中的任何对象。

    【讨论】:

      【解决方案2】:

      你可以用这个太像巴兰回答

              $query = $this->getModelManager()->createQuery('AppBundle:testEntity', 'entity');
              $results = $query->execute();
      

      【讨论】:

        猜你喜欢
        • 2016-04-20
        • 2013-06-04
        • 2016-09-03
        • 1970-01-01
        • 1970-01-01
        • 2016-10-11
        • 2013-03-06
        • 2017-05-18
        • 2021-11-09
        相关资源
        最近更新 更多