2014-06-09 35 views
0

我知道如何扩展或覆盖污物产生的观点,创造一个像documendation文件说:扩展界面污物发电机上的Symfony2

http://symfony.com/doc/current/bundles/SensioGeneratorBundle/index.html

,但我想重用的观点和我不想把意见在同一个包在那里我有实体和污物控制器,表单和视图将被创建,所以我尝试生成我自己的命令,并延长GenerateDoctrineCrudCommand:

​​

我tryed 2个的代码,我发现getGenerator函数的n和即时得到:

[Symfony\Component\Debug\Exception\ContextErrorException]                                         
Runtime Notice: Declaration of XXX\BackendBundle\Command\BackendCrudCommand::getGenerator() should be compatible with Sensio\Bundle\GeneratorBundle\Command\GeneratorCommand::getGenerator(Symfony\Component\HttpKernel\Bundle\BundleInterface $bundle = NULL) in /home.../XXX/BackendBundle/Command/BackendCrudCommand.php line 38 

当然,我有相同的文件夹树像SensioGenerator捆绑有作为骨架,但只有一些文件重写,我想它从我的包只需要我申报文件,其绝采取defualt文件,如果不存在我捆绑。

我不知道这是否是正确的方式来做到这一点,我错过了什么。

谢谢你的建议!

+0

你的问题到底是什么?通知是否会打扰您?如果是这样,它很清楚什么是错的。你可以从'GeneratorCommand'中覆盖'getGenerator()',但是你没有指定最初提供的参数('$ bundle = NULL')。 – dbrumann

+0

编程时间太长,你是对的! – ruudy

回答

2

您错过了用参数声明函数: protected function getGenerator(BundleInterface $ bundle = null) 并使用Symfony \ Component \ HttpKernel \ Bundle \ BundleInterface;

+0

解决之后,现在即时获取:[Twig_Error_Loader] 命名空间“__main__”没有注册路径。 – ruudy

+0

请在问题中分享你的树枝文件代码。这可能会导致问题。 – szecsikecso