Every entity in Symfony has a property $id
and getters and setters for it, but I actually can't understand why do we need to have the setId method because we almost never call it directly.
I could think only one suggestion for using a setId()
method. It's a situation when we need to replace data for one entity by another saving the id of the replaced entity, but I'm not sure if it isn't the degenerate case.
Could somebody explain to me the reasons why we should have this method in entities classes?