Container

class \TYPO3\CMS\Extbase\Object\Container\Container

Implements
SingletonInterface, LoggerAwareInterface
Uses
LoggerAwareTrait

Internal TYPO3 Dependency Injection container

Deprecated

since v11, will be removed in v12. Use symfony DI and GeneralUtility::makeInstance() instead. See TYPO3 explained documentation for more information. Does not trigger_error since the ObjectManager->get() call does that.

Tags

template

Table of Contents

Interfaces

SingletonInterface
"empty" interface for singletons (marker interface pattern)
LoggerAwareInterface

Properties

$instantiator  : InstantiatorInterface

Methods

__construct()  : mixed
getEmptyObject()  : object|T
Create an instance of $className without calling its constructor
getImplementationClassName()  : string
Returns the class name for a new instance, taking into account the class-extension API.
getInstance()  : object|T
Main method which should be used to get an instance of the wished class specified by $className.
registerImplementation()  : void
register a classname that should be used if a dependency is required.
getInstanceInternal()  : object|T
Internal implementation for getting a class.
getInstantiator()  : InstantiatorInterface
Internal method to create the class instantiator, extracted to be mockable
getReflectionService()  : ReflectionService
Lazy load ReflectionService.
initializeObject()  : void
Call object initializer if present in object
injectDependencies()  : void
Inject setter-dependencies into $instance
instanciateObject()  : object
Instantiates an object, possibly setting the constructor dependencies.

Properties

$instantiator

protected InstantiatorInterface $instantiator

Methods

__construct()

public __construct(ContainerInterface $psrContainer) : mixed

Parameters

$psrContainer : ContainerInterface

getEmptyObject()

Create an instance of $className without calling its constructor

public getEmptyObject(string|class-string $className) : object|T

Parameters

$className : string|class-string

Return values

object|T

getImplementationClassName()

Returns the class name for a new instance, taking into account the class-extension API.

public getImplementationClassName(string $className) : string

Parameters

$className : string

Base class name to evaluate

Return values

string —

Final class name to instantiate with "new [classname]

getInstance()

Main method which should be used to get an instance of the wished class specified by $className.

public getInstance(string|class-string $className[, array $givenConstructorArguments = [] ]) : object|T

Parameters

$className : string|class-string
$givenConstructorArguments : array = []

the list of constructor arguments as array

Return values

object|T —

the built object

registerImplementation()

register a classname that should be used if a dependency is required.

public registerImplementation(string $className, string $alternativeClassName) : void

e.g. used to define default class for an interface

Parameters

$className : string
$alternativeClassName : string

Tags

todo

deprecate in favor of core DI configuration (aliases/overrides)

getInstanceInternal()

Internal implementation for getting a class.

protected getInstanceInternal(string|class-string $className, array<int, mixed> ...$givenConstructorArguments) : object|T

Parameters

$className : string|class-string
$givenConstructorArguments : array<int, mixed>

the list of constructor arguments as array

Tags

throws
Exception
throws
CannotBuildObjectException

Return values

object|T —

the built object

getInstantiator()

Internal method to create the class instantiator, extracted to be mockable

protected getInstantiator() : InstantiatorInterface

Return values

InstantiatorInterface

getReflectionService()

Lazy load ReflectionService.

protected getReflectionService() : ReflectionService

Required as this class is being loaded in ext_localconf.php and we MUST not create caches in ext_localconf.php (which ReflectionService needs to do).

Return values

ReflectionService

initializeObject()

Call object initializer if present in object

protected initializeObject(object $instance) : void

Parameters

$instance : object

injectDependencies()

Inject setter-dependencies into $instance

protected injectDependencies(object $instance, ClassSchema $classSchema) : void

Parameters

$instance : object
$classSchema : ClassSchema

instanciateObject()

Instantiates an object, possibly setting the constructor dependencies.

protected instanciateObject(ClassSchema $classSchema, array<int, mixed> ...$givenConstructorArguments) : object

Additionally, directly registers all singletons in the singleton registry, such that circular references of singletons are correctly instantiated.

Parameters

$classSchema : ClassSchema
$givenConstructorArguments : array<int, mixed>

Tags

throws
Exception

Return values

object —

the new instance

On this page