Symfony 的 Easyadmin 捆绑包

Easyadmin bundle of Symfony

我正在使用 Symfony 创建后端。我想创建子菜单。我在 config/packages 内的 easy_admin 文件中编写以下代码:

easy_admin:
    design:
        menu:
            - label: 'Products'
              icon: 'shopping-basket'
              children:
                  - { entity: 'Product', icon: 'th-list', label: 'List Products' }
                  - { entity: 'Product', label: 'Add Product' }
                  - { label: 'Additional Items' }
                  - { entity: 'User', label: 'Users' }

我已经在 src/Entity

中创建了 ProductUser 的实体

但我收到错误消息:

The "Product" entity included in the "menu" option is not managed by EasyAdmin. The menu can only include any of these entities: .

我做错了什么?先感谢您!

要解决您的问题,您首先需要仔细阅读 easyadmin 上的文档。然后你发现你需要将你的实体添加到 easyadmin 配置文件中,如下所示:

# config/packages/easy_admin.yaml
easy_admin:
# ...
    entities:
        - App\Entity\Product
        - App\Entity\User

# config/packages/easy_admin.yaml
easy_admin:
# ...
    entities:
        Product:
            class: App\Entity\Product
        User:
            class: App\Entity\User