Closed schmengler closed 7 years ago
This needs some performance considerations: Botman Conversation
uses SerializableClosure to serialize the callbacks and the conversation instance in the Botman cache. Closure callbacks are bound to the conversation instance on unserialization. The originally bound object is serialized too though.
If the conversation uses any Magento classes (like ProductRepository
in a ProductListAction
) this is going to be ugly.
Possible approaches:
__sleep
and in serialized objects to replace actions and triggers with fresh lazy loading objects (see also #3) - but serialization should not be the responsibility of each trigger/action implementation. So there should be a SerializableAction
and SerializableTrigger
, maybe as decorator that can recreate the objects using the factory classes and the serialized data.To unserialize the actions that need to access botman, Botman
should probably be instantiated via Magento object manager and kept as a shared instance.
And/or we extend Conversation->setBot()
which is called on unserialization and pass the bot to the objects that need it.
Relevant Botman issue: https://github.com/mpociot/botman/issues/195
Configure Botman conversations based on
ConversationDefinition
, let Botman control theConversation
instance