Automattic\WooCommerce\Internal\DependencyManagement
RuntimeContainer::get
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.
Method of the class: RuntimeContainer{}
No Hooks.
Returns
Object
. The instance of the requested class.
Usage
$RuntimeContainer = new RuntimeContainer(); $RuntimeContainer->get( $class_name );
- $class_name(string) (required)
- The class name.
RuntimeContainer::get() RuntimeContainer::get code WC 9.8.5
public function get( string $class_name ) { $class_name = trim( $class_name, '\\' ); $resolve_chain = array(); return $this->get_core( $class_name, $resolve_chain ); }