Automattic\WooCommerce\StoreApi

StoreApi::container()public staticWC 1.0

Loads the DI container for Store API.

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

Хуков нет.

Возвращает

Разное.

Использование

$result = StoreApi::container( $reset );
$reset(true|false)
Used to reset the container to a fresh instance. Note: this means all dependencies will be reconstructed.
По умолчанию: false

Код StoreApi::container() WC 8.7.0

public static function container( $reset = false ) {
	static $container;

	if ( $reset ) {
		$container = null;
	}

	if ( $container ) {
		return $container;
	}

	$container = new Container();
	$container->register(
		Authentication::class,
		function () {
			return new Authentication();
		}
	);
	$container->register(
		Legacy::class,
		function () {
			return new Legacy();
		}
	);
	$container->register(
		RoutesController::class,
		function ( $container ) {
			return new RoutesController(
				$container->get( SchemaController::class )
			);
		}
	);
	$container->register(
		SchemaController::class,
		function ( $container ) {
			return new SchemaController(
				$container->get( ExtendSchema::class )
			);
		}
	);
	$container->register(
		ExtendSchema::class,
		function ( $container ) {
			return new ExtendSchema(
				$container->get( Formatters::class )
			);
		}
	);
	$container->register(
		Formatters::class,
		function () {
			$formatters = new Formatters();
			$formatters->register( 'money', MoneyFormatter::class );
			$formatters->register( 'html', HtmlFormatter::class );
			$formatters->register( 'currency', CurrencyFormatter::class );
			return $formatters;
		}
	);
	return $container;
}