无法覆盖 Symfony2 GeneratorBundle 中的标准骨架视图
我无法覆盖 GeneratorBundle 的骨架视图。
我首先尝试在 /app/Resources/SensioGeneratorBundle/sculpt/crud/views/index.html.twig 中添加我的视图,
但它不起作用,所以我尝试创建一个扩展 SensioGeneratorBundle 的新捆绑包,并将我的视图复制到其中资源文件夹。
我已经设法使用树枝形式的主题,但我需要个性化由doctrine:generate:crud 命令生成的视图。
I don't manage to override the skeleton views of the generatorBundle.
I've first tried by adding my view in /app/Resources/SensioGeneratorBundle/skeleton/crud/views/index.html.twig
It didn't worked so I tried to create a new Bundle extending SensioGeneratorBundle and copy the my view in its Resources folder.
I already manage to use themes for twig forms, but I need to personalize the views generated by the doctrine:generate:crud command.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先:相应的骨架视图位于此处:
快速而肮脏,您应该可以通过覆盖这些视图文件来解决问题 - 但这不是我们想要的;)
在:
有一个生成器的访问器:
可以尝试覆盖此方法在您的扩展 Bundle 中并在构造函数中设置不同的
$sculptureDir
。编辑:
在我的测试环境中如何实现它的快速示例(我只做了一个快速测试;):
为自定义生成器生成一个新的包:
php app/consolegenerate:bundle< /code> 并按照说明进行操作。不需要路线。我为此示例选择:Acme/CrudGeneratorBundle(或使用现有的包)
在新创建的包目录中创建一个名为“Command”的文件夹。
将命令类放置在此文件夹中。
将vendor/bundles/Sensio/Bundle/GeneratorBundle/Resources/sculpture/crud复制到您的资源中(在我的示例中为“src/Acme/CrudGeneratorBundle/Resources/crud”)
First of all: The corresponding skeleton views are located here:
Quick and dirty you should be fine by overriding these view files - but thats not what we want ;)
In:
there is an accessor for the Generator:
One can try to override this method in your extending Bundle and set a different
$skeletonDir
in the constructor.Edit:
Quick example in my test environment how it can be achieved (I only made a quick test ;):
Generate a new bundle for the custom generator:
php app/console generate:bundle
and follow the instructions. A route is not needed. I chose for this example: Acme/CrudGeneratorBundle (Or use an existing bundle)Create a folder called "Command" in the newly created bundle directory.
Place a command class in this folder.
Copy the vendor/bundles/Sensio/Bundle/GeneratorBundle/Resources/skeleton/crud to your Resources (in my example "src/Acme/CrudGeneratorBundle/Resources/crud")
这对我来说是最好的解决方案:
symfony2-how-to-override-core-template
不添加命令,但会修改该特定包的骨架。
This was the best solution for me:
symfony2-how-to-override-core-template
doesn't add a command but modifies the skeleton for that particular bundle.