Automattic\WooCommerce\Blocks\Registry

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 ) );

Method of the class: Container{}

No Hooks.

Return

FactoryType. An instance of the FactoryType dependency.

Usage

$Container = new Container();
$Container->factory( $instantiation_callback );
$instantiation_callback(Closure) (required)
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() code WC 8.7.0

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