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); }
/** * 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(); } }
/** * 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; } } }
/** * 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; } } }
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; } }
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; }