PHP Class Neos\Flow\ObjectManagement\ObjectManager

Inheritance: implements Neos\Flow\ObjectManagement\ObjectManagerInterface
Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Свойство Type Description
$allSettings array An array of settings of all packages, indexed by package key
$cachedLowerCasedObjectNames array
$classesBeingInstantiated array
$context Neos\Flow\Core\ApplicationContext The configuration context for this Flow run
$dependencyProxies array
$internalShutdownObjects SplObjectStorage These shutdown method will be called after all other shutdown methods have been called.
$objectSerializer ObjectSerializer
$objects array
$shutdownObjects SplObjectStorage A SplObjectStorage containing those objects which need to be shutdown when the container shuts down. Each value of each entry is the respective shutdown method name.

Méthodes publiques

Méthode Description
__construct ( ApplicationContext $context ) Constructor for this Object Container
createLazyDependency ( string $hash, &$propertyReferenceVariable, string $className, Closure $builder ) : DependencyProxy Creates a new DependencyProxy class for a dependency built through code identified through "hash" for a dependency of class $className. The closure in $builder contains code for actually creating the dependency instance once it needs to be materialized.
forgetInstance ( string $objectName ) : void Unsets the instance of the given object
get ( string $objectName ) : object Returns a fresh or existing instance of the object specified by $objectName.
getAllObjectConfigurations ( ) : array Returns all current object configurations.
getCaseSensitiveObjectName ( string $caseInsensitiveObjectName ) : mixed Returns the case sensitive object name of an object specified by a case insensitive object name. If no object of that name exists, FALSE is returned.
getClassNameByObjectName ( string $objectName ) : string Returns the implementation class name for the specified object
getContext ( ) : ApplicationContext Returns the context Flow is running in.
getInstance ( string $objectName ) : object Returns the instance of the specified object or NULL if no instance has been registered yet.
getLazyDependencyByHash ( string $hash, &$propertyReferenceVariable ) : mixed This method is used internally to retrieve either an actual (singleton) instance of the specified dependency or, if no instance exists yet, a Dependency Proxy object which automatically triggers the creation of an instance as soon as it is used the first time.
getObjectNameByClassName ( string $className ) : string Returns the object name corresponding to a given class name.
getPackageKeyByObjectName ( string $objectName ) : string Returns the key of the package the specified object is contained in.
getScope ( string $objectName ) : integer Returns the scope of the specified object.
getSessionInstances ( ) : array Returns all instances of objects with scope session
getSettingsByPath ( array $settingsPath ) : mixed Returns the an array of package settings or a single setting value by the given path.
hasInstance ( string $objectName ) : boolean Returns TRUE if this object manager already has an instance for the specified object.
injectAllSettings ( array $settings ) : void Injects the global settings array, indexed by package key.
isRegistered ( string $objectName ) : boolean Returns TRUE if an object with the given name is registered
registerShutdownObject ( object $object, string $shutdownLifecycleMethodName ) : void Registers the passed shutdown lifecycle method for the given object
setInstance ( string $objectName, object $instance ) : void Sets the instance of the given object
setObjects ( array $objects ) : void Sets the objects array
shutdown ( ) : void Shuts down this Object Container by calling the shutdown methods of all object instances which were configured to be shut down.

Méthodes protégées

Méthode Description
buildObjectByFactory ( string $objectName ) : object Invokes the Factory defined in the object configuration of the specified object in order to build an instance. Arguments which were defined in the object configuration are passed to the factory method.
callShutdownMethods ( SplObjectStorage $shutdownObjects ) : void Executes the methods of the provided objects.
instantiateClass ( string $className, array $arguments ) : object Speed optimized alternative to ReflectionClass::newInstanceArgs()

Method Details

__construct() public méthode

Constructor for this Object Container
public __construct ( ApplicationContext $context )
$context Neos\Flow\Core\ApplicationContext The configuration context for this Flow run

buildObjectByFactory() protected méthode

Invokes the Factory defined in the object configuration of the specified object in order to build an instance. Arguments which were defined in the object configuration are passed to the factory method.
protected buildObjectByFactory ( string $objectName ) : object
$objectName string Name of the object to build
Résultat object The built object

callShutdownMethods() protected méthode

Executes the methods of the provided objects.
protected callShutdownMethods ( SplObjectStorage $shutdownObjects ) : void
$shutdownObjects SplObjectStorage
Résultat void

createLazyDependency() public méthode

Internally used by the injectProperties method of generated proxy classes.
public createLazyDependency ( string $hash, &$propertyReferenceVariable, string $className, Closure $builder ) : DependencyProxy
$hash string An md5 hash over the code needed to actually build the dependency instance
$className string Name of the class of the dependency which eventually will be instantiated
$builder Closure An anonymous function which creates the instance to be injected
Résultat Neos\Flow\ObjectManagement\DependencyInjection\DependencyProxy

forgetInstance() public méthode

If run during standard runtime, the whole application might become unstable because certain parts might already use an instance of this object. Therefore this method should only be used in a setUp() method of a functional test case.
public forgetInstance ( string $objectName ) : void
$objectName string The object name
Résultat void

get() public méthode

Returns a fresh or existing instance of the object specified by $objectName.
public get ( string $objectName ) : object
$objectName string The name of the object to return an instance of
Résultat object The object instance

getAllObjectConfigurations() public méthode

For internal use in bootstrap only. Can change anytime.
public getAllObjectConfigurations ( ) : array
Résultat array

getCaseSensitiveObjectName() public méthode

In general, the case sensitive variant is used everywhere in Flow, however there might be special situations in which the case sensitive name is not available. This method helps you in these rare cases.
public getCaseSensitiveObjectName ( string $caseInsensitiveObjectName ) : mixed
$caseInsensitiveObjectName string The object name in lower-, upper- or mixed case
Résultat mixed Either the mixed case object name or FALSE if no object of that name was found.

getClassNameByObjectName() public méthode

Returns the implementation class name for the specified object
public getClassNameByObjectName ( string $objectName ) : string
$objectName string The object name
Résultat string The class name corresponding to the given object name or FALSE if no such object is registered

getContext() public méthode

Returns the context Flow is running in.
public getContext ( ) : ApplicationContext
Résultat Neos\Flow\Core\ApplicationContext The context, for example "Development" or "Production"

getInstance() public méthode

Returns the instance of the specified object or NULL if no instance has been registered yet.
public getInstance ( string $objectName ) : object
$objectName string The object name
Résultat object The object or NULL

getLazyDependencyByHash() public méthode

Internally used by the injectProperties method of generated proxy classes.
public getLazyDependencyByHash ( string $hash, &$propertyReferenceVariable ) : mixed
$hash string
Résultat mixed

getObjectNameByClassName() public méthode

Returns the object name corresponding to a given class name.
public getObjectNameByClassName ( string $className ) : string
$className string The class name
Résultat string The object name corresponding to the given class name or FALSE if no object is configured to use that class

getPackageKeyByObjectName() public méthode

Returns the key of the package the specified object is contained in.
public getPackageKeyByObjectName ( string $objectName ) : string
$objectName string The object name
Résultat string The package key or FALSE if no such object exists

getScope() public méthode

Returns the scope of the specified object.
public getScope ( string $objectName ) : integer
$objectName string The object name
Résultat integer One of the Configuration::SCOPE_ constants

getSessionInstances() public méthode

Returns all instances of objects with scope session
public getSessionInstances ( ) : array
Résultat array

getSettingsByPath() public méthode

Returns the an array of package settings or a single setting value by the given path.
public getSettingsByPath ( array $settingsPath ) : mixed
$settingsPath array Path to the setting(s) as an array, for example array('Neos', 'Flow', 'persistence', 'backendOptions')
Résultat mixed Either an array of settings or the value of a single setting

hasInstance() public méthode

Returns TRUE if this object manager already has an instance for the specified object.
public hasInstance ( string $objectName ) : boolean
$objectName string The object name
Résultat boolean TRUE if an instance already exists

injectAllSettings() public méthode

Injects the global settings array, indexed by package key.
public injectAllSettings ( array $settings ) : void
$settings array The global settings
Résultat void

instantiateClass() protected méthode

Speed optimized alternative to ReflectionClass::newInstanceArgs()
protected instantiateClass ( string $className, array $arguments ) : object
$className string Name of the class to instantiate
$arguments array Arguments to pass to the constructor
Résultat object The object

isRegistered() public méthode

Returns TRUE if an object with the given name is registered
public isRegistered ( string $objectName ) : boolean
$objectName string Name of the object
Résultat boolean TRUE if the object has been registered, otherwise FALSE

registerShutdownObject() public méthode

Registers the passed shutdown lifecycle method for the given object
public registerShutdownObject ( object $object, string $shutdownLifecycleMethodName ) : void
$object object The object to register the shutdown method for
$shutdownLifecycleMethodName string The method name of the shutdown method to be called
Résultat void

setInstance() public méthode

Objects of scope sessions are assumed to be the real session object, not the lazy loading proxy.
public setInstance ( string $objectName, object $instance ) : void
$objectName string The object name
$instance object A prebuilt instance
Résultat void

setObjects() public méthode

Sets the objects array
public setObjects ( array $objects ) : void
$objects array An array of object names and some information about each registered object (scope, lower cased name etc.)
Résultat void

shutdown() public méthode

Shuts down this Object Container by calling the shutdown methods of all object instances which were configured to be shut down.
public shutdown ( ) : void
Résultat void

Property Details

$allSettings protected_oe property

An array of settings of all packages, indexed by package key
protected array $allSettings
Résultat array

$cachedLowerCasedObjectNames protected_oe property

protected array $cachedLowerCasedObjectNames
Résultat array

$classesBeingInstantiated protected_oe property

protected array $classesBeingInstantiated
Résultat array

$context protected_oe property

The configuration context for this Flow run
protected ApplicationContext,Neos\Flow\Core $context
Résultat Neos\Flow\Core\ApplicationContext

$dependencyProxies protected_oe property

protected array $dependencyProxies
Résultat array

$internalShutdownObjects protected_oe property

These shutdown method will be called after all other shutdown methods have been called.
protected SplObjectStorage $internalShutdownObjects
Résultat SplObjectStorage

$objectSerializer protected_oe property

protected ObjectSerializer,Neos\Flow\ObjectManagement $objectSerializer
Résultat ObjectSerializer

$objects protected_oe property

protected array $objects
Résultat array

$shutdownObjects protected_oe property

A SplObjectStorage containing those objects which need to be shutdown when the container shuts down. Each value of each entry is the respective shutdown method name.
protected SplObjectStorage $shutdownObjects
Résultat SplObjectStorage