Sonata with Symfony3.4 - 依赖注入(正确的 Sonata 管理服务声明)
Sonata with Symfony3.4 - Dependency injection (Correct Sonata admin service declaration)
我正在尝试在我的 symphony 3.4 项目上安装 Sonata (sonata-project/admin-bundle)。
不幸的是,我在添加第一个服务时出错了。
services.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)
有谁能帮帮我吗?
首先,将应用前缀添加到您的管理服务是个好主意。
但是你在声明 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' }
我正在尝试在我的 symphony 3.4 项目上安装 Sonata (sonata-project/admin-bundle)。
不幸的是,我在添加第一个服务时出错了。
services.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)
有谁能帮帮我吗?
首先,将应用前缀添加到您的管理服务是个好主意。
但是你在声明 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' }