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

getContext()

Returns the currently set context.

object
get(string $objectName)

Returns a fresh or existing instance of the object specified by $objectName.

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.

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

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.

Details

ApplicationContext getContext()

Returns the currently set context.

Return Value

ApplicationContext

the current 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.

Parameters

string $objectName

The name of the object to return an instance of

Return Value

object

The object instance

bool has(string $objectName)

This is the PSR-11 ContainerInterface equivalent to isRegistered.

Parameters

string $objectName

Return Value

bool

See also

isRegistered

bool isRegistered(string $objectName)

Since: 1.0.0 alpha 8

Returns true if an object with the given name has already been registered.

Parameters

string $objectName

Name of the object

Return Value

bool

true if the object has been registered, otherwise false

void registerShutdownObject(object $object, string $shutdownLifecycleMethodName)

Registers the passed shutdown lifecycle method for the given object

Parameters

object $object

The object to register the shutdown method for

string $shutdownLifecycleMethodName

The method name of the shutdown method to be called

Return Value

void

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.

Parameters

string $caseInsensitiveObjectName

The object name in lower-, upper- or mixed case

Return Value

string|null

Either the mixed case object name or false if no object of that name was found.

string getObjectNameByClassName(string $className)

Returns the object name corresponding to a given class name.

Parameters

string $className

The class name

Return Value

string

The object name corresponding to the given class name

string getClassNameByObjectName(string $objectName)

Returns the implementation class name for the specified object

Parameters

string $objectName

The object name

Return Value

string

The class name corresponding to the given object name or false if no such object is registered

string getPackageKeyByObjectName(string $objectName)

Returns the key of the package the specified object is contained in.

Parameters

string $objectName

The object name

Return Value

string

The package key or false if no such object exists

int getScope(string $objectName)

Returns the scope of the specified object.

Parameters

string $objectName

The object name

Return Value

int

One of the Configuration::SCOPE_ constants

void setInstance(string $objectName, object $instance)

Sets the instance of the given object

Parameters

string $objectName

The object name

object $instance

A prebuilt instance

Return Value

void

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.

Parameters

string $objectName

The object name

Return Value

void

array getSessionInstances()

Returns all instances of objects with scope session

Return Value

array

void shutdown()

Shuts the object manager down and calls the shutdown methods of all objects which are configured for it.

Return Value

void