private function getProxyListFixtures()
 {
     $serviceReflectionClass = new ReflectionClass(FooService::class);
     $aspectReflectionClass = new ReflectionClass(FooAspect::class);
     $proxyList = new ProxyList();
     $joinpoint = new Joinpoint($serviceReflectionClass->getMethod('foo'));
     $advice = new Advice(new BeforePointcut(new PointcutExpression('\\AOP\\Before')), new InterceptingMethod($aspectReflectionClass->getMethod('fooAdvice')));
     $aspectDefinition = new ArrayServiceDefinition(array('serviceId' => 'fooService', 'class' => FooAspect::class));
     $joinpointsAdvices = new Map();
     $joinpointsAdvices->put($joinpoint, new ArrayList());
     $joinpointsAdvices->getValue($joinpoint)->put([$advice, $aspectDefinition]);
     $proxyList->addProxy(new Proxy($joinpointsAdvices, new ArrayServiceDefinition(array('serviceId' => 'fooService', 'class' => '\\FooService'))));
     return $proxyList;
 }
 /**
  * @return ProxyList
  */
 private function getExpectedProxyList()
 {
     $reflectionClass = new ReflectionClass(FooAspect::class);
     $reflectionMethod = $reflectionClass->getMethod('fooAdvice');
     $joinpoint = new Joinpoint($reflectionMethod);
     $advice = new Advice(new Pointcut($this->getPointcutExpressionFixtures()), new InterceptingMethod(new ReflectionMethod(FooAspect::class, 'fooAdvice')));
     $adviceDefinition = new ArrayServiceDefinition(array('serviceId' => 'fooAspect', 'class' => FooAspect::class));
     $joinpointsAdvices = new Map();
     $joinpointsAdvices->put($joinpoint, new ArrayList());
     $joinpointsAdvices->getValue($joinpoint)->put([$advice, $adviceDefinition]);
     $targetDefinition = new ArrayServiceDefinition(array('serviceId' => 'fooService', 'class' => FooService::class));
     $proxyList = new ProxyList();
     $proxyList->addProxy(new Proxy($joinpointsAdvices, $targetDefinition));
     return $proxyList;
 }
Exemplo n.º 3
0
 private function groupByJoinpoints(IMap $advicesJoinpoints)
 {
     $groupedByJoinpoints = new Map();
     foreach ($advicesJoinpoints->getKeys() as $advice) {
         list($joinpoints, $aspectDefinition) = $advicesJoinpoints->getValue($advice);
         foreach ($joinpoints as $joinpoint) {
             if (!$groupedByJoinpoints->exists($joinpoint)) {
                 $groupedByJoinpoints->put($joinpoint, new ArrayList());
             }
             /** @var ArrayList $advices */
             $advices = $groupedByJoinpoints->getValue($joinpoint);
             $advices->put([$advice, $aspectDefinition]);
         }
     }
     return $groupedByJoinpoints;
 }