Automattic\WooCommerce\StoreApi\Schemas

ExtendSchema::format_extensions_properties()privateWC 1.0

Format schema for an extension.

Method of the class: ExtendSchema{}

No Hooks.

Return

Array. Formatted schema.

Usage

// private - for code of main (parent) class only
$result = $this->format_extensions_properties( $namespace, $schema, $schema_type );
$namespace(string) (required)
Error message or \Exception.
$schema(array) (required)
An error to throw if we have debug enabled and user is admin.
$schema_type(string) (required)
How should data be shaped.

ExtendSchema::format_extensions_properties() code WC 9.4.2

private function format_extensions_properties( $namespace, $schema, $schema_type ) {
	if ( ARRAY_N === $schema_type ) {
		return [
			/* translators: %s: extension namespace */
			'description' => sprintf( __( 'Extension data registered by %s', 'woocommerce' ), $namespace ),
			'type'        => [ 'array', 'null' ],
			'context'     => [ 'view', 'edit' ],
			'items'       => $schema,
		];
	}
	return [
		/* translators: %s: extension namespace */
		'description' => sprintf( __( 'Extension data registered by %s', 'woocommerce' ), $namespace ),
		'type'        => [ 'object', 'null' ],
		'context'     => [ 'view', 'edit' ],
		'properties'  => $schema,
	];
}