Example #1
0
 /**
  * Ejectua un callback definido por el usuario
  */
 public function invoke($name, $args = array())
 {
     // Probamos si el metodo se puede invocar
     // mediante la clase Reflection
     try {
         $method = new \ReflectionMethod(get_called_class(), $name);
         $method->setAccesible(true);
         return $method->invokeArgs($this, $args);
     } catch (\ReflectionException $eR) {
         if (isset($this->callbacks) && is_array($this->callbacks) && isset($this->callbacks[$name])) {
             try {
                 return call_user_func_array($this->callbacks[$name], $args);
             } catch (Exception\Stage $e) {
                 throw $e;
             } catch (\Exception $e) {
                 throw new Exception\Object("No se puede ejecutar el metodo:" . $name . print_r($this, true), 4);
             }
         } else {
             throw new Exception\Object('El metodo ' . $name . ' no pude ser invocado', 5);
         }
     } catch (Exception\Object $e) {
         throw new Exception\Object('El metodo ' . $name . ' no pude ser invocado', 6);
     } catch (\Exception $e) {
         throw new Exception\Object('No se puede invocar ' . $name, 7);
     }
 }