Automattic\WooCommerce\Internal\BatchProcessing

BatchProcessingController::get_processor_instance()privateWC 1.0

Get an instance of a processor given its class name.

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

Хуки из метода

Возвращает

BatchProcessorInterface. Instance of batch processor for the given class.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_processor_instance( $processor_class_name ) : BatchProcessorInterface;
$processor_class_name(строка) (обязательный)
Full class name of the batch processor.

Код BatchProcessingController::get_processor_instance() WC 8.7.0

private function get_processor_instance( string $processor_class_name ) : BatchProcessorInterface {
	$processor = wc_get_container()->get( $processor_class_name );

	/**
	 * Filters the instance of a processor for a given class name.
	 *
	 * @param object|null $processor The processor instance given by the dependency injection container, or null if none was obtained.
	 * @param string $processor_class_name The full class name of the processor.
	 * @return BatchProcessorInterface|null The actual processor instance to use, or null if none could be retrieved.
	 *
	 * @since 6.8.0.
	 */
	$processor = apply_filters( 'woocommerce_get_batch_processor', $processor, $processor_class_name );
	if ( ! isset( $processor ) && class_exists( $processor_class_name ) ) {
		// This is a fallback for when the batch processor is not registered in the container.
		$processor = new $processor_class_name();
	}
	if ( ! is_a( $processor, BatchProcessorInterface::class ) ) {
		throw new \Exception( "Unable to initialize batch processor instance for $processor_class_name" );
	}
	return $processor;
}