Automattic\WooCommerce\Internal\DependencyManagement
RuntimeContainer::get
Get an instance of a class.
ContainerException will be thrown in these cases:
$class_nameis outside the WooCommerce root namespace (and wasn't included in the initial resolve cache).- The class referred by
$class_namedoesn'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{}
Хуков нет.
Возвращает
T. Object instance.
Использование
$RuntimeContainer = new RuntimeContainer(); $RuntimeContainer->get( $class_name );
- $class_name(строка) (обязательный)
- Class name.
Код RuntimeContainer::get() RuntimeContainer::get WC 10.7.0
public function get( string $class_name ) {
$class_name = trim( $class_name, '\\' );
$resolve_chain = array();
// @phpstan-ignore return.type (get_core uses reflection to instantiate the correct class type at runtime)
return $this->get_core( $class_name, $resolve_chain );
}