ObjectManagerInterface
interface ObjectManagerInterface implements ContainerInterface (View source)
Interface for the Flow Object Manager This is a superset of the PSR-11 ContainerInterface.
If all you need is get and has you might want to use ContainerInterface only.
Constants
INITIALIZATIONCAUSE_CREATED |
|
INITIALIZATIONCAUSE_RECREATED |
|
Methods
Returns the currently set context.
Returns a fresh or existing instance of the object specified by $objectName.
This is the PSR-11 ContainerInterface equivalent to isRegistered
.
Returns true if an object with the given name has already been registered.
Registers the passed shutdown lifecycle method for the given object
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.
Returns the object name corresponding to a given class name.
Returns the implementation class name for the specified object
Returns the key of the package the specified object is contained in.
Returns the scope of the specified object.
Sets the instance of the given object
Unsets the instance of the given object
Returns all instances of objects with scope session
Shuts the object manager down and calls the shutdown methods of all objects which are configured for it.
Details
ApplicationContext
getContext()
Returns the currently set context.
object
get(string $objectName)
Returns a fresh or existing instance of the object specified by $objectName.
Important:
If possible, instances of Prototype objects should always be created with the new keyword and Singleton objects should rather be injected by some type of Dependency Injection.
bool
has(string $objectName)
This is the PSR-11 ContainerInterface equivalent to isRegistered
.
bool
isRegistered(string $objectName)
Returns true if an object with the given name has already been registered.
void
registerShutdownObject(object $object, string $shutdownLifecycleMethodName)
Registers the passed shutdown lifecycle method for the given object
string|null
getCaseSensitiveObjectName(string $caseInsensitiveObjectName)
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.
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.
string
getObjectNameByClassName(string $className)
Returns the object name corresponding to a given class name.
string
getClassNameByObjectName(string $objectName)
Returns the implementation class name for the specified object
string
getPackageKeyByObjectName(string $objectName)
Returns the key of the package the specified object is contained in.
int
getScope(string $objectName)
Returns the scope of the specified object.
void
setInstance(string $objectName, object $instance)
Sets the instance of the given object
void
forgetInstance(string $objectName)
Unsets the instance of the given object
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.
array
getSessionInstances()
Returns all instances of objects with scope session
void
shutdown()
Shuts the object manager down and calls the shutdown methods of all objects which are configured for it.