예제 #1
0
 function testThrowCallbackException()
 {
     try {
         // this should raise an error
         Raxan::throwCallbackException('back_callback');
         $ok = true;
     } catch (Exception $e) {
         $ok = false;
     }
     $this->okFalse($ok, 'Callback Error');
 }
예제 #2
0
파일: raxan.php 프로젝트: enriqueism/raxan
 /**
  * Triggers an event on the object
  * @param string $type Event type
  * @param mixed $args Optional event argument
  * @return RaxanBase
  */
 public function trigger($type, $args = null)
 {
     $events =& $this->events;
     $id = $this->objId . $type;
     $hnds = isset($events[$id]) ? $events[$id] : null;
     if ($hnds) {
         $e = new RaxanSysEvent($type);
         foreach ($hnds as $hnd) {
             $fn = $hnd[0];
             $data = $hnd[1];
             if (!is_callable($fn)) {
                 Raxan::throwCallbackException($hnd);
             } else {
                 $e->data = $data;
                 if (is_string($fn)) {
                     $rt = $fn($e, $args);
                 } else {
                     $rt = $fn[0]->{$fn[1]}($e, $args);
                 }
                 // object callback
                 if ($rt !== null) {
                     $e->result = $rt;
                 }
                 if (!$e->isStopPropagation) {
                     break;
                 }
             }
         }
     }
     return $this;
 }
예제 #3
0
 /**
  * Adds a custom method to the RaxanElement Class. Use addMethod($object) to add multiple methods from an object
  */
 public static function addMethod($name, $callback = null)
 {
     if (!self::$callMethods) {
         self::$callMethods = array();
     }
     if ($callback === null && is_object($name)) {
         // add methods from an object
         $obj = $name;
         $names = get_class_methods($obj);
         foreach ($names as $name) {
             if ($name[0] != '_') {
                 self::$callMethods[$name] = array($obj, $name);
             }
         }
         // don't add names that begins with '_'
     } else {
         if (!is_callable($callback)) {
             Raxan::throwCallbackException($callback);
         }
         self::$callMethods[$name] = $callback;
     }
 }