Serializing an entity immediately after creating it results in an error
Steps
- Create an entity (Any entity, doesn't matter which one, Address, Barcode, Contact,etc)
- pass it through json_encode.
Expected behavior: Returns a json encoded string of all the properties available in the entity
Actual behavior: Throws an exception
What exactly is currentService being used for? Currently I can only see it being set, and not being read anywhere except to throw the mentioned exception. getCurrentService() does not seems to be used.
And why must it be set if it's not used anywhere?
If it is absolutely necessary to have, can the check be moved elsewhere so it doesn't interfere with the simple process of serializing the entity's properties?
I believe it used to provide some serialization context for the SOAP API, equivalent to the context of a Symfony Serializer. It somehow ended up in the entity itself rather than on the serializer. Now that support for the SOAP API has been dropped it is no longer necessary, I think.
Do you think it can be removed in its entirety? It would be nice to get rid of legacy code like this.
In theory, as I don't see it being used anywhere, it should be possible to remove it entirely without affected anything else in the package. I of course don't know if there are any implementations that may use the currentService property.