2

我正在尝试在我的 symphony 3.4 项目上安装 Sonata (sonata-project/admin-bundle)。

不幸的是,当我添加我的第一个服务时出现错误。

服务.yaml:

    admin.carrier:
    class: App\Admin\CarrierAdmin
    arguments: [~, App\Entity\Carrier, ~]
    tags:
        - { name: sonata.admin, manager_type: orm, label: Carrier }
    public: true

访问http://localhost/admin/dashboard时出现的错误:

1) FatalThrowableError

Type error: strlen() expects parameter 1 to be string, null given
in AddDependencyCallsCompilerPass.php (line 401)
at strlen(null)in AddDependencyCallsCompilerPass.php (line 401)
at AddDependencyCallsCompilerPass->replaceDefaultArguments(array('admin.carrier', 'SonataAdminBundle:CRUD'), object(Definition), null)in AddDependencyCallsCompilerPass.php (line 67)
at AddDependencyCallsCompilerPass->process(object(ContainerBuilder))in Compiler.php (line 141)
at Compiler->compile(object(ContainerBuilder))in ContainerBuilder.php (line 753)
at ContainerBuilder->compile()in Kernel.php (line 634)
at Kernel->initializeContainer()in Kernel.php (line 137)
at Kernel->boot()in Kernel.php (line 197)
at Kernel->handle(object(Request))in index.php (line 25)

有人可以帮助我吗?

4

1 回答 1

1

首先,将应用前缀添加到您的管理服务中是个好主意。但是您在声明 CRUD 控制器时的错误。第三个参数 - 是此管理服务的 CRUD 控制器。因此,您应该使用默认值:SonataAdminBundle:CRUD

app.admin.carrier:
    class: App\Admin\CarrierAdmin
    arguments: [~, App\Entity\Carrier, SonataAdminBundle:CRUD]
    tags:
        - { name: sonata.admin, manager_type: orm, group: 'carrier', label_catalogue: "admin", label: 'carrier' }
于 2017-12-21T09:55:37.650 回答