Ejemplo n.º 1
0
 /**
  * implements Sabel_Aspect_MethodInterceptor
  */
 public function invoke(Sabel_Aspect_MethodInvocation $i)
 {
     $result = $this->interceptor->before($i->getMethod(), $i->getArguments(), $i->getThis());
     if ($result !== null) {
         return $result;
     } else {
         return $i->proceed();
     }
 }
Ejemplo n.º 2
0
 /**
  * implements Sabel_Aspect_MethodInterceptor
  */
 public function invoke(Sabel_Aspect_MethodInvocation $i)
 {
     try {
         return $i->proceed();
     } catch (Exception $e) {
         $result = $this->interceptor->throws($i->getMethod(), $i->getArguments(), $i->getThis(), $e);
         if ($result !== null) {
             return $result;
         } else {
             throw $e;
         }
     }
 }
Ejemplo n.º 3
0
 public function invoke(Sabel_Aspect_MethodInvocation $inv)
 {
     Sabel_Db_Transaction::activate();
     try {
         $result = $inv->proceed();
         Sabel_Db_Transaction::commit();
         return $result;
     } catch (Exception $e) {
         Sabel_Db_Transaction::rollback();
         l($e->getMessage(), SBL_LOG_ERR);
         throw $e;
     }
 }
Ejemplo n.º 4
0
 public function invoke(Sabel_Aspect_MethodInvocation $inv)
 {
     try {
         $result = $inv->proceed();
         $method = str_replace("_", "", get_class($inv->getThis()));
         $method = lcfirst($method . ucfirst($inv->getMethod()->getName()));
         if (method_exists($this, $method)) {
             $args = $inv->getArguments();
             $args[] = $result;
             call_user_func_array(array($this, $method), $args);
         }
         return $result;
     } catch (Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 5
0
 public function invoke(Sabel_Aspect_MethodInvocation $inv)
 {
     if (!($active = Sabel_Db_Transaction::isActive())) {
         Sabel_Db_Transaction::activate();
     }
     try {
         $result = $inv->proceed();
         if (!$active) {
             Sabel_Db_Transaction::commit();
         }
         return $result;
     } catch (Exception $e) {
         if (!$active) {
             Sabel_Db_Transaction::rollback();
         }
         throw $e;
     }
 }
Ejemplo n.º 6
0
 /**
  * implements Sabel_Aspect_MethodInterceptor
  */
 public function invoke(Sabel_Aspect_MethodInvocation $i)
 {
     $exception = null;
     try {
         $return = $i->proceed();
         $result = $this->interceptor->after($i->getMethod(), $i->getArguments(), $i->getThis(), $return, $exception);
         if ($result !== null) {
             return $result;
         } else {
             return $return;
         }
     } catch (Exception $exception) {
         $result = $this->interceptor->after($i->getMethod(), $i->getArguments(), $i->getThis(), $return, $exception);
         if ($result !== null) {
             return $result;
         } else {
             throw $exception;
         }
     }
 }
Ejemplo n.º 7
0
 public function invoke(Sabel_Aspect_MethodInvocation $invocation)
 {
     $advice = $this->advice;
     $methods = $this->adviceMethods;
     $method = $invocation->getMethod();
     $arguments = $invocation->getArguments();
     $target = $invocation->getThis();
     $hasBefore = isset($methods["before"]);
     $hasAround = isset($methods["around"]);
     $hasAfter = isset($methods["after"]);
     $hasThrows = isset($methods["throws"]);
     try {
         $result = null;
         if ($hasBefore) {
             $beforeMethod = $methods["before"];
             $result = $advice->{$beforeMethod}($method, $arguments, $target);
         }
         if ($result === null && !$hasAround) {
             $result = $invocation->proceed();
         }
         if ($hasAround) {
             $aroundMethod = $methods["around"];
             $result = $advice->{$aroundMethod}($invocation);
         }
     } catch (Exception $exception) {
         if ($hasThrows) {
             $throwsMethod = $methods["throws"];
             $advice->{$throwsMethod}($method, $arguments, $target, $exception);
         } else {
             throw $exception;
         }
     }
     if ($hasAfter) {
         $afterMethod = $methods["after"];
         $advice->{$afterMethod}($method, $arguments, $target, $result);
     }
     return $result;
 }
Ejemplo n.º 8
0
 public function invoke(Sabel_Aspect_MethodInvocation $invocation)
 {
     return $invocation->proceed();
 }