magento-hackathon / magebot

21 stars 2 forks source link

Implement Domain Logic for Conversations #3

Closed schmengler closed 7 years ago

schmengler commented 7 years ago

State machine definition / configuration:

State machine implementation:

schmengler commented 7 years ago

Instead of separating definitions and executable implementations, we'll create lazy loading versions of the objects that might be expensive to instantiate due to dependencies (actions, triggers). Lazy loading will be implemented via Magento Proxy or Factory:

final class LazyLoadingAction implements Action
{
    public function execute()
    {
        return $this->action()->execute();
    }
    private function action()
    {
        if (! $this->action) {
            $this->action = $this->factory->create($this->type, $this->parameters);
        }
    }
}