我可以在观察者中使用控制器方法吗?

发布于 2024-09-16 13:11:34 字数 30 浏览 2 评论 0原文

我需要从缓存观察器引用控制器方法,我该怎么做?

I need to refer to a controller method from a cache observer, How can I make it?

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

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

发布评论

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

评论(2

等待我真够勒 2024-09-23 13:11:34

如果你需要这样做,那么架构就会出现问题。它打破了 MVC 模式,因为观察者绑定到模型,我们应该从控制器调用模型方法,而不是反之亦然。

If you need to do it, then something goes wrong with architecture. It breaks MVC pattern because observers bind to models, and we should call model methods from controller and not vice-versa.

聚集的泪 2024-09-23 13:11:34

观察者绑定到模型,至少你可以在lib中编写一些自定义代码,然后在观察者中重用它。顺便说一句,这可能取决于你在做什么

an observer binds to models, at least you can write some custom code in lib, then reuse it in obsever. by the way it may depend from what you're doing

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