0

I need to track the changes for an entity including oneToMany relations. I've tried Stof Extension Loggable, but I think it doesn't track changes to a linked entity, only deletions or additions.

For ex: if my entity Member can have several Address, and if my field adresses is versioned, the extension will tell me if an address has been removed or added, but it will not track a change in the address.

I thought SimpleThings/EntityAudit might do that, but it doesn't and it's not compatible yet with Symfony 3.

What would be the best way to implement such a system myself ? With Loggable extension, how could my entity Member be aware of changes that happened to an Address?

Roubi
  • 1,989
  • 1
  • 27
  • 36
  • 1
    Are you sure it's not compatible with Symfony3 yet? There was a closed pull request 2 days ago to do Symfony3 fixes. – Jason Roman Jan 22 '16 at 21:27
  • @JasonRoman Thanks for your answer. On packagist page, I couldn't find any version stating compatibility with Symfony ~3 version. I've installed the bundle's version dev-master anyway, but when emptying my cache, I get the error `the attribute factory-method is not allowed` in file *auditable.xml*. Upon research, it looks like this attribute cannot be used anymore with newer Symfony versions, so I thought it was a compatibility problem. – Roubi Jan 22 '16 at 21:38
  • Yeah it's likely that they still haven't worked out all of the kinks. I've done something like this before but it was rolling my own - listening for entity updates and pushing to a log file (or database table for logging). If that change isn't tracked for a linked entity though, can't you just do an individual log on that entity? Like do the `Loggable` extension on `Address` as well? – Jason Roman Jan 22 '16 at 21:56
  • @JasonRoman Thanks to your comment, I had a look at that particular request issue and made the changes stated there. The error is gone and I'm now giving it a try. As for you advice on making `Address` loggable too, that's what I did first but I have then to manage myself the coherence between my different entities and it quickly gets complicated, since my member entity is linked to seven others. – Roubi Jan 23 '16 at 02:58
  • This question should be asked on [Software Recommendations](http://softwarerecs.stackexchange.com/tour). – A.L Jan 23 '16 at 21:34
  • @A.L Please note that I also ask how I could do it without using any bundle. And Jason Romans provided interesting advices on the matter. So in the end it's also about how to use the mentioned bundles. No need to downvote my question... – Roubi Jan 24 '16 at 13:41
  • 1
    @Roubi as it's written, it's off-topic because it asks for an external ressource and too broad because there is many possible answers. Feel free to update the question if you can improve it. – A.L Jan 24 '16 at 13:54
  • @A.L Question edited! – Roubi Jan 24 '16 at 18:06
  • *the extension will tell me if an address has been removed or added* I tried *Loggable* last year and it logged changes in strings but not added or removed entities associated through Doctrine. Is it something new? – A.L Jan 25 '16 at 16:55
  • 1
    I found what I was thinking about: https://github.com/Atlantic18/DoctrineExtensions/issues/1199 `OneToMany` and `ManyToMany` associations are not loggable. – A.L Jan 25 '16 at 19:01
  • See also [Doctrine 2 - Log changes in manyToMany relation](http://stackoverflow.com/q/31871048/2257664). – A.L Jan 25 '16 at 19:07

0 Answers0