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

Class: IMediator

Source Location: /org/puremvc/php/multicore/interfaces/IMediator.php

Interface Overview

INotifier
   |
   --IMediator

The interface definition for a PureMVC Mediator.


Author(s):

Methods


Inherited Methods

Class: INotifier

INotifier::initializeNotifier()
Initialize this INotifier instance.
INotifier::sendNotification()
Send a INotification.

Class Details

[line 99]
The interface definition for a PureMVC Mediator.

In PureMVC, IMediator implementors assume these responsibilities:

  • Implement a common method which returns a list of all INotifications the IMediator has interest in.
  • Implement a notification callback method.
  • Implement methods that are called when the IMediator is registered or removed from the View.
Additionally, IMediators typically:

  • Act as an intermediary between one or more view components such as text boxes or list controls, maintaining references and coordinating their behavior.
  • This is often the place where event listeners are added to view components, and their handlers implemented.
  • Respond to and generate INotifications, interacting with of the rest of the PureMVC app.
When an IMediator is registered with the IView, the IView will call the IMediator's listNotificationInterests method. The IMediator will return an Array of INotification names which it wishes to be notified about.

The IView will then create an Observer object encapsulating that IMediator's (handleNotification) method and register it as an Observer for each INotification name returned by listNotificationInterests.

A concrete IMediator implementor usually looks something like this:

  1.  <?php
  2.  require_once 'org/puremvc/php/multicore/interfaces/IMediator.php';
  3.  require_once 'org/puremvc/php/multicore/patterns/mediator/Mediator.php';
  4.  
  5.  class MyMediator extends Mediator implements IMediator
  6.  {
  7.      const NAME 'MyMediator';
  8.  
  9.      public function __construct$mediatorName$viewComponent null )
  10.      {
  11.          parent::__constructMyMediator::NAME$viewComponent );
  12.      }
  13.  
  14.      public function listNotificationInterests()
  15.      {
  16.          return array'Hello''Bye' );
  17.      }
  18.  
  19.      public function handleNotificationINotification $notification )
  20.      {
  21.          switch$notification->getName() )
  22.          {
  23.              case 'hello':
  24.              case 'bye':
  25.                  $this->outputNotificationBody$notification );
  26.                  break;
  27.          }
  28.      }
  29.  
  30.      public function outputNotificationBody$note )
  31.      {
  32.          print $note->body;
  33.      }
  34.  }




Tags:

see:  INotification


[ Top ]


Class Methods


method getMediatorName [line 109]

string getMediatorName( )

Get Mediator Name

Get the IMediator instance name




Tags:

return:  The IMediator instance name.
access:  public


[ Top ]

method getViewComponent [line 118]

mixed getViewComponent( )

Get View Component

Get the IMediator's view component.




Tags:

return:  The view component
access:  public


[ Top ]

method handleNotification [line 147]

void handleNotification( INotification $notification)

Handle Notification

Handle an INotification.




Tags:

access:  public


Parameters:

INotification   $notification   The INotification to be handled.

[ Top ]

method listNotificationInterests [line 137]

array listNotificationInterests( )

List Notifications Interests.

List INotification interests.




Tags:

return:  An Array of the INotification names this IMediator has an interest in.
access:  public


[ Top ]

method onRegister [line 156]

void onRegister( )

onRegister event

Called by the View when the Mediator is registered.




Tags:

access:  public


[ Top ]

method onRemove [line 165]

void; onRemove( )

onRemove event

Called by the View when the Mediator is removed.




Tags:

access:  public


[ Top ]

method setViewComponent [line 128]

void setViewComponent( mixed $viewComponent)

Set View Component

Set the IMediator's view component.




Tags:

access:  public


Parameters:

mixed   $viewComponent   The view component.

[ Top ]


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