WooCommerce::get_instance_of()publicWC 4.4

Gets an instance of a given legacy class. This must not be used to get instances of classes in the src directory.

This method can be useful for unit tests, since objects obtained using this method can be easily mocked by using WC_Unit_Test_Case::register_legacy_proxy_class_mocks.

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

Хуков нет.


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


$WooCommerce = new WooCommerce();
$WooCommerce->get_instance_of( $class_name, ...$args );
$class_name(строка) (обязательный)
The name of the class to get an instance for.
...$args(разное) (обязательный)
Parameters to be passed to the class constructor or to the appropriate internal 'get_instance_of_' method.

Список изменений

С версии 4.4 Введена.

Код WooCommerce::get_instance_of() WC 8.9.3

public function get_instance_of( string $class_name, ...$args ) {
	return wc_get_container()->get( LegacyProxy::class )->get_instance_of( $class_name, ...$args );