Symfony4 Maker捆绑包自己的Crud Maker [英] Symfony4 MakerBundle Own Crud Maker

查看:104
本文介绍了Symfony4 Maker捆绑包自己的Crud Maker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自定义新的Makebundle Crud Maker的样板代码。没有像SensioGeneratorBundle中那样简单地覆盖模板。我试图根据原始代码生成自定义MyMakeCrud-但我为注入的DoctrineEntityHelper $ entityHelper感到挣扎。

I want to customize the boilerplate code of the new makerbundle crud maker. There is no simple overwriting the templates as it was in SensioGeneratorBundle. I tried to generate a custom MyMakeCrud based on the original code - but i struggle about the injected DoctrineEntityHelper $entityHelper.

 Cannot autowire service "App\Maker\MakeMyCrud": argument "$entityHelper" of
 method "__construct()" references class "Symfony\Bundle\MakerBundle\Doctri
 ne\DoctrineEntityHelper" but no such service exists. You should maybe alias
 this class to the existing "maker.doctrine_entity_helper" service.

现有maker.doctrine_entity_helper在maker捆绑包中定义为私有。我该如何进行注射?

The existing maker.doctrine_entity_helper is defined private in the maker bundle. How can i get the injection to run?

您能帮我吗?有没有人有一个自定义粗野一代的例子? sf4中的新功能。

Could you help me? Has anyone an example for customizing the crud generation? New in sf4.

推荐答案

您必须为其定义服务,如下所示:

You have to define a service for it like below:

    app.maker.make_crud:
    class: App\Maker\MakeCrud
    arguments: ['@maker.doctrine_helper']
    calls:
        - [configureCommand, ['@security.command.user_password_encoder', '@?']]
        - [interact, ['@?', '@?', '@security.command.user_password_encoder']]
    tags:
        - { name: maker.command }

我将其放置在 config / services.yaml 中。

App\ Maker\MakeCrud 是您的原始制造商类。

App\Maker\MakeCrud is your crud maker class.

应该将其真正放置在services_dev.yaml文件中。

Should really place this in a services_dev.yaml file.

希望这会有所帮助。

这篇关于Symfony4 Maker捆绑包自己的Crud Maker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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