Beispiel #1
0
 public static function receiveException(Event\Bucket $bucket)
 {
     // Early draft.
     self::$_message = $bucket->getData()->raise();
     return;
 }
Beispiel #2
0
 public function case_set_data()
 {
     $this->given($bucket = new SUT(), $datumA = 'foo')->when($result = $bucket->setData($datumA))->then->variable($result)->isNull()->string($bucket->getData())->isEqualTo($datumA)->given($datumB = 'bar')->when($result = $bucket->setData($datumB))->then->string($result)->isEqualTo($datumA)->string($bucket->getData())->isEqualTo($datumB);
 }
Beispiel #3
0
 /**
  * Fire an event
  *
  * @param string                $event
  * @param Hoa\Event\Bucket $bucket
  * @param mixed                 $additionnalData
  * @param boolean               $log
  *
  * @return void
  */
 public function onEvent($event, Bucket $bucket, $additionnalData = null, $log = true)
 {
     $callables = $this->getEventCallables($event);
     if ($log) {
         $rawData = $bucket->getData();
         $this->getLogger()->log('%s - %s (%d) > %s + %s', $bucket->getSource()->getConnection()->getCurrentNode()->getId(), $event, count($callables), json_encode($rawData, JSON_PRETTY_PRINT), json_encode($additionnalData, JSON_PRETTY_PRINT));
     }
     if ($this->hasEvent($event)) {
         foreach ($callables as $callable) {
             list($module, $method) = $callable;
             if ($this->launchModuleAction($event, $module, $method, $bucket, $additionnalData) === false) {
                 break;
             }
         }
     }
 }
Beispiel #4
0
 /**
  * onQuery callback
  *
  * @param \Hoa\Event\Bucket $bucket
  * @return false|string
  */
 function onQueryCallback(\Hoa\Event\Bucket $bucket)
 {
     $data = $bucket->getData();
     return $this->resolve($data['type'], $this->stripTld($data['domain']));
 }
Beispiel #5
0
 /**
  * Notify, i.e. send data to observers.
  *
  * @param   string             $eventId    Event ID.
  * @param   \Hoa\Event\Source  $source     Source.
  * @param   \Hoa\Event\Bucket  $data       Data.
  * @return  void
  * @throws  \Hoa\Event\Exception
  */
 public static function notify($eventId, Source $source, Bucket $data)
 {
     if (false === self::eventExists($eventId)) {
         throw new Exception('Event ID %s does not exist, cannot send notification.', 3, $eventId);
     }
     $data->setSource($source);
     $event = self::getEvent($eventId);
     foreach ($event->_callable as $callable) {
         $callable($data);
     }
     return;
 }