Symfony 全局函数

发布于 2024-12-21 06:11:24 字数 107 浏览 6 评论 0原文

我想要一个可以从操作和模型访问的函数。记住 MVCDRY 的最佳实践是什么?该函数将被多个模型使用,因此将其设为模型的公共函数也是没有意义的。

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 技术交流群。

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

发布评论

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

评论(1

﹂绝世的画 2024-12-28 06:11:24

将其清理到自己的对象中比具有混合功能的助手更好,因为它使(单元)测试更容易,并允许继承来满足每个模型的单独需求。

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.

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