/**
  * get the current bpm value from the notification, load our templates
  * and provide them w/ data they need.  as well, some of the data is
  * generated by us here.
  */
 public function handleNotification(INotification $oNote)
 {
     $this->iBpm = $oNote->getBody();
     /* set template values */
     $this->sBpmGraphic = $this->renderBpmGraphic();
     include 'layout.php';
 }
Example #2
0
 public function handleNotification(INotification $notification)
 {
     if (self::$isVerbose) {
         echo $notification->getName() . PHP_EOL;
     }
     return parent::handleNotification($notification);
 }
 public function execute(INotification $oNote)
 {
     require 'DjBpmMediator.php';
     require 'DjControlProxy.php';
     /* setup the view */
     $this->facade->registerMediator(new DjBpmMediator());
     /* setup the model*/
     $iAmount = $oNote->getBody();
     $sCommandType = $oNote->getType();
     $oDjControlProxy = new DjControlProxy();
     $this->facade->registerProxy($oDjControlProxy);
     switch ($sCommandType) {
         case '<<':
             $oDjControlProxy->decBpm();
             break;
         case '>>':
             $oDjControlProxy->incBpm();
             break;
         case 'set':
             $oDjControlProxy->setBpm($iAmount);
             break;
         default:
             break;
     }
     /* save our changes and the view automatically gets updated! */
     $oDjControlProxy->save();
     $this->oDjControlProxy = $oDjControlProxy;
 }
 public function execute(INotification $note)
 {
     if (!$note->getBody()) {
         $layoutMediator = $this->facade->retrieveMediator(LayoutMediator::NAME);
         $layoutMediator->alert('Add User Role', 'Role already exists for this user!');
     }
 }
 /**
  * Override execute to add logic.  In the <code>StartModelCommand</code>
  * the ApplicationDataProxy is started and registered, and then
  * the selected CSS file is loaded.
  */
 public function execute(INotification $notification)
 {
     $view = $notification->getBody();
     $cssFileName = $notification->getType();
     $applicationDataProxy = new ApplicationDataProxy();
     $this->facade->registerProxy($applicationDataProxy);
     $applicationDataProxy->loadCSS($cssFileName);
 }
 /**
  * Prints the view to the browser when the VIEW_DATA_READY
  * notification is sent.
  */
 private function _printDisplay(INotification $notification)
 {
     $viewData = $notification->getBody();
     $css = $viewData['css'];
     $template = $this->getApplicationView()->getViewTemplate();
     $output = str_replace("{css}", $css, $template);
     print $output;
 }
 public function execute(INotification $note)
 {
     $user = $note->getBody();
     $userProxy = $this->facade->retrieveProxy(UserProxy::NAME);
     $roleProxy = $this->facade->retrieveProxy(RoleProxy::NAME);
     $userProxy->deleteItem($user);
     $roleProxy->deleteItem($user);
     $this->sendNotification(AppFacade::USER_DELETED);
 }
 public function handleNotification(INotification $note)
 {
     switch ($note->getName()) {
         case AppFacade::NEW_USER:
             $this->userForm->setUser($note->getBody(), UserFormComponent::MODE_ADD);
             break;
         case AppFacade::USER_DELETED:
             $this->userForm->reset();
             break;
         case AppFacade::USER_SELECTED:
             $this->userForm->setUser($note->getBody(), UserFormComponent::MODE_EDIT);
             break;
     }
 }
 public function handleNotification(INotification $note)
 {
     switch ($note->getName()) {
         case AppFacade::NEW_USER:
             $this->clearForm();
             break;
         case AppFacade::USER_ADDED:
             $this->rolePanel->user = $note->getBody();
             $this->roleProxy->addItem(new RoleVO($this->rolePanel->user->username));
             $this->clearForm();
             break;
         case AppFacade::USER_UPDATED:
             $this->clearForm();
             break;
         case AppFacade::USER_DELETED:
             $this->clearForm();
             break;
         case AppFacade::CANCEL_SELECTED:
             $this->clearForm();
             break;
         case AppFacade::USER_SELECTED:
             $this->rolePanel->user = $note->getBody();
             $this->rolePanel->setUserRoles($this->roleProxy->getUserRoles($this->rolePanel->user->username));
             $this->rolePanel->reset();
             break;
         case AppFacade::ADD_ROLE_RESULT:
             $note->getBody() && $this->rolePanel->addUserRole($note->getType(), RoleEnum::getValue($note->getType()));
             $this->rolePanel->reset();
             break;
     }
 }
 /**
  * Handle Notification.
  * <P>
  * This provides the handling for common junction activities. It 
  * accepts input and output pipes in response to <code>IPipeAware</code>
  * interface calls.</P>
  * <P>
  * Override in subclass, and call <code>super.handleNotification</code>
  * if none of the subclass-specific notification names are matched.</P>
  * 
  * @param INotification $notification
  * @return void 
  */
 public function handleNotification(INotification $notification)
 {
     switch ($notification->getName()) {
         // accept an input pipe
         // register the pipe and if successful
         // set this mediator as its listener
         case JunctionMediator::ACCEPT_INPUT_PIPE:
             $inputPipeName = $notification->getType();
             $inputPipe = $notification->getBody();
             if ($this->junction > registerPipe($inputPipeName, Junction::INPUT, $inputPipe)) {
                 $this->junction->addPipeListener($inputPipeName, $this, 'handlePipeMessage');
             }
             break;
             // accept an output pipe
         // accept an output pipe
         case JunctionMediator::ACCEPT_OUTPUT_PIPE:
             $outputPipeName = $notification->getType();
             $outputPipe = $notification->getBody();
             $this->junction->registerPipe($outputPipeName, Junction::OUTPUT, $outputPipe);
             break;
     }
 }
 public function handleNotification(INotification $note)
 {
     switch ($note->getName()) {
         case AppFacade::CANCEL_SELECTED:
             $this->userList->deSelect();
             break;
         case AppFacade::USER_ADDED:
             $refID = $this->userProxy->getIndex($note->getBody());
             $this->userList->addUser($refID, $note->getBody());
             break;
         case AppFacade::USER_UPDATED:
             $refID = $this->userProxy->getIndex($note->getBody());
             $this->userList->updateUser($refID, $note->getBody());
             $this->userList->deSelect();
             break;
     }
 }
 /**
  * If an <code>ICommand</code> has previously been registered 
  * to handle a the given <code>INotification</code>, then it is executed.
  * 
  * @param note an <code>INotification</code>
  */
 public function executeCommand(INotification $note)
 {
     if (isset($this->commandMap[$note->getName()])) {
         $commandClassName = $this->commandMap[$note->getName()];
         $commandClassReflector = new ReflectionClass($commandClassName);
         $commandClassRef = $commandClassReflector->newInstance();
         $commandClassRef->execute($note);
     }
 }
 /**
  * A utility method to test the notification of Observers by the view
  *
  * @param INotification $note
  */
 public function viewTestMethod(INotification $note)
 {
     $this->viewTestVar = $note->getBody();
 }
 /**
  * A function that is used as the observer notification
  * method. It multiplies the input number by the 
  * observerTestVar value
  */
 public function observerTestMethod(INotification $note)
 {
     $this->observerTestVar = $note->getBody();
 }
 /**
  *
  * @param notification the <b>INotification</b> to be handled
  * @see IMediator::handleNotification()
  */
 public function handleNotification(INotification $notification)
 {
     $this->viewTest()->lastNotification = $notification->getName();
 }
Example #16
0
 /**
  * @param INotification $notification
  * @return null
  * @throws \InvalidArgumentException When the notification is not valid
  * @since 8.2.0
  */
 public function notify(INotification $notification)
 {
     if (!$notification->isValid()) {
         throw new \InvalidArgumentException('The given notification is invalid');
     }
     $apps = $this->getApps();
     foreach ($apps as $app) {
         try {
             $app->notify($notification);
         } catch (\InvalidArgumentException $e) {
         }
     }
 }
 /**
  * Handle notifications the <b>StateMachine</b> is interested in.
  * 
  * <b>StateMachine::ACTION</b>: Triggers the transition to a new state.<BR>
  * <b>StateMachine::CANCEL</b>: Cancels the transition if sent in response to the exiting note for the current state.<BR>
  * 
  * @param INotification $notification The <b>INotification</b> to be handled.
  * @return void
  */
 public function handleNotification(INotification $notification)
 {
     switch ($notification->getName()) {
         case StateMachine::ACTION:
             $action = $notification->getType();
             $target = $this->getCurrentState()->getTarget($action);
             $newState = $this->states[$target];
             if ($newState) {
                 $this->transitionTo($newState, $notification->getBody());
             }
             break;
         case StateMachine::CANCEL:
             $this->canceled = true;
             break;
     }
 }
 public function execute(INotification $notification)
 {
     echo $notification->getName();
 }
 /**
  * Fabricate a result by multiplying the input by 2
  *
  * @param INotification $note the Notification carrying the FacadeTestVO
  */
 public function execute(INotification $note)
 {
     $vo = $note->getBody();
     $vo->result2 = $vo->input * $vo->input;
 }
 /**
  * The <code>execute()</code> method is overridden in order
  * to add your application logic for this specific command.
  */
 public function execute(INotification $notification)
 {
     $view = $notification->getBody();
     $this->facade->registerMediator(new ApplicationMediator(new ApplicationView($view)));
 }
 /**
  * Notify the <code>IObservers</code> for a particular <code>INotification</code>.
  * 
  * <P>
  * All previously attached <code>IObservers</code> for this <code>INotification</code>'s
  * list are notified and are passed a reference to the <code>INotification</code> in 
  * the order in which they were registered.</P>
  * 
  * @param notification the <code>INotification</code> to notify <code>IObservers</code> of.
  */
 public function notifyObservers(INotification $notification)
 {
     if (isset($this->observerMap[$notification->getName()])) {
         // Copy observers from reference array to working array,
         // since the reference array may change during the notification loop
         $observers = $this->observerMap[$notification->getName()];
         foreach ($observers as $observer) {
             $observer->notifyObserver($notification);
         }
     }
 }
 /**
  * Notify Observers
  *
  * Notify the <b>IObservers</b> for a particular <b>INotification</b>.
  *
  * All previously attached <b>IObservers</b> for this <b>INotification</b>'s
  * list are notified and are passed a reference to the <b>INotification</b> in
  * the order in which they were registered.
  *
  * @param INotification $notification The <b>INotification</b> to notify <b>IObservers</b> of.
  * @return void
  */
 public function notifyObservers(INotification $notification)
 {
     if (isset($this->observerMap[$notification->getName()])) {
         // Get a reference to the observers list for this notification name
         $observers_ref = $this->observerMap[$notification->getName()];
         // Copy observers from reference array to working array,
         // since the reference array may change during the notification loop
         $observers = array();
         foreach ($observers_ref as $observer) {
             array_push($observers, $observer);
         }
         // Notify Observers from the working array
         foreach ($observers as $observer) {
             $observer->notifyObserver($notification);
         }
     }
 }
 public function notifyObservers(INotification $notification)
 {
     if ($this->observerMap[$notification->getName()] != null) {
         $observers = $this->observerMap[$notification->getName()];
         foreach ($observers as $observer) {
             $observer->notifyObserver($notification);
         }
     }
 }
 /**
  * Execute Command
  *
  * Execute the <b>ICommand</b> previously registered as the
  * handler for <b>INotification</b>s with the given notification name.
  *
  * @param INotification $notification The <b>INotification</b> to execute the associated <b>Command</b> for.
  * @return void
  */
 public function executeCommand(INotification $notification)
 {
     // if the Command is registered...
     if ($this->hasCommand($notification->getName())) {
         $commandClassName = $this->commandMap[$notification->getName()];
         $commandClassRef = new $commandClassName();
         $commandClassRef->initializeNotifier($this->multitonKey);
         $commandClassRef->execute($notification);
     }
 }