コード例 #1
0
 /**
  * Handle the answer provided by the user and execute the relative action
  *
  * @param AbstractEventNotification $event
  */
 public function handleAnswer(AbstractEventNotification $event)
 {
     if ($event->getAnswer() === null || !is_string($event->getAnswer())) {
         throw new EyeInvalidArgumentException('Missing or invalid answer property');
     }
     switch ($event->getAnswer()) {
         case 'Confirm':
             try {
                 $eventData = $event->getEventData();
                 $assignation = UMManager::getInstance()->getNewUserWorkgroupAssignationInstance();
                 $assignation->setUserId($eventData['userId']);
                 $assignation->setWorkgroupId($eventData['groupId']);
                 $assignation->setRole(WorkgroupConstants::ROLE_VIEWER);
                 $assignation->setStatus(WorkgroupConstants::STATUS_MEMBER);
                 UMManager::getInstance()->updateUserWorkgroupAssignation($assignation);
             } catch (Exception $e) {
                 //FIXME Need real control of error
             }
             break;
         case 'Cancel':
             try {
                 $eventData = $event->getEventData();
                 $assignation = UMManager::getInstance()->getNewUserWorkgroupAssignationInstance();
                 $assignation->setUserId($eventData['userId']);
                 $assignation->setWorkgroupId($eventData['groupId']);
                 UMManager::getInstance()->unregisterUserWorkgroupAssignation($assignation);
             } catch (Exception $e) {
                 //FIXME Need real control of error
             }
             break;
         default:
             throw new EyeInvalidArgumentException('The answer to this events is not correct');
     }
 }
コード例 #2
0
 /**
  * Execute the action relative an event with the answer provided by the user
  *
  * @param map $params => array {
  *		'id' => String
  *		'answer' => String
  * }
  */
 public function handleAnswer(AbstractEventNotification $event)
 {
     if ($event->getType() === null) {
         throw new EyeInvalidArgumentException('Missing or invalid type property');
     }
     if ($event->getAnswer() === null) {
         throw new EyeInvalidArgumentException('Missing or invalid answer property');
     }
     list($category, $type) = explode('_', $event->getType(), 2);
     $eventHanlderClass = $type . 'Event';
     $eventHandler = new $eventHanlderClass();
     $eventHandler->handleAnswer($event);
 }
コード例 #3
0
 /**
  * Handle the answer provided by the user and execute the relative action
  *
  * @param AbstractEventNotification $event
  */
 public function handleAnswer(AbstractEventNotification $event)
 {
     if ($event->getAnswer() === null || !is_string($event->getAnswer())) {
         throw new EyeInvalidArgumentException('Missing or invalid answer property');
     }
     $peopleController = PeopleController::getInstance();
     switch ($event->getAnswer()) {
         case 'Confirm':
             try {
                 //Action for add the contact
                 $myProcManager = ProcManager::getInstance();
                 $currentUser = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser();
                 $peopleController = PeopleController::getInstance();
                 $peopleController->confirmContact($currentUser, $user = UMManager::getInstance()->getUserById($event->getSender()));
                 //Send message to the BUS
                 $message = new ClientBusMessage('events', 'confirmContact', $event->getSender());
                 ClientMessageBusController::getInstance()->queueMessage($message);
             } catch (Exception $e) {
                 //FIXME There should be real control on exception
             }
             break;
         case 'Cancel':
             try {
                 //Action for delete the contact
                 $contact = $peopleController->getContact($event->getReceiver(), $event->getSender());
                 $peopleController->removeContact($contact);
                 //Send message to the bus
                 $message = new ClientBusMessage('events', 'deleteContact', $event->getSender());
                 ClientMessageBusController::getInstance()->queueMessage($message);
             } catch (Exception $e) {
                 //FIXME There should be real control on exception
             }
             break;
         default:
             throw new EyeInvalidArgumentException('The answer to this events is not correct');
     }
 }