Automattic\WooCommerce\StoreApi\Schemas\V1

AbstractSchema::force_schema_readonly()protectedWC 1.0

Force all schema properties to be readonly.

Method of the class: AbstractSchema{}

No Hooks.

Return

Array. Updated schema.

Usage

// protected - for code of main (parent) or child class
$result = $this->force_schema_readonly( $properties );
$properties(array) (required)
Schema.

AbstractSchema::force_schema_readonly() code WC 8.9.0

protected function force_schema_readonly( $properties ) {
	return array_map(
		function( $property ) {
			$property['readonly'] = true;
			if ( isset( $property['items']['properties'] ) ) {
				$property['items']['properties'] = $this->force_schema_readonly( $property['items']['properties'] );
			}
			return $property;
		},
		(array) $properties
	);
}