Automattic\WooCommerce\StoreApi\Schemas\V1

AbstractSchema::get_recursive_schema_property_defaults()protectedWC 1.0

Gets an array of schema defaults recursively.

Method of the class: AbstractSchema{}

No Hooks.

Return

Array. Array of defaults, pulled from arg_options

Usage

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

AbstractSchema::get_recursive_schema_property_defaults() code WC 9.3.1

protected function get_recursive_schema_property_defaults( $properties ) {
	$defaults = [];

	foreach ( $properties as $property_key => $property_value ) {
		if ( isset( $property_value['arg_options']['default'] ) ) {
			$defaults[ $property_key ] = $property_value['arg_options']['default'];
		} elseif ( isset( $property_value['properties'] ) ) {
			$defaults[ $property_key ] = $this->get_recursive_schema_property_defaults( $property_value['properties'] );
		}
	}

	return $defaults;
}