6. OrderProcessor terminates.
If anything goes wrong at any point in the pipeline processing, such as a credit card being
declined, an e-mail is sent to an administrator. The administrator then has all the information
necessary to check what has happened, get in contact with the customer involved, and cancel
or replace the order if necessary.
No point in this process is particularly complicated; it??™s just that a lot of code is required
to put this into action!
Laying the Groundwork
Before we start building the components just described, we need to make a few modifications
to the TShirtShop database and web application.
During order processing, one of the most important functions of the pipeline is to maintain
an up-to-date audit trail. The implementation of this audit trail involves adding records
to a new database table called audit. We??™ll add the audit table in the following exercise.
To implement the functionality just described, we??™ll also need to add a new function named
orders_create_audit to the tshirtshop database. The orders_create_audit stored procedure
adds an entry to the audit table.
We??™ll also create the OrderProcessor class (the class responsible for moving an order
through the pipeline), which contains a lot of code. However, we can start simply and build up
additional functionality as needed. To start with, we??™ll create a version of the OrderProcessor
class with the following functionality:
??? Dynamically selects a pipeline section supporting the IPipelineSection interface
??? Adds basic auditing data
??? Gives access to the current order details
??? Gives access to the customer for the current order
??? Gives access to the administrator mailing
??? Mails the administrator in case of error
CHAPTER 18 ?– IMPLEMENTING THE ORDER PIPELINE: PART 1 574
INTERFACES IN PHP
This is the first time in this book where we??™re working with interfaces.
Pages:
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691