1 | <?php |
||
27 | class DefaultPointcutAdvisor extends AbstractGenericAdvisor implements PointcutAdvisor |
||
28 | { |
||
29 | |||
30 | /** |
||
31 | * Pointcut instance |
||
32 | * |
||
33 | * @var Pointcut |
||
34 | */ |
||
35 | private $pointcut; |
||
36 | |||
37 | /** |
||
38 | * Create a DefaultPointcutAdvisor, specifying Pointcut and Advice. |
||
39 | * |
||
40 | * @param Pointcut $pointcut The Pointcut targeting the Advice |
||
41 | * @param Advice $advice The Advice to run when Pointcut matches |
||
42 | */ |
||
43 | 2 | public function __construct(Pointcut $pointcut, Advice $advice) |
|
44 | { |
||
45 | 2 | $this->pointcut = $pointcut; |
|
46 | 2 | parent::__construct($advice); |
|
47 | 2 | } |
|
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 2 | public function getAdvice(): Advice |
|
53 | { |
||
54 | 2 | $advice = parent::getAdvice(); |
|
55 | 2 | if (($advice instanceof Interceptor) && ($this->pointcut->getKind() & PointFilter::KIND_DYNAMIC)) { |
|
56 | $advice = new DynamicInvocationMatcherInterceptor( |
||
57 | $this->pointcut, |
||
58 | $advice |
||
59 | ); |
||
60 | } |
||
61 | |||
62 | 2 | return $advice; |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * Get the Pointcut that drives this advisor. |
||
67 | */ |
||
68 | 2 | public function getPointcut(): Pointcut |
|
72 | } |
||
73 |