bedezign / yii2-audit

Yii2 Audit records and displays web/cli requests, database changes, php/js errors and associated data.
https://bedezign.github.io/yii2-audit/
Other
193 stars 112 forks source link

Discussion: should we move the model saving methods into the panel? #110

Open cornernote opened 9 years ago

cornernote commented 9 years ago

Things like AuditError::log() and AuditMail::record() may be better suited as protected methods in the panel classes, making our models very slim, and keeping all the panel logic in one place.

I think the change is minor (but haven't fully investigated yet). What are your thoughts?

Blizzke commented 9 years ago

I guess in the case of the error it doesnt really matter either way, since the model is bound directly to the panel anyway. It is a bit cleaner though, since the general idea is that the panels collect the data. In the same way it has annoyed me a bit that the audit_data records get saved by the AuditEntry model, those do not belong there either.

cornernote commented 9 years ago

In the same way it has annoyed me a bit that the audit_data records get saved by the AuditEntry model, those do not belong there either.

Could that be moved to a utility function?

Blizzke commented 9 years ago

Technically those should just be in the AuditData-model. But if we are making the models slimmer in favor of more intelligence in the Panels... Problem is obviously that that save would be called only once for all Panels.

cornernote commented 9 years ago

I did Mail and Error panels, but when I tried to move the methods from AuditEntry to AuditData I was getting an error on the AuditEntryTest and I don't understand why. You might have to take a look at it.