如何为sonata-admin定义/传递实体管理器 [英] How to define/pass the entity manager for sonata-admin

查看:61
本文介绍了如何为sonata-admin定义/传递实体管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了本教程使用FOSUserBundle安装SonataAdmin.

I followed this tutorial to install SonataAdmin with FOSUserBundle.

现在,我不断收到此错误消息:没有为类Application \ Sonata \ UserBundle \ Entity \ User

Now i keep getting this Error Message: No entity manager defined for class Application\Sonata\UserBundle\Entity\User

但是我如何设置/通过EntityManager?我还没有发现有关配置它的任何信息,也没有发现有关此错误含义的任何提示.任何人有帮助吗?

But how do i set/pass the EntityManager? I haven't found anything about configuring it or any hint on what this error means. Any help anyone?

编辑#1:

根据要求,到目前为止,这是我在config.yml中用于奏鸣曲的内容:

As asked for, here is what i have in my config.yml for sonata so far:

sonata_block:
    default_contexts: [cms]
    blocks:
        sonata.admin.block.admin_list:
            contexts:   [admin]
        sonata.block.service.text:
        sonata.block.service.rss:


编辑#2:

我为Doctrine2 ORM Admin添加了实体管理器配置部分,但是在文档中提到如果保留为空,则应仅使用默认值.不过,它并不能解决我的问题.

I added the entity manager configuration part for Doctrine2 ORM Admin thou it is mentioned in the Documentation that if left null, it should just use the default. Still, it doesn't solve my problem.

sonata_doctrine_orm_admin:
    # default value is null, so doctrine uses the value defined in the configuration
    entity_manager: '@doctrine.orm.entity_manager'


编辑#3:我也将auto_mapping也设置为true,即使默认情况下也是如此.仍然没有解决此问题的方法.


Edit #3: I did set auto_mapping to true as well, even thou that also is true by default. Still no Solution to this Problem.

推荐答案

我的config.yml中缺少的是:

What was missing in my config.yml was:

doctrine:
  [...]
  orm:
    [...]
    entity_managers:
      default:
        mappings:
          ApplicationSonataUserBundle: ~
          SonataUserBundle: ~

这篇关于如何为sonata-admin定义/传递实体管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆