奏鸣曲管理员捆绑symfony

anu*_*bis 7 php symfony fosuserbundle sonata-admin

我试图安装sonata admin bundle来管理我的用户.

我使用FOS用户包.

我已经说明了,但是出了什么问题,我找不到.

我有错误:

无法自动确定基本路由名称,请在C:\ Users\Alexandre\hubiC\www\questionnaire\app/config中baseRouteName为管理类定义默认值UserBundle\Admin\UserAdmin.(从"C:\ Users\Alexandre\hubiC\www\questionnaire\app/config\routing.yml"导入).

在我的服务中,我有:

services:
    sonata.admin.user:
        class: UserBundle\Admin\UserAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: "Content", label: "User" }
        arguments:
            - ~
            - UserBundle\Entity\User
            - ~
        calls:
            - [ setTranslationDomain, [UserBundle]]
Run Code Online (Sandbox Code Playgroud)

在我的配置中:

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }
    - { resource: @UserBundle/Resources/config/admin.yml }
sonata_block:
    default_contexts: [cms]
    blocks:
        # Enable the SonataAdminBundle block
        sonata.admin.block.admin_list:
            contexts:   [admin]
        # Your other blocks
Run Code Online (Sandbox Code Playgroud)

和UserAdmin文件:

<?php // 
namespace UserBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;

class UserAdmin extends Admin
{
    // Fields to be shown on create/edit forms
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('nom')
            ->add('prenom')
            ->add('adresse')
            ->add('npa')
            ->add('localite')
            ->add('entreprise')
        ;
    }

    // Fields to be shown on filter forms
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('nom')
            ->add('prenom')
            ->add('adresse')
            ->add('npa')
            ->add('localite')
            ->add('entreprise')
        ;
    }

    // Fields to be shown on lists
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('nom')
            ->add('prenom')
            ->add('adresse')
            ->add('npa')
            ->add('localite')
            ->add('entreprise')
        ;
    }
}
Run Code Online (Sandbox Code Playgroud)

此文件位于UserBundle/Admin文件夹中.

哪里错了?

谢谢

Pio*_*las 11

我不确定,为什么sonata不会自动为你生成baseRouteName.我想你定义了自定义目录结构或自定义类名.您可以转储getBaseRouteName方法的返回.此方法用于生成路由信息.

你也可以定义它(不是自动的):

   protected $baseRouteName = 'your_name'; 
   protected $baseRoutePattern = 'your_name';
Run Code Online (Sandbox Code Playgroud)

您可以通过app/console路由器检查控制台中的路由器:debug,来自admin的新路由应该在那里

文档中描述了路由问题:https: //sonata-project.org/bundles/admin/2-3/doc/reference/routing.html