PHP Class Neos\Flow\ObjectManagement\DependencyInjection\ProxyClassBuilder

Mostra file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$compiler Neos\Flow\ObjectManagement\Proxy\Compiler
$configurationManager Neos\Flow\Configuration\ConfigurationManager
$objectConfigurations array
$objectManager Neos\Flow\ObjectManagement\CompileTimeObjectManager
$reflectionService Neos\Flow\Reflection\ReflectionService
$systemLogger Neos\Flow\Log\SystemLoggerInterface

Public Methods

Method Description
build ( ) : void Analyzes the Object Configuration provided by the compiler and builds the necessary PHP code for the proxy classes to realize dependency injection.
buildPropertyInjectionCodeByConfigurationTypeAndPath ( Configuration $objectConfiguration, string $propertyName, string $configurationType, string $configurationPath = null ) : array Builds code which assigns the value stored in the specified configuration into the given class property.
buildPropertyInjectionCodeByString ( Configuration $objectConfiguration, Neos\Flow\ObjectManagement\Configuration\ConfigurationProperty $propertyConfiguration, string $propertyName, string $propertyObjectName ) : array Builds code which injects an object which was specified by its object name
injectCompiler ( Compiler $compiler ) : void
injectConfigurationManager ( ConfigurationManager $configurationManager ) : void
injectObjectManager ( CompileTimeObjectManager $objectManager ) : void
injectReflectionService ( ReflectionService $reflectionService ) : void
injectSystemLogger ( Neos\Flow\Log\SystemLoggerInterface $systemLogger ) : void

Protected Methods

Method Description
buildConstructorInjectionCode ( Configuration $objectConfiguration ) : string Renders additional code for the __construct() method of the Proxy Class which realizes constructor injection.
buildCustomFactoryCall ( string $customFactoryObjectName, string $customFactoryMethodName, array $arguments ) : string
buildLazyPropertyInjectionCode ( string $propertyObjectName, string $propertyClassName, string $propertyName, string $preparedSetterArgument ) : array Builds code which injects a DependencyProxy instead of the actual dependency
buildLifecycleInitializationCode ( Configuration $objectConfiguration, integer $cause ) : string Builds code which calls the lifecycle initialization method, if any.
buildLifecycleShutdownCode ( Configuration $objectConfiguration ) : string Builds code which registers the lifecycle shutdown method, if any.
buildMethodParametersCode ( array $argumentConfigurations ) : string FIXME: Not yet completely refactored to new proxy mechanism
buildPropertyInjectionCode ( Configuration $objectConfiguration ) : string Builds the code necessary to inject setter based dependencies.
buildPropertyInjectionCodeByConfiguration ( Configuration $objectConfiguration, string $propertyName, Configuration $propertyConfiguration ) : array Builds code which injects an object which was specified by its object configuration
buildSerializeRelatedEntitiesCode ( Configuration $objectConfiguration ) : string Renders code to create identifier/type information from related entities in an object.
buildSetInstanceCode ( Configuration $objectConfiguration ) : string 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.
buildSetterInjectionCode ( string $className, string $propertyName, string $preparedSetterArgument ) : array 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.
compileStaticMethods ( string $className, ProxyClass $proxyClass ) : void Compile the result of methods marked with CompileStatic into the proxy class

Method Details

build() public method

Analyzes the Object Configuration provided by the compiler and builds the necessary PHP code for the proxy classes to realize dependency injection.
public build ( ) : void
return void

buildConstructorInjectionCode() protected method

Renders additional code for the __construct() method of the Proxy Class which realizes constructor injection.
protected buildConstructorInjectionCode ( Configuration $objectConfiguration ) : string
$objectConfiguration Neos\Flow\ObjectManagement\Configuration\Configuration
return string The built code

buildCustomFactoryCall() protected method

protected buildCustomFactoryCall ( string $customFactoryObjectName, string $customFactoryMethodName, array $arguments ) : string
$customFactoryObjectName string
$customFactoryMethodName string
$arguments array
return string

buildLazyPropertyInjectionCode() protected method

Builds code which injects a DependencyProxy instead of the actual dependency
protected buildLazyPropertyInjectionCode ( string $propertyObjectName, string $propertyClassName, string $propertyName, string $preparedSetterArgument ) : array
$propertyObjectName string Object name of the dependency to inject
$propertyClassName string Class name of the dependency to inject
$propertyName string Name of the property in the class to inject into
$preparedSetterArgument string PHP code to use for retrieving the value to inject
return array PHP code

buildLifecycleInitializationCode() protected method

Builds code which calls the lifecycle initialization method, if any.
protected buildLifecycleInitializationCode ( Configuration $objectConfiguration, integer $cause ) : string
$objectConfiguration Neos\Flow\ObjectManagement\Configuration\Configuration
$cause integer a \Neos\Flow\ObjectManagement\ObjectManagerInterface::INITIALIZATIONCAUSE_* constant which is the cause of the initialization command being called.
return string

buildLifecycleShutdownCode() protected method

Builds code which registers the lifecycle shutdown method, if any.
protected buildLifecycleShutdownCode ( Configuration $objectConfiguration ) : string
$objectConfiguration Neos\Flow\ObjectManagement\Configuration\Configuration
return string

buildMethodParametersCode() protected method

FIXME: Not yet completely refactored to new proxy mechanism
protected buildMethodParametersCode ( array $argumentConfigurations ) : string
$argumentConfigurations array
return string

buildPropertyInjectionCode() protected method

Builds the code necessary to inject setter based dependencies.
protected buildPropertyInjectionCode ( Configuration $objectConfiguration ) : string
$objectConfiguration Neos\Flow\ObjectManagement\Configuration\Configuration (needed to produce helpful exception message)
return string The built code

buildPropertyInjectionCodeByConfiguration() protected method

Builds code which injects an object which was specified by its object configuration
protected buildPropertyInjectionCodeByConfiguration ( Configuration $objectConfiguration, string $propertyName, Configuration $propertyConfiguration ) : array
$objectConfiguration Neos\Flow\ObjectManagement\Configuration\Configuration Configuration of the object to inject into
$propertyName string Name of the property to inject
$propertyConfiguration Neos\Flow\ObjectManagement\Configuration\Configuration Configuration of the object to inject
return array PHP code

buildPropertyInjectionCodeByConfigurationTypeAndPath() public method

Builds code which assigns the value stored in the specified configuration into the given class property.
public buildPropertyInjectionCodeByConfigurationTypeAndPath ( Configuration $objectConfiguration, string $propertyName, string $configurationType, string $configurationPath = null ) : array
$objectConfiguration Neos\Flow\ObjectManagement\Configuration\Configuration Configuration of the object to inject into
$propertyName string Name of the property to inject
$configurationType string the configuration type of the injected property (one of the ConfigurationManager::CONFIGURATION_TYPE_* constants)
$configurationPath string Path with "." as separator specifying the setting value to inject or NULL if the complete configuration array should be injected
return array PHP code

buildPropertyInjectionCodeByString() public method

Builds code which injects an object which was specified by its object name
public buildPropertyInjectionCodeByString ( Configuration $objectConfiguration, Neos\Flow\ObjectManagement\Configuration\ConfigurationProperty $propertyConfiguration, string $propertyName, string $propertyObjectName ) : array
$objectConfiguration Neos\Flow\ObjectManagement\Configuration\Configuration Configuration of the object to inject into
$propertyConfiguration Neos\Flow\ObjectManagement\Configuration\ConfigurationProperty
$propertyName string Name of the property to inject
$propertyObjectName string Object name of the object to inject
return array PHP code

buildSerializeRelatedEntitiesCode() protected method

Used in sleep methods.
protected buildSerializeRelatedEntitiesCode ( Configuration $objectConfiguration ) : string
$objectConfiguration Neos\Flow\ObjectManagement\Configuration\Configuration
return string

buildSetInstanceCode() protected method

This also makes sure that object creation does not end in an endless loop due to bi-directional dependencies.
protected buildSetInstanceCode ( Configuration $objectConfiguration ) : string
$objectConfiguration Neos\Flow\ObjectManagement\Configuration\Configuration
return string

buildSetterInjectionCode() protected method

If neither inject*() nor set*() exists, but the property does exist, NULL is returned
protected buildSetterInjectionCode ( string $className, string $propertyName, string $preparedSetterArgument ) : array
$className string Name of the class to inject into
$propertyName string Name of the property to inject
$preparedSetterArgument string PHP code to use for retrieving the value to inject
return array PHP code

compileStaticMethods() protected method

Compile the result of methods marked with CompileStatic into the proxy class
protected compileStaticMethods ( string $className, ProxyClass $proxyClass ) : void
$className string
$proxyClass Neos\Flow\ObjectManagement\Proxy\ProxyClass
return void

injectCompiler() public method

public injectCompiler ( Compiler $compiler ) : void
$compiler Neos\Flow\ObjectManagement\Proxy\Compiler
return void

injectConfigurationManager() public method

public injectConfigurationManager ( ConfigurationManager $configurationManager ) : void
$configurationManager Neos\Flow\Configuration\ConfigurationManager
return void

injectObjectManager() public method

public injectObjectManager ( CompileTimeObjectManager $objectManager ) : void
$objectManager Neos\Flow\ObjectManagement\CompileTimeObjectManager
return void

injectReflectionService() public method

public injectReflectionService ( ReflectionService $reflectionService ) : void
$reflectionService Neos\Flow\Reflection\ReflectionService
return void

injectSystemLogger() public method

public injectSystemLogger ( Neos\Flow\Log\SystemLoggerInterface $systemLogger ) : void
$systemLogger Neos\Flow\Log\SystemLoggerInterface
return void

Property Details

$compiler protected_oe property

protected Compiler,Neos\Flow\ObjectManagement\Proxy $compiler
return Neos\Flow\ObjectManagement\Proxy\Compiler

$configurationManager protected_oe property

protected ConfigurationManager,Neos\Flow\Configuration $configurationManager
return Neos\Flow\Configuration\ConfigurationManager

$objectConfigurations protected_oe property

protected array $objectConfigurations
return array

$objectManager protected_oe property

protected CompileTimeObjectManager,Neos\Flow\ObjectManagement $objectManager
return Neos\Flow\ObjectManagement\CompileTimeObjectManager

$reflectionService protected_oe property

protected ReflectionService,Neos\Flow\Reflection $reflectionService
return Neos\Flow\Reflection\ReflectionService

$systemLogger protected_oe property

protected SystemLoggerInterface,Neos\Flow\Log $systemLogger
return Neos\Flow\Log\SystemLoggerInterface