However, the call to the Process() method of the current pipeline section class (which receives a parameter
of the current OrderProcessor instance, thus having access to the $mContinueNow member) changes the
value of $mContinueNow back to true, in case processing should go to the next pipeline section without waiting
for user interaction.
Note that in the previous code snippet, the Process() method is called without knowing what kind of object
$this->_mCurrentPipelineSection references. Each pipeline section is represented by a different class,
but all these classes need to expose a method named Process(). When such behavior is needed, the standard
technique is to create an interface that defines the common behavior we need in that set of classes.
All order pipeline section classes support the simple IPipelineSection interface, defined as follows:
interface IPipelineSection
{
public function Process($processor);
}
?>
All pipeline sections use a Process() method to perform their work. This method requires an OrderProcessor
reference as a parameter because the pipeline sections need access to the public fields and methods exposed by
the OrderProcessor class.
CHAPTER 18 ?– IMPLEMENTING THE ORDER PIPELINE: PART 1 583
The last part of the Process() method in OrderProcessor involves catching exceptions. Here, we catch any
exceptions that may be thrown by the order pipeline section classes and react to them by sending an e-mail to the
administrator using the MailAdmin() method, adding an audit entry, and throwing a new exception that can be
caught by PHP pages that use the OrderProcessor class:
catch(Exception $e)
{
$this->MailAdmin('Order Processing error occurred.
Pages:
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701