org::puremvc::perl5::core::Controller
Singleton responsible for executing commands in response to a notification.
In PureMVC, the Controller class follows the 'Command and Controller' strategy, and assumes these responsibilities:
Remembering which commands are intended to handle which notification.
Registering itself as an observer with the View for each notification that it has a command mapping for.
Creating a new instance of the proper command to handle a given notification when notified by the View.
Calling the command's execute method, passing in the notification.
Your application must register commands with the Controller.
The simplest way is to subclass Facade class, and use its initializeController method to add your registrations.
Returns the singleton instance of the Controller.
Returns
org::puremvc::perl5::core::Controller - The singleton instance of the Controller.
Initialize the singleton instance of the Controller.
This method is automatically called during singleton instantiation.
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:
# ensure that the Controller is talking to my View implementation sub initializeController { my $self = shift; $self->{_view} = com::me::myapp::MyView->getInstance() unless exists $self->{_view}; }
sub registerCommand( $notification_name, $command_class_ref );
Register a particular command class as the handler for a particular notification.
$command_class_ref is a string holding the name of the command class, e.g. "com::me::myapp::MyCommand".
If a command has already been registered to handle notification with this name, it is no longer used, the new command is used instead.
The observer for the new command is only created if this the first time a command has been registered for this notification name.
Parameters
$notification_name - String
Name of the notifications the registered Command will handle.
$command_class_ref - String
Class name of the Command to handle notification called $notification_name.
sub executeCommand( $notification );
If a command has previously been registered to handle a given notification, then it is executed.
Parameters
$notification - org::puremvc::perl5::patterns::observer::Notification
The notification to handle.
sub removeCommand( $notification_name );
Remove a previously registered command for a given notification name.
Parameters
$notification_name - String
Name of the notification for which to remove a registered command.
sub hasCommand( $notification_name );
Check whether a command is registered for a given notification name.
Parameters
$notification_name - String
Name of the notification for which to check a registered command.
Returns
scalar - 1 if a Command class is registered with the Controller for notifications named $notification_name, "" otherwise.
Array reference on registered commands with the Controller. You should not have to access it and must not update it in normal usage.
org::puremvc::perl5::core::Model
org::puremvc::perl5::core::View
org::puremvc::perl5::patterns::facade::Facade
org::puremvc::perl5::patterns::observer::Notification
org::puremvc::perl5::patterns::proxy::Proxy
org::puremvc::perl5::patterns::mediator::Mediator
org::puremvc::perl5::patterns::command::SimpleCommand
org::puremvc::perl5::patterns::command::MacroCommand