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

Метод класса: 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 8.7.0

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