ytake / Laravel-Aspect

aspect oriented programming Package for laravel framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Binding aspects without annotations?

4n70w4 opened this issue · comments

Case: need bind aspects to external readonly library.
There is no possibility to edit its code to add annotations.
There is no possibility to make a wrapper with 10 000 methods for defining annotations.

It would be useful to define the cut points configured separately from the classes themselves.

Like this:
https://github.com/schmittjoh/JMSAopBundle/blob/master/Resources/doc/index.rst#pointcut

Okay.

  1. implement Interceptor implements MethodInterceptor
  2. create new PointCut implements PointCutable
  3. implement configure() in PointCut like this:
    public function configure(Container $app): Pointcut {
        $interceptor = new Interceptor();
        $this->setInterceptor($interceptor);
        
        return new Pointcut(
            (new Matcher())->any(),
            (new Matcher())->startsWith('action'),
            // or (new Matcher())->any()
            [$this->interceptor]
        );
    }
  1. create new Aspect extends AspectModule
  2. implement registerPointCut() in Aspect like this:
    public function registerPointCut(): PointCutable {
        return new PointCut();
    }

Your included Interceptors (https://github.com/ytake/Laravel-Aspect/tree/master/src/Interceptor) have very high coupling to the annotations. What about refactor them and remove hard coupling them with annotations?