Automattic\WooCommerce\Internal\ProductFeed\Storage

JsonFileFeed::open_handle │ private │ WC 1.0

Opens the feed file handle, throwing if it cannot be opened.

Method of the class: JsonFileFeed{}

No Hooks.

Returns

resource. The opened file handle.

Usage

// private - for code of main (parent) class only
$result = $this->open_handle( $path, $mode );
$path(string) (required)
The file path to open.
$mode(string) (required)
The fopen() mode.

JsonFileFeed::open_handle() code WC 11.1.2

private function open_handle( string $path, string $mode ) {
	$handle = fopen( $path, $mode );
	if ( false === $handle ) {
		throw new Exception(
			esc_html(
				sprintf(
					/* translators: %s: file path */
					__( 'Unable to open feed file: %s', 'woocommerce' ),
					$path
				)
			)
		);
	}

	$this->file_handle = $handle;
	return $handle;
}