Automattic\WooCommerce\Internal\DependencyManagement

RuntimeContainer::get()publicWC 1.0

Get an instance of a class.

ContainerException will be thrown in these cases:

  • $class_name is outside the WooCommerce root namespace (and wasn't included in the initial resolve cache).
  • The class referred by $class_name doesn't exist.
  • Recursive resolution condition found.
  • Reflection exception thrown when instantiating or initializing the class.

A "recursive resolution condition" happens when class A depends on class B and at the same time class B depends on class A, directly or indirectly; without proper handling this would lead to an infinite loop.

Note that this method throwing ContainerException implies that code fixes are needed, it's not an error condition that's recoverable at runtime.

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

Хуков нет.

Возвращает

Объект. The instance of the requested class.

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

$RuntimeContainer = new RuntimeContainer();
$RuntimeContainer->get( $class_name );
$class_name(строка) (обязательный)
The class name.

Код RuntimeContainer::get() WC 9.5.1

public function get( string $class_name ) {
	$class_name    = trim( $class_name, '\\' );
	$resolve_chain = array();
	return $this->get_core( $class_name, $resolve_chain );
}