Symfony 全局函数
我想要一个可以从操作和模型访问的函数。记住 MVC
和 DRY
的最佳实践是什么?该函数将被多个模型使用,因此将其设为模型的公共函数也是没有意义的。
I want a function to be accessible from both action and model. What is the best practice for it keeping in mind MVC
and DRY
? The function is to be used by more than one models so it also does not make sense to make it a public function of a model.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其清理到自己的对象中比具有混合功能的助手更好,因为它使(单元)测试更容易,并允许继承来满足每个模型的单独需求。
Getting it clean into an own object is better than a helper with mixed functionality as it makes (unit) testing easier and allows inheritance to fit each models invidual needs.