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.
- implement Interceptor
implements MethodInterceptor
- create new PointCut
implements PointCutable
- 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]
);
}
- create new Aspect
extends AspectModule
- 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?