Example #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();
     }
 }
Example #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;
         }
     }
 }
Example #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;
     }
 }
Example #4
0
 public function invoke(Sabel_Aspect_MethodInvocation $invocation)
 {
     $method = $invocation->getMethod()->getName();
     if (in_array($method, get_class_methods($this))) {
         $this->{$method}();
     }
     if (preg_match("/set+/", $invocation->getMethod()->getName())) {
         if ($this->locked()) {
             throw new Sabel_Test_Aspect_LockedException("locked");
         }
     }
     return parent::invoke($invocation);
 }
Example #5
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;
     }
 }
Example #6
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;
     }
 }
Example #7
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;
         }
     }
 }
Example #8
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;
 }
Example #9
0
 public function invoke(Sabel_Aspect_MethodInvocation $invocation)
 {
     return $invocation->proceed();
 }