org.puremvc.php.core

# Class: Controller Source Location: /core/Controller.php
### Class Overview
A Singleton IController implementation. #### Author(s): Implements interfaces: IController | ### Variables $commandMap $instance $view | ### Methods executeCommand getInstance hasCommand initializeController registerCommand removeCommand
### Class Details [line 54] A Singleton IController implementation. In PureMVC, the Controller class follows the 'Command and Controller' strategy, and assumes these responsibilities: Remembering which ICommand s are intended to handle which INotifications . Registering itself as an IObserver with the View for each INotification that it has an ICommand mapping for. Creating a new instance of the proper ICommand to handle a given INotification when notified by the View . Calling the ICommand 's execute method, passing in the INotification . Your application must register ICommands with the Controller. The simplest way is to subclass </code>Facade</code>, and use its initializeController method to add your registrations. #### Tags:
see: | org.puremvc.php.patterns.command.MacroCommand MacroCommand
see: | org.puremvc.php.patterns.command.SimpleCommand SimpleCommand
see: | org.puremvc.php.patterns.observer.Notification Notification
see: | org.puremvc.php.patterns.observer.Observer Observer
see: | org.puremvc.core.View View
[ Top ] ### Class Variables #### static $instance = [line 64] #### Tags:
access: | protected
Type: | mixed
[ Top ] #### $commandMap = [line 61] #### Tags:
access: | protected
Type: | mixed
[ Top ] #### $view = [line 58] #### Tags:
access: | protected
Type: | mixed
[ Top ] ### Class Methods ### static method getInstance [line 114]
`static the getInstance( )`
Controller Singleton Factory method. #### Tags:
return: | Singleton instance of Controller
access: | public
[ Top ] ### method executeCommand [line 126]
`void executeCommand( $note)`
If an ICommand has previously been registered to handle a the given INotification , then it is executed. #### Tags:
access: | public
#### Parameters:
note | $note | an INotification
[ Top ] ### method hasCommand [line 155]
`whether hasCommand( string $notificationName)`
Check if a Command is registered for a given Notification #### Tags:
return: | a Command is currently registered for the given notificationName .
access: | public
#### Parameters:
string | $notificationName |
[ Top ] ### method initializeController [line 104]
`void initializeController( )`
Initialize the Singleton Controller instance. Called automatically by the constructor. Note that if you are using a subclass of View in your application, you should also subclass Controller and override the initializeController method in the following way: <listing> // ensure that the Controller is talking to my IView implementation override public function initializeController( ) : void { view = MyView.getInstance(); } </listing> #### Tags:
access: | protected
[ Top ] ### method registerCommand [line 144]
`void registerCommand( notificationName $notificationName, commandClassRef $commandClassRef)`
Register a particular ICommand class as the handler for a particular INotification . If an ICommand has already been registered to handle INotification s with this name, it is no longer used, the new ICommand is used instead. #### Tags:
access: | public
#### Parameters:
notificationName | $notificationName | the name of the INotification
commandClassRef | $commandClassRef | the Class of the ICommand
[ Top ] ### method removeCommand [line 165]
`void removeCommand( notificationName $notificationName)`
Remove a previously registered ICommand to INotification mapping. #### Tags:
access: | public
#### Parameters:
notificationName | $notificationName | the name of the INotification to remove the ICommand mapping for
[ Top ] Documentation generated on Tue, 30 Sep 2008 08:05:43 -0700 by phpDocumentor 1.4.0