Blog: PHP

Interceptors with PHP

June 23, 2010, (updated on September 6, 2014), 2 comments, Software Development

Interceptors are used for aspect oriented programming (AOP). With the given interceptor, method calls can be extended or suppressed. PHP interceptors are implemented using the _call magic method. Problems A big problem implementing interceptors in PHP is the fact that method calls of the same class will not be intercepted. To solve the problem, simply call a method with $this->intercepted->myMethod() instead of $this->myMethod(). Methods which are called on intercepted will be intercepted. Another problem is that the AbstractInterceptor‘s methods (e.g. callMethod()) must not be called on the intercepted object from outside. Implementation Important: Within the interceptor methods, all calls on […] Read more...

Tags: ,

  Page 1 of 1