Is there some easy way how to create an event on doctrine entity? I would like to do some changes before entity is finaly saved into DB. For example i have entity with priority column and if i'm creating new record i need to get highest priority and set i into this new one.

Hi, if you have logic like this, you might wanna consider creating a new service, and only this specific service would be used to save this specific entity. And then in some save method, you would generate the field value, ideally in transaction.

But yes, there are for example EntityListeners.

So the service is better than some event? Because i already have a service which is saving this entity.

I wouldn't say that services are better than events. I would say that service is probably better than event in this case.


You must first log in to participate in this discussion