/** * Loads definition from specific point of aspect into the container * * @param AspectContainer $container Instance of container * @param Aspect $aspect Instance of aspect * @param mixed|\ReflectionClass|\ReflectionMethod|\ReflectionProperty $reflection Reflection of point * @param mixed|null $metaInformation Additional meta-information, e.g. annotation for method * * @throws \UnexpectedValueException */ public function load(AspectContainer $container, Aspect $aspect, $reflection, $metaInformation = null) { $pointcut = $this->parsePointcut($aspect, $reflection, $metaInformation); $methodId = get_class($aspect) . '->' . $reflection->name; $adviceCallback = Framework\BaseAdvice::fromAspectReflection($aspect, $reflection); if (isset($metaInformation->scope) && $metaInformation->scope !== 'aspect') { $scope = $metaInformation->scope; $adviceCallback = Framework\BaseAdvice::createScopeCallback($aspect, $adviceCallback, $scope); } switch (true) { // Register a pointcut by its name case $metaInformation instanceof Annotation\Pointcut: $container->registerPointcut($pointcut, $methodId); break; case $pointcut instanceof PointFilter: $advice = $this->getInterceptor($metaInformation, $adviceCallback); if ($pointcut->getKind() & PointFilter::KIND_DYNAMIC) { $advice = new Framework\DynamicInvocationMatcherInterceptor($pointcut, $advice); } $container->registerAdvisor(new DefaultPointcutAdvisor($pointcut, $advice), $methodId); break; default: throw new \UnexpectedValueException("Unsupported pointcut class: " . get_class($pointcut)); } }
/** * Loads definition from specific point of aspect into the container * * @param Aspect $aspect Instance of aspect * @param mixed|\ReflectionClass|\ReflectionMethod|\ReflectionProperty $reflection Reflection of point * @param mixed|null $metaInformation Additional meta-information, e.g. annotation for method * * @return array|Pointcut[]|Advisor[] * * @throws \UnexpectedValueException */ public function load(Aspect $aspect, $reflection, $metaInformation = null) { $loadedItems = array(); $pointcut = $this->parsePointcut($aspect, $reflection, $metaInformation); $methodId = get_class($aspect) . '->' . $reflection->name; $adviceCallback = Framework\BaseAdvice::fromAspectReflection($aspect, $reflection); if (isset($metaInformation->scope) && $metaInformation->scope !== 'aspect') { $scope = $metaInformation->scope; $adviceCallback = Framework\BaseAdvice::createScopeCallback($aspect, $adviceCallback, $scope); } switch (true) { // Register a pointcut by its name case $metaInformation instanceof Annotation\Pointcut: $loadedItems[$methodId] = $pointcut; break; case $pointcut instanceof PointFilter: $advice = $this->getInterceptor($metaInformation, $adviceCallback); $loadedItems[$methodId] = new DefaultPointcutAdvisor($pointcut, $advice); break; default: throw new \UnexpectedValueException("Unsupported pointcut class: " . get_class($pointcut)); } return $loadedItems; }