Automattic\WooCommerce\Blueprint\Schemas

JsonSchema::__construct │ public │ WC 1.0

JsonSchema constructor.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$JsonSchema = new JsonSchema();
$JsonSchema->__construct( $json_path );
$json_path(строка) (обязательный)
The path to the JSON file.

Код JsonSchema::__construct() WC 11.3.0

public function __construct( $json_path ) {
	$real_path = realpath( $json_path );

	if ( false === $real_path ) {
		throw new \InvalidArgumentException( 'Invalid schema path' );
	}

	$contents = $this->wp_filesystem_get_contents( $real_path );

	if ( false === $contents ) {
		throw new \RuntimeException( "Failed to read the JSON file at {$real_path}." );
	}

	$schema       = json_decode( $contents );
	$this->schema = $schema;

	if ( ! $this->validate() ) {
		throw new \InvalidArgumentException( "Invalid JSON or missing 'steps' field." );
	}
}