douqin7086 2015-12-14 00:00
浏览 55

在Laravel中使用存储库刷新()Doctrine2的位置

I'm trying to figure out how to implement a good separation of concerns in a Laravel application. I'm planning to use Repository pattern with concrete repositories implemented using Doctrine2. Now the question is actually simple. Where should I do a EntityManager::flush()?

As I read on several articles, I should not put an updateModel operation to modify my objects since I would end up writing business logic in my repositories.

Now, if I only have operations related to persistence and search (find, all, add, remove) in my repositories, where would I do a flush when modifying a persisted object? If I do it in my service classes or in my controller (wherever I'm consuming a repository from) I will be coupling my business logic to Doctrine and that's what I'm trying to avoid. I thought a good option may be to put it somewhere at the end of the request, but this answer says it's not a good idea.

Any advice?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 求会做山景bo1048b2程序的 直播声卡用
    • ¥15 51单片机与数码管实现电子琴
    • ¥15 h3.6m 人类行为预测论文复现
    • ¥50 wordpress项目注册报失败刷新后其实是成功状态,请求排查原因
    • ¥20 linxu服务器僵尸进程不释放,代码如何修改?
    • ¥15 pycharm激活不成功
    • ¥40 如果update 一个列名为参数的value
    • ¥15 基于51单片机的水位检测系统设计中LCD1602一直不显示
    • ¥15 OCS2安装出现问题,请大家给点意见
    • ¥15 ros小车启动launch文件报错