sfDoctrineRouteCollection 的默认操作

发布于 2024-10-14 16:01:08 字数 234 浏览 10 评论 0原文

我正在使用 Symfony 的管理生成器,总的来说一切都按我想要的方式工作。

但是,我想知道是否有一种简单的方法来设置模块的默认操作。生成器默认使用 sfDoctrineRouteCollection 设置路由。

对于特定模块,我希望默认操作为“新”而不是“索引”,但仍然让“返回列表”等链接正常工作。

我所说的简单是指生成器配置选项或类似的东西,我已经检查了文档,但还没有运气。

谢谢大家

I'm using Symfony's admin generator and on the whole everything is working as I would like.

However, I'd like to know if there is an easy way to set the default action for a module. The generator sets up routes using sfDoctrineRouteCollection by default.

For a specific module, I would like the default action to be "new" rather than "index" but still have the links like "back to list" work correctly.

By easy I mean a generator configuration option or something like that, I have checked the documentation but no luck yet.

Thanks everyone

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无语# 2024-10-21 16:01:08

好吧,我从来没有这样做过,我不确定我会这样做,但是因为 ./symfony 命令运行的所有内容都是用 symfony 编写的(根据 Fabien 的说法),所以你可以利用它,你可以......

lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/

在那里你会找到一组模板,其中包含生成时构建的 CRUD,我假设更改这些模板或使用这些模板的代码将为您提供所需的内容。

(请注意,我看到您指定了管理生成器,我假设这是该管理生成器以及前端的代码。如果不是,您可能需要破解更多内容。)

只是扩展您的评论。我同意你的观点,yaml 会更好。以上是我的大锤方法。然而,如果这些模板中的结构是硬连线的,那么目前 yaml 方法将无法工作,因为它没有可供控制的变量。人们需要从这些模板中取出硬接线并将它们移动到 yaml 文件中,然后它就可以工作了。然而,由于 Symfony2 即将发布,除非速度很快,否则可能不值得。但是,如果它以相同/相似的方式工作,则可能在 S2 中

OK i have never done this and i am not sure i would but as everything that runs as the ./symfony command is written in symfony (according to Fabien) so you can leverage it you go to ......

lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/data/generator/sfDoctrineModule/default/template/templates/

there you will find a set of templates that comprise the CRUD that is built when you generate and i assume altering those or the code that uses those will give you what you want.

(Note i see you specified Admin Generator i assume this is the code for that as well as the frontend. If not you might need to hack in that are a bit more.)

Just expanding on your comment. I agree with you the yaml would be better. Above was my sledgehammer approach. However is the structure is hardwired in those templates then the yaml approach, at the moment, wouldn't work as it has no variables to control. One would need to take the hardwiring out of those templates and move them to a yaml file and then it will work. However as Symfony2 is close to release it's perhaps not worth it unless it's quick. However could be in S2 if it works in the same/similar way

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文