org.puremvc.php.patterns.command

# Class: MacroCommand Source Location: /patterns/command/MacroCommand.php
### Class Overview
    Notifier
       |
       ..MacroCommand
A base ICommand implementation that executes other ICommand s. #### Author(s): Implements interfaces: ICommand INotifier | ### Methods __construct addSubCommand execute initializeMacroCommand
### Child classes: StartApplicationCommand The StartApplicationCommand prepares the view first so that it is ready to display data when the model is done loading. | ### Inherited Variables #### Class: Notifier Notifier::$facade | ### Inherited Methods #### Class: Notifier Notifier::__construct() Notifier::sendNotification()
### Class Details [line 46] A base ICommand implementation that executes other ICommand s. A MacroCommand maintains an list of ICommand Class references called SubCommands. When execute is called, the MacroCommand instantiates and calls execute on each of its SubCommands turn. Each SubCommand will be passed a reference to the original INotification that was passed to the MacroCommand 's execute method. Unlike SimpleCommand , your subclass should not override execute , but instead, should override the initializeMacroCommand method, calling addSubCommand once for each SubCommand to be executed. #### Tags:
see: | org.puremvc.patterns.command.SimpleCommand SimpleCommand
see: | org.puremvc.patterns.observer.Notification Notification
see: | org.puremvc.core.controller.Controller Controller
[ Top ] ### Class Methods ### constructor __construct [line 62]
`MacroCommand __construct( )`
Constructor. You should not need to define a constructor, instead, override the initializeMacroCommand method. If your subclass does define a constructor, be sure to call super() . #### Tags:
access: | public
Overrides Notifier::__construct() (parent method not documented) [ Top ] ### method addSubCommand [line 104]
`void addSubCommand( commandClassRef $commandClassRef)`
Add a SubCommand. The SubCommands will be called in First In/First Out (FIFO) order. #### Tags:
access: | protected
#### Parameters:
commandClassRef | $commandClassRef | a reference to the Class of the ICommand .
[ Top ] ### method execute [line 118]
`void execute( $notification)`
Execute this MacroCommand 's SubCommands. The SubCommands will be called in First In/First Out (FIFO) order. #### Tags:
access: | public
#### Parameters:
notification | $notification | the INotification object to be passsed to each SubCommand.
[ Top ] ### method initializeMacroCommand [line 91]
`void initializeMacroCommand( )`
Initialize the MacroCommand . In your subclass, override this method to initialize the MacroCommand 's SubCommand list with ICommand class references like this: <listing> // Initialize MyMacroCommand override protected function initializeMacroCommand( ) : void { addSubCommand( com.me.myapp.controller.FirstCommand ); addSubCommand( com.me.myapp.controller.SecondCommand ); addSubCommand( com.me.myapp.controller.ThirdCommand ); } </listing> Note that SubCommands may be any ICommand implementor, MacroCommand s or SimpleCommands are both acceptable. #### Tags:
access: | protected
Overridden in child classes as: StartApplicationCommand::initializeMacroCommand() The initializeMacroCommand is overridden to add references to instances of SimpleCommand that should be executed. [ Top ] Documentation generated on Tue, 30 Sep 2008 08:05:45 -0700 by phpDocumentor 1.4.0