ProxyClassBuilder
class ProxyClassBuilder (View source)
A Proxy Class Builder which integrates Dependency Injection
Constants
AUTOGENERATED_PROXY_METHOD_COMMENT |
|
Properties
protected | $reflectionService | ||
protected | $compiler | ||
protected | $logger | ||
protected | $configurationManager | ||
protected | $cacheManager | ||
protected | $objectManager | ||
protected Configuration[] | $objectConfigurations |
Methods
No description
Analyzes the object configuration provided by the compile-time object manager and builds the necessary PHP code for the proxy classes to realize dependency injection.
Renders additional code which registers the instance of the proxy class at the Object Manager before constructor injection is executed. Used in constructors and wakeup methods.
Renders code to create identifier/type information from related entities in an object.
No description
Renders additional code for the __construct() method of the Proxy Class which realizes constructor injection.
Builds the code necessary to inject setter based dependencies.
Builds code which injects an object which was specified by its object configuration
Builds code which injects an object which was specified by its object name
Builds code which assigns the value stored in the specified configuration into the given class property.
Builds code which assigns the frontend of the specified cache into the given class property.
Builds code which injects a DependencyProxy instead of the actual dependency
Builds a code snippet which tries to inject the specified property first through calling the related inject() method and then the set() method. If neither exists and the property doesn't exist either, an empty array is returned.
Builds code which calls the lifecycle initialization method, if any.
Builds code which registers the lifecycle shutdown method, if any.
FIXME: Not yet completely refactored to new proxy mechanism
No description
Compile the result of methods marked with CompileStatic into the proxy class
Details
void
injectReflectionService(ReflectionService $reflectionService)
No description
void
injectCompiler(Compiler $compiler)
No description
void
injectConfigurationManager(ConfigurationManager $configurationManager)
No description
void
injectCacheManager(CacheManager $cacheManager)
No description
void
injectLogger(LoggerInterface $logger)
No description
void
injectObjectManager(CompileTimeObjectManager $objectManager)
No description
void
build()
Analyzes the object configuration provided by the compile-time object manager and builds the necessary PHP code for the proxy classes to realize dependency injection.
protected string
buildSetInstanceCode(Configuration $objectConfiguration)
Renders additional code which registers the instance of the proxy class at the Object Manager before constructor injection is executed. Used in constructors and wakeup methods.
This also makes sure that object creation does not end in an endless loop due to bidirectional dependencies.
protected string
buildSerializeRelatedEntitiesCode(Configuration $objectConfiguration)
Renders code to create identifier/type information from related entities in an object.
The code is only rendered if one of the following conditions is met:
- The class is annotated with Entity
- The class is annotated with Scope("session")
- The class has properties annotated with Transient
- The class has properties annotated with Inject
Despite the previous condition, the code will not be rendered if the following condition is true:
- The class already has a __sleep() method (we assume that the developer wants to take care of serialization themself)
NOTE: Even though the method name suggests that it is only dealing with related entities code, it is currently also used for removing injected properties before serialization. This should be refactored in the future.
protected string
buildSetRelatedEntitiesCode()
No description
protected string
buildConstructorInjectionCode(Configuration $objectConfiguration)
Renders additional code for the __construct() method of the Proxy Class which realizes constructor injection.
protected string
buildPropertyInjectionCode(Configuration $objectConfiguration)
Builds the code necessary to inject setter based dependencies.
protected array
buildPropertyInjectionCodeByConfiguration(Configuration $objectConfiguration, string $propertyName, Configuration $propertyConfiguration)
Builds code which injects an object which was specified by its object configuration
array
buildPropertyInjectionCodeByString(Configuration $objectConfiguration, ConfigurationProperty $propertyConfiguration, string $propertyName, string $propertyObjectName)
Builds code which injects an object which was specified by its object name
array
buildPropertyInjectionCodeByConfigurationTypeAndPath(Configuration $objectConfiguration, string $propertyName, string $configurationType, string|null $configurationPath = null)
Builds code which assigns the value stored in the specified configuration into the given class property.
array
buildPropertyInjectionCodeByCacheIdentifier(Configuration $objectConfiguration, string $propertyName, string $cacheIdentifier)
Builds code which assigns the frontend of the specified cache into the given class property.
protected array
buildLazyPropertyInjectionCode(string $propertyObjectName, string $propertyClassName, string $propertyName, string $preparedSetterArgument)
Builds code which injects a DependencyProxy instead of the actual dependency
protected array|null
buildSetterInjectionCode(string $className, string $propertyName, string $preparedSetterArgument)
Builds a code snippet which tries to inject the specified property first through calling the related inject() method and then the set() method. If neither exists and the property doesn't exist either, an empty array is returned.
If neither inject() nor set() exists, but the property does exist, NULL is returned
protected string
buildLifecycleInitializationCode(Configuration $objectConfiguration, int $cause)
Builds code which calls the lifecycle initialization method, if any.
protected string
buildLifecycleShutdownCode(Configuration $objectConfiguration, int $cause)
Builds code which registers the lifecycle shutdown method, if any.
protected string
buildMethodParametersCode(array $argumentConfigurations)
FIXME: Not yet completely refactored to new proxy mechanism
protected string
buildCustomFactoryCall(string $customFactoryObjectName, string $customFactoryMethodName, array $arguments)
No description
protected void
compileStaticMethods(string $className, ProxyClass $proxyClass)
Compile the result of methods marked with CompileStatic into the proxy class