Retrieve published/unpublished objects state on preSave



in my case there are encapsulated shop categories which never should be published while one of their (grand)parent is unpublished. So I want to unpublish all child objects recursive when a parent object is unpublished. Therefor I played around with a “preSave” function and try to find the state of the changed object. I’ve recognized the getLatestVersion and getVersions but they don’t respond like expected.

For example:
I have a published Object and unpublish it without any further changes, “getLatestVersion” will return null, “getVersions” will repond a array of versions (as expected).
I have a unpublished Object and publish it without any further changes, getLatestVersion will return the object, getVersions will repond a array of versions (both as expected).

1.) Is there any easy way of getting the new/changed published-state of an object effectively or do I have to combine all given parameters (getLastVersion is null AND getVersionsCount > 0 AND …)?

2.) Also I recognized the “task” parameter which would be great, but I’m not able to retrieve it’s value? ($event->getArguments()) Is it possible to get it?

3.) Additionally I don’t find the different versions of a object in the database. Where are they stored?

Thanks and greetings :slight_smile:


Anyone? Ideas? Hints?