org-puremvc-php-multicore
[ class tree: org-puremvc-php-multicore ] [ index: org-puremvc-php-multicore ] [ all elements ]

Class: Controller

Source Location: /org/puremvc/php/multicore/core/Controller.php

Class Overview


A Multiton IController implementation.


Author(s):

Implements interfaces:

Variables

Constants

Methods



Class Details

[line 66]
A Multiton IController implementation.

In PureMVC, the Controller class follows the 'Command and Controller' strategy, and assumes these responsibilities:

  • Remembering which ICommands 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 Facade, and use its initializeController method to add your registrations.




Tags:

see:  View
see:  Observer
see:  Notification
see:  SimpleCommand
see:  MacroCommand


[ Top ]


Class Variables

static $instanceMap = array()

[line 96]

The Multiton instances stack



Tags:

access:  protected

Type:   array


[ Top ]

$commandMap =

[line 84]

Mapping of Notification names to Command Class references



Tags:

access:  protected

Type:   array


[ Top ]

$multitonKey =

[line 90]

The Multiton Key for this Core



Tags:

access:  protected

Type:   string


[ Top ]

$view =

[line 78]

The view instance for this Core



Tags:

access:  protected

Type:   IView


[ Top ]



Class Methods


static method getInstance [line 160]

static IController getInstance( string $key)

Controller Factory method.

This IController implementation is a Multiton so this method MUST be used to get acces, or create, IControllers.




Tags:

return:  The instance for this Multiton key.
access:  public


Parameters:

string   $key   Unique key for this instance.

[ Top ]

static method removeController [line 259]

static void removeController( string $key)

Remove controller

Remove an IController instance identified by it's key




Tags:

access:  public


Parameters:

string   $key   multitonKey of IController instance to remove

[ Top ]

constructor __construct [line 115]

IController __construct( string $key)

Instance constructor

This IController implementation is a Multiton, so you should not call the constructor directly, but instead call the static getInstance() Factory method, passing the unique key for this instance.

ex:

  1.  $myController MyController::getInstance'myMultitonKey' );




Tags:

return:  Instance for this key
throws:  Exception if instance for this key has already been constructed.
access:  protected


Parameters:

string   $key   Unique key for this instance.

[ Top ]

method executeCommand [line 179]

void executeCommand( INotification $notification)

Execute Command

Execute the ICommand previously registered as the handler for INotifications with the given notification name.




Tags:

access:  public



Implementation of:
IController::executeCommand()
Execute Command

Parameters:

INotification   $notification   The INotification to execute the associated Command for.

[ Top ]

method hasCommand [line 225]

bool hasCommand( string $notificationName)

Has Command

Check if a ICommand is registerCommand() registered for a given INotification




Tags:

return:  Whether a ICommand is currently registered for the given notificationName.
access:  public



Implementation of:
IController::hasCommand()
Has Command

Parameters:

string   $notificationName   Name of the INotification to check for.

[ Top ]

method initializeController [line 146]

void initializeController( )

Initialize the 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:

  1.  // ensure that the Controller is talking to my IView implementation
  2.  public function initializeController)
  3.  {
  4.      $this->view MyView::getInstance('myViewName');
  5.  }




Tags:

access:  protected


[ Top ]

method registerCommand [line 208]

void registerCommand( string $notificationName, string $commandClassRef)

Register Command

Register a particular ICommand class as the handler for a particular INotification.

If an ICommand has already been registered to handle INotifications with this name, it is no longer used, the new ICommand is used instead.

The IObserver for the new ICommand is only created if this the first time an ICommandhas been regisered for this INotification name.




Tags:

access:  public



Implementation of:
IController::registerCommand()
Register Command

Parameters:

string   $notificationName   Name of the INotification.
string   $commandClassRef   Class name of the ICommand implementation to register.

[ Top ]

method removeCommand [line 238]

void removeCommand( string $notificationName)

Remove Command

Remove a previously registerCommand() registered ICommand to INotification mapping.




Tags:

access:  public



Implementation of:
IController::removeCommand()
Remove Command

Parameters:

string   $notificationName   Name of the INotification to remove the ICommand mapping for.

[ Top ]


Class Constants

MULTITON_MSG =  "Controller instance for this Multiton key already constructed!"

[line 72]

Define the message content for the duplicate instance exception


[ Top ]



Documentation generated on Mon, 03 Aug 2009 04:57:51 +0000 by phpDocumentor 1.4.2