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.
See also: View org.puremvc.php.multicore.core.View.php
Inheritance: extends Notifier, implements IMediator, implements INotifier
 /**
  * Tests getting the name using Mediator class accessor method.
  */
 public function testViewAccessor()
 {
     // Create a view object
     $view = new stdClass();
     // Create a new Mediator and use accessors to set the mediator name
     $mediator = new Mediator(Mediator::NAME, $view);
     // test assertions
     $this->assertNotNull($mediator->getViewComponent(), "Expecting mediator.getViewComponent() not null");
 }
Ejemplo n.º 2
0
 public function handleNotification(INotification $notification)
 {
     if (self::$isVerbose) {
         echo $notification->getName() . PHP_EOL;
     }
     return parent::handleNotification($notification);
 }
 /**
  * Constructor
  */
 public function __construct($mediatorName, $viewComponent = null)
 {
     parent::__construct(ViewTestMediator::NAME, $viewComponent);
 }
 public function __construct(UserFormComponent $userForm)
 {
     parent::__construct(self::NAME, $userForm);
     $this->userForm = $userForm;
 }
 public function __construct(UserListComponent $userList)
 {
     parent::__construct(self::NAME, $userList);
     $this->userList = $userList;
 }
 /**
  * Constructor
  */
 public function __construct($view)
 {
     parent::__construct(ApplicationMediator::NAME, $view);
 }
 /**
  * Constructor
  */
 public function __construct($mediatorName, $viewComponent = null)
 {
     parent::__construct($mediatorName, $viewComponent);
 }
 public function __construct(LayoutComponent $layout)
 {
     parent::__construct(self::NAME, $layout);
     $this->layout = $layout;
 }
Ejemplo n.º 9
0
    }
    // displaySessions() handled in tutor interface.
    public function displaySiteSessions()
    {
        $this->specializedInteractor->displaySiteSessions();
    }
}
// $_POST["username"] = "******";
// $_POST["password"] = "******";
// $_GET['sessionID'] = 6;
// $_GET['function'] = 'cancelSession';
// $_GET['recipient'] = 'ben';
// $_GET['subject'] = 'test message';
// $_GET['content'] = 'i hope to god this works ben';
// $_GET['jsonString'] = '{"recipient":"ben","subject":"json test","message":"JSON TEST DURRRRR"}';
$med = new Mediator();
// $med->displayAllSessions();
// $_GET['site'] = "John Hay HS";
// $_GET['date'] = "12-01-2015";
// $_GET['time'] = "8:30PM";
// $_GET['subject'] = "programming";
// $_GET['gradeLevel'] = "12";
if (isset($_GET['function'])) {
    $function = $_GET['function'];
    /* Mediator functions: */
    if ($function == 'displayAllSessions') {
        $med->displayAllSessions();
    } elseif ($function == 'logout') {
        $med->getUser()->logout();
    } elseif ($function == 'getJsonMessages') {
        $med->getJsonMessages();
 /**
  * Constructor.
  * 
  * @param string $name
  * @param Junction $viewComponent
  * @return JunctionMediator
  */
 public function __construct($name, Junction $viewComponent)
 {
     parent::__construct($name, $viewComponent);
 }
 /**
  * Constructor.
  * 
  * @return StateMachine
  */
 public function __construct()
 {
     parent::__construct(StateMachine::NAME);
 }
 /**
  * @param string $eventName
  *
  * @return ContainerMediatorInterface Fluent Interface
  * @throws \InvalidArgumentException
  */
 private function sortServiceListeners(string $eventName) : ContainerMediatorInterface
 {
     if (0 === count($this->serviceListeners)) {
         return $this;
     }
     if ('' !== $eventName) {
         if (!array_key_exists($eventName, $this->serviceListeners)) {
             return $this;
         }
         $eventNames = [$eventName];
     } else {
         ksort($this->serviceListeners);
         $eventNames = array_keys(parent::getListeners(''));
     }
     foreach ($eventNames as $anEvent) {
         krsort($this->serviceListeners[$anEvent], SORT_NUMERIC);
     }
     return $this;
 }
 public function __construct(RolePanelComponent $rolePanel)
 {
     parent::__construct(self::NAME, $rolePanel);
     $this->rolePanel = $rolePanel;
 }