Automattic\WooCommerce\Internal\Admin\Logging\FileV2

FileController::get_file_by_id()publicWC 1.0

Get a File instance from a file ID.

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

Хуков нет.

Возвращает

File|WP_Error.

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

$FileController = new FileController();
$FileController->get_file_by_id( $file_id );
$file_id(строка) (обязательный)
A file ID (file basename without the hash).

Код FileController::get_file_by_id() WC 9.7.1

public function get_file_by_id( string $file_id ) {
	$result = $this->get_files_by_id( array( $file_id ) );

	if ( count( $result ) < 1 ) {
		return new WP_Error(
			'wc_log_file_error',
			esc_html__( 'This file does not exist.', 'woocommerce' )
		);
	}

	if ( count( $result ) > 1 ) {
		return new WP_Error(
			'wc_log_file_error',
			esc_html__( 'Multiple files match this ID.', 'woocommerce' )
		);
	}

	return reset( $result );
}