Marcus
Well-known member
From what I see it is very convenient to extend the class for _postsave() as I have access to all objects (and $this) there. I could somehow emulate a code event listener by calling the parent class first and then execute my own things. What is the advantage of using the code event listener? There are some good guidelines from xf team how to program as like here, so it seems the most unobtrusive way to add something in _postSave() would be to extend it, and not listen to the code event.
https://xf2demo.xenforo.com/threads/how-to-use-the-thread-creator-to-create-a-thread.2002/ There are some hidden gems in the xfdemo forum as like @ChrisD one post further down the same discussion advised to always use the entity when you already have the key.Mike said:(...) In this particular example, not using the service would generally be considered wrong. The service is what's responsible for dealing with things like quote and mention alerts and notification. These are not things that should be handled in entities; in general, entities deal more with data validation and other things that technically need to happen for a working system. Sending an alert doesn't fit in that and thus would normally be a level above that. (...)
Last edited: