PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1

CHAPTER 12 ■ ENTERPRISE PATTERNS


The strategies an application controller might use to acquire views and commands can vary
considerably; the key is that these are hidden away from the wider system. Figure 12–7 shows the high-
level process by which a front controller class uses an application controller to acquire first a Command
object and then a view.


Figure 12–7. Using an application controller to acquire commands and views


The Command Class


You may have noticed that the AppController class relies on previous commands having been stored in
the Request object. This is done by the Command base class:


namespace woo\command;
//....


abstract class Command {


private static $STATUS_STRINGS = array (
'CMD_DEFAULT'=>0,
'CMD_OK' => 1,
'CMD_ERROR' => 2,
'CMD_INSUFFICIENT_DATA' => 3

Free download pdf