Automattic\WooCommerce\StoreApi\Schemas

ExtendSchema::get_endpoint_schema()publicWC 1.0

Returns the registered endpoint schema

Method of the class: ExtendSchema{}

No Hooks.

Return

Object. Returns an array with registered schema data.

Usage

$ExtendSchema = new ExtendSchema();
$ExtendSchema->get_endpoint_schema( $endpoint, $passed_args );
$endpoint(string) (required)
A valid identifier.
$passed_args(array)
Passed arguments from the Schema class.
Default: []

ExtendSchema::get_endpoint_schema() code WC 8.7.0

public function get_endpoint_schema( $endpoint, array $passed_args = [] ) {
	$registered_schema = [];

	if ( isset( $this->extend_data[ $endpoint ] ) ) {
		foreach ( $this->extend_data[ $endpoint ] as $namespace => $callbacks ) {
			if ( is_null( $callbacks['schema_callback'] ) ) {
				continue;
			}
			try {
				$schema = $callbacks['schema_callback']( ...$passed_args );

				if ( ! is_array( $schema ) ) {
					$schema = [];
					throw new \Exception( '$schema_callback must return an array.' );
				}
			} catch ( \Throwable $e ) {
				$this->throw_exception( $e );
			}

			$registered_schema[ $namespace ] = $this->format_extensions_properties( $namespace, $schema, $callbacks['schema_type'] );
		}
	}

	return (object) $registered_schema;
}