rest_find_matching_pattern_property_schema

函式
rest_find_matching_pattern_property_schema ( $property, $args )
引數
  • (string) $property The property name to check.
    Required:
  • (array) $args The schema array to use.
    Required:
返回值
  • (array|null) The schema of matching pattern property, or null if no patterns match.
定義位置
相關方法
rest_find_any_matching_schemarest_find_one_matching_schemarest_validate_string_value_from_schemarest_handle_multi_type_schemarest_get_endpoint_args_for_schema
引入
5.6.0
棄用
-

rest_find_matching_pattern_property_schema: 該函式用於查詢與模式屬性相匹配的模式。它接收一個資料物件、屬性名稱和一個模式物件的陣列,並返回與模式屬性相匹配的第一個模式物件。

使用patternProperties關鍵字查詢一個屬性的模式。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function rest_find_matching_pattern_property_schema( $property, $args ) {
if ( isset( $args['patternProperties'] ) ) {
foreach ( $args['patternProperties'] as $pattern => $child_schema ) {
if ( rest_validate_json_schema_pattern( $pattern, $property ) ) {
return $child_schema;
}
}
}
return null;
}
function rest_find_matching_pattern_property_schema( $property, $args ) { if ( isset( $args['patternProperties'] ) ) { foreach ( $args['patternProperties'] as $pattern => $child_schema ) { if ( rest_validate_json_schema_pattern( $pattern, $property ) ) { return $child_schema; } } } return null; }
function rest_find_matching_pattern_property_schema( $property, $args ) {
	if ( isset( $args['patternProperties'] ) ) {
		foreach ( $args['patternProperties'] as $pattern => $child_schema ) {
			if ( rest_validate_json_schema_pattern( $pattern, $property ) ) {
				return $child_schema;
			}
		}
	}

	return null;
}

常見問題

FAQs
檢視更多 >