Automattic\WooCommerce\Blueprint\Schemas
JsonSchema::__construct
JsonSchema constructor.
Method of the class: JsonSchema{}
No Hooks.
Returns
null
. Nothing (null).
Usage
$JsonSchema = new JsonSchema(); $JsonSchema->__construct( $json_path );
- $json_path(string) (required)
- The path to the JSON file.
JsonSchema::__construct() JsonSchema:: construct code WC 9.9.5
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." ); } }