A generic interceptor can intercept runtime events that occur within a base program. Those events are materialized by (reified in) joinpoints. Runtime joinpoints can be invocations, field access, exceptions... This interface is not used directly. Use the the sub-interfaces to intercept specific events. For instance, the following class implements some specific interceptors in order to implement a debugger:
class DebuggingInterceptor implements Interceptor
{
    public function invoke(Joinpoint $i)
    {
        $this->debug($i->getStaticPart(), $i->getThis(), $i->getArgs());

        return $i->proceed();
    }

    protected function debug($accessibleObject, $object, $value)
    {
        ...
    }
}
See also: Joinpoint
Inheritance: extends Go\Aop\Advice
コード例 #1
0
 /**
  * Method invoker
  *
  * @param Joinpoint $joinpoint the method invocation joinpoint
  *
  * @return mixed the result of the call to {@see Joinpoint->proceed()}
  */
 public final function invoke(Joinpoint $joinpoint)
 {
     if ($joinpoint instanceof Invocation) {
         if ($this->dynamicPointFilter->matches($joinpoint->getStaticPart(), $joinpoint->getThis(), $joinpoint->getArguments())) {
             return $this->interceptor->invoke($joinpoint);
         }
     }
     return $joinpoint->proceed();
 }
コード例 #2
0
 /**
  * Method invoker
  *
  * @param Joinpoint $joinpoint the method invocation joinpoint
  *
  * @return mixed the result of the call to {@see Joinpoint->proceed()}
  */
 public final function invoke(Joinpoint $joinpoint)
 {
     if ($joinpoint instanceof Invocation) {
         $point = $joinpoint->getStaticPart();
         $instance = $joinpoint->getThis();
         $context = new \ReflectionClass($instance);
         if ($this->pointFilter->matches($point, $context, $instance, $joinpoint->getArguments())) {
             return $this->interceptor->invoke($joinpoint);
         }
     }
     return $joinpoint->proceed();
 }