Automattic\WooCommerce\Internal\BatchProcessing
BatchProcessingController::get_processor_instance()
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() BatchProcessingController::get processor instance WC 9.3.3
private function get_processor_instance( string $processor_class_name ): BatchProcessorInterface { $container = wc_get_container(); $processor = $container->has( $processor_class_name ) ? $container->get( $processor_class_name ) : null; /** * 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; }