Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
MenuItem (tree) is not serializable #309
I want the menu to be serializable, because we use a large menu (200+ items) and we want to cache the result.
When serializing the menuItem (including children) an exception will thrown:
This is due to the injected ItemFactory.
solution will be to implement Serializable interface on the menuItem and reinject the factory on deserialization
We cannot reinject the factory when using the PHP serialization API, as there is no way to hook in it externally (and we don't want to make the factory available in a global variable to be able to retrieve it from inside the unserialized MenuItem). So we cannot implement Serializable in a usable way.
My suggestion would be to use a more powerful serializer for that (one that allows hooking from the outside), like symfony/serializer or jms/serializer (and both of them would allow you to use the library without modifying it btw).