design an extendible and pluggable business logic flow handler in php
- by Broncha
I am working on a project where I need to allow a pluggable way to inject business processes in the normal data flow.
eg
There is an ordering system. The standard flow of the application is
A consumer orders an item.
Pays for it and card is authorized.
Admin captures the payment.
Order is marked as complete and item is shipped.
But this process may vary (extra steps in between) for different clients. Say a client would need to validate the location of the consumer before he is presented with a credit card form, OR his policies might require some other processes in between.
I am thinking of using State Pattern for processing orders, saving the current state of the order in database, and initializing the state of order from the saved state.
I would also need some mechanism, where a small plugin would be able to inject business specific states in the state machine. Am I thinking the right way? Are there already implemented patterns for this kind of situation?
I am working with Codeigniter and basically this would mean for me, to redirect to proper controller according to the current state of the order. Like, if the state of the order is unconfirmed then redirect the user to details page and then change the state to pending. If some client would need to do some validation, then register an intermediate state between unconfirmed and pending
Please suggest.