Container::factory()publicWC 1.0

Public api for adding a factory to the container.

Factory dependencies will have the instantiation callback invoked every time the dependency is requested.

Typical Usage:

$container->register( MyClass::class, $container->factory( $mycallback ) );

Метод класса: Container{}

Хуков нет.


FactoryType. An instance of the FactoryType dependency.


$Container = new Container();
$Container->factory( $instantiation_callback );
$instantiation_callback(Closure) (обязательный)
This will be invoked when the dependency is required. It will receive an instance of this container so the callback can retrieve dependencies from the container.

Код Container::factory() WC 9.0.2

public function factory( Closure $instantiation_callback ) {
	return new FactoryType( $instantiation_callback );