Is doing Transaction Management in the Controller bad practice?

前端 未结 4 1882
情深已故
情深已故 2021-01-31 19:00

I\'m working on a PHP/MySQL app using the Yii framework.

I\'ve come across the following situation:

In my VideoController, I have a actionCrea

4条回答
  •  没有蜡笔的小新
    2021-01-31 19:46

    No you are right. The transaction is delegated by the "create" method which is what a controller is supposed to do. Your suggestion of using a 'wrapper' like beforeAction() is the way to go. Just make the controller extend or implement this class. It looks like you are looking for an Observer type pattern or a factory-like implementation.

提交回复
热议问题