ProxyClassBuilder
class ProxyClassBuilder (View source)
The main class of the AOP (Aspect Oriented Programming) framework.
Properties
protected Compiler | $compiler | ||
protected ReflectionService | $reflectionService | ||
protected LoggerInterface | $logger | ||
protected PointcutExpressionParser | $pointcutExpressionParser | An instance of the pointcut expression parser |
|
protected ProxyClassBuilder | $proxyClassBuilder | ||
protected VariableFrontend | $objectConfigurationCache | ||
protected CompileTimeObjectManager | $objectManager | ||
protected array | $excludedSubPackages | Hardcoded list of Flow sub packages (first 15 characters) which must be immune to AOP proxying for security, technical or conceptual reasons. |
|
protected array | $aspectContainers | A registry of all known aspects |
|
protected array | $methodInterceptorBuilders |
Methods
Injects the (system) logger based on PSR-3.
Injects an instance of the pointcut expression parser
Injects the cache for storing information about objects
Injects the Adviced Constructor Interceptor Builder
Injects the Adviced Method Interceptor Builder
Builds proxy class code which weaves advices into the respective target classes.
Traverses the aspect containers to find a pointcut from the aspect class name and pointcut method name
Determines which of the given classes are potentially proxyable and returns their names in an array.
Checks the annotations of the specified classes for aspect tags and creates an aspect with advisors accordingly.
Creates and returns an aspect from the annotations found in a class which is tagged as an aspect. The object acting as an advice will already be fetched (and therefore instantiated if necessary).
Builds methods for a single AOP proxy class for the specified class.
Makes sure that any sub classes of an adviced class also build the advices array on construction.
Adds code to build the methods and advices array in case the parent class has some.
Returns the methods of the target class.
Creates code for an array of target methods and their advices.
Traverses all intercepted methods and their advices and builds PHP code to intercept methods if necessary.
Traverses all aspect containers, their aspects and their advisors and adds the methods and their advices to the (usually empty) array of intercepted methods.
Traverses all methods which were introduced by interfaces and adds them to the intercepted methods array if they didn't exist already.
Traverses all aspect containers and returns an array of interface introductions which match the target class.
Traverses all aspect containers and returns an array of property introductions which match the target class.
Traverses all aspect containers and returns an array of trait introductions which match the target class.
Returns an array of interface names introduced by the given introductions
Returns all methods declared by the introduced interfaces
Renders a short message which gives a hint on where the currently parsed pointcut expression was defined.
Details
void
injectCompiler(Compiler $compiler)
No description
void
injectReflectionService(ReflectionService $reflectionService)
Injects the reflection service
void
injectLogger(LoggerInterface $logger)
Injects the (system) logger based on PSR-3.
void
injectPointcutExpressionParser(PointcutExpressionParser $pointcutExpressionParser)
Injects an instance of the pointcut expression parser
void
injectObjectConfigurationCache(VariableFrontend $objectConfigurationCache)
Injects the cache for storing information about objects
void
injectAdvicedConstructorInterceptorBuilder(AdvicedConstructorInterceptorBuilder $builder)
Injects the Adviced Constructor Interceptor Builder
void
injectAdvicedMethodInterceptorBuilder(AdvicedMethodInterceptorBuilder $builder)
Injects the Adviced Method Interceptor Builder
void
injectObjectManager(CompileTimeObjectManager $objectManager)
No description
void
build()
Builds proxy class code which weaves advices into the respective target classes.
The object configurations provided by the Compiler are searched for possible aspect annotations. If an aspect class is found, the pointcut expressions are parsed and a new aspect with one or more advisors is added to the aspect registry of the AOP framework. Finally all advices are woven into their target classes by generating proxy classes.
In general, the command neos.flow:core:compile is responsible for compilation and calls this method to do so.
In order to distinguish between an emerged / changed possible target class and a class which has been matched previously but just didn't have to be proxied, the latter are kept track of by an "unproxiedClass-*" cache entry.
mixed
findPointcut(string $aspectClassName, string $pointcutMethodName)
Traverses the aspect containers to find a pointcut from the aspect class name and pointcut method name
protected array
getProxyableClasses(array $classNamesByPackage)
Determines which of the given classes are potentially proxyable and returns their names in an array.
protected array
buildAspectContainers(array $classNames)
Checks the annotations of the specified classes for aspect tags and creates an aspect with advisors accordingly.
protected AspectContainer
buildAspectContainer(string $aspectClassName)
Creates and returns an aspect from the annotations found in a class which is tagged as an aspect. The object acting as an advice will already be fetched (and therefore instantiated if necessary).
bool
buildProxyClass(string $targetClassName, array $aspectContainers)
Builds methods for a single AOP proxy class for the specified class.
protected ClassNameIndex
proxySubClassesOfClassToEnsureAdvices(string $className, ClassNameIndex $targetClassNameCandidates, ClassNameIndex $treatedSubClasses)
Makes sure that any sub classes of an adviced class also build the advices array on construction.
protected ClassNameIndex
addBuildMethodsAndAdvicesCodeToClass(string $className, ClassNameIndex $treatedSubClasses)
Adds code to build the methods and advices array in case the parent class has some.
protected array
getMethodsFromTargetClass(string $targetClassName)
Returns the methods of the target class.
protected string
buildMethodsAndAdvicesArrayCode(array $methodsAndGroupedAdvices)
Creates code for an array of target methods and their advices.
Example:
$this->Flow_Aop_Proxy_targetMethodsAndGroupedAdvices = array( 'getSomeProperty' => array( \Neos\Flow\Aop\Advice\AroundAdvice::class => array( new \Neos\Flow\Aop\Advice\AroundAdvice(\Neos\Foo\SomeAspect::class, 'aroundAdvice', \Neos\Flow\Core\Bootstrap::$staticObjectManager, function() { ... }), ), ), );
protected void
buildMethodsInterceptorCode(string $targetClassName, array $interceptedMethods)
Traverses all intercepted methods and their advices and builds PHP code to intercept methods if necessary.
The generated code is added directly to the proxy class by calling the respective methods of the Compiler API.
protected void
addAdvicedMethodsToInterceptedMethods(array $interceptedMethods, array $methods, string $targetClassName, array $aspectContainers)
Traverses all aspect containers, their aspects and their advisors and adds the methods and their advices to the (usually empty) array of intercepted methods.
protected void
addIntroducedMethodsToInterceptedMethods(array $interceptedMethods, array $methodsFromIntroducedInterfaces)
Traverses all methods which were introduced by interfaces and adds them to the intercepted methods array if they didn't exist already.
protected array
getMatchingInterfaceIntroductions(array $aspectContainers, string $targetClassName)
Traverses all aspect containers and returns an array of interface introductions which match the target class.
protected array
getMatchingPropertyIntroductions(array $aspectContainers, string $targetClassName)
Traverses all aspect containers and returns an array of property introductions which match the target class.
protected array
getMatchingTraitNamesFromIntroductions(array $aspectContainers, string $targetClassName)
Traverses all aspect containers and returns an array of trait introductions which match the target class.
protected array
getInterfaceNamesFromIntroductions(array $interfaceIntroductions)
Returns an array of interface names introduced by the given introductions
protected array
getIntroducedMethodsFromInterfaceIntroductions(array $interfaceIntroductions)
Returns all methods declared by the introduced interfaces
protected string
renderSourceHint(string $aspectClassName, string $methodName, string $tagName)
Renders a short message which gives a hint on where the currently parsed pointcut expression was defined.