CakePHP - 模型或控制器职责?
我有一个用户实体模型,它依赖于来自休息服务的一些额外数据。在我的项目中,我开发了一个包来检索额外的数据并将其放入 Vendors/Components 文件夹中。所以我在我的用户控制器中有一个注册方法,它接受表单数据,后面跟着来自休息服务的额外数据。
我的问题是我应该在哪里调用休息服务功能,从而检索并附加到控制器或模型中的用户数据? ps 我的猜测是用户模型可以更好地处理其余功能,但是在 cakephp 的模型中使用模型中的组件有点但很尴尬。
i have a model of User entity, which relies on some extra data from rest service. In my project i developed a package for retrieving that extra data and put it into Vendors/Components folders. So i have a register method in my User controller which accepts form data that is to be followed by extra data from rest service.
My question is where should I call rest service functionality and therefore retrieve and append to User data - in controller or in model ?
ps my guess is that User model had better deal with rest functionality, but working with components in model is a little but awkward in models in cakephp.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1.3 文档在使用库方面不太好。
但 2.0 的解释得很好:
http://book.cakephp.org/2.0/en /getting-started/cakephp-folder-struct.html
app/Lib
for 2.0 然后:
应用程序::uses('ClassName', 'Lib');
The 1.3 documenation is not so good on using libs.
But the 2.0 one explains it pretty good:
http://book.cakephp.org/2.0/en/getting-started/cakephp-folder-structure.html
app/Lib
for 2.0 then:
App::uses('ClassName', 'Lib');