TYPO3 Extbase: update record with logging of changes

烈酒焚心 提交于 2019-12-02 20:04:24

问题


When I update an object with an Extbase repository (e.g. in a cronjob or in the frontend) like this...

$myRepository->update($myObject);

and afterwards I use button "Display change history / Un-do" for this record in TYPO3 BE, I don't see any history. I only see a history when editing the object in TYPO3 BE.

How can I enable the history?


回答1:


Short version: you can't, because the history is for changes done in the backend interface only.

Longer version: you sort of, kind of can, but that would involve quite a bit of custom code in your repository which would do one of two things:

  1. Override the update method on your repository and from it, fire DataHandler methods to update the record - then use the persistence session to mark your object as clean so Extbase doesn't try to persist it again. Updates via DataHandler will write the history.
  2. Also override the update method but write the history records manually instead of allowing DataHandler to do it.

The first solution is very complex to handle. The second one means you have to implement a bit of (duplicated) code and likely won't cause all the usual hooks to trigger in TYPO3 (which is usually fine but does sometimes cause trouble with third party extensions). If you are forced to do this, I would choose the second solution. But I would first of all consider if perhaps the need to have BE-specific history for anonymous (no BE user) editing that's bordering on abuse of what that undo history was also intended for: tracing who made a change.



来源:https://stackoverflow.com/questions/52368578/typo3-extbase-update-record-with-logging-of-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!