ACF\AI\GEO

Schema::get_preferred_object_type │ public static │ ACF 6.8.0

Get the preferred object type for a property

When a property expects an object, this returns the most appropriate type. For properties with multiple possible types, returns the first one.

Метод класса: Schema{}

Хуков нет.

Возвращает

string|null. The type name, or null if property doesn't expect an object

Использование

$result = Schema::get_preferred_object_type( $property );
$property(строка) (обязательный)
The property name.

Список изменений

С версии 6.8.0 Введена.

Код Schema::get_preferred_object_type() ACF 6.8.11

public static function get_preferred_object_type( $property ) {
	if ( ! self::property_expects_object( $property ) ) {
		return null;
	}

	$range = self::get_property_range( $property );

	// Filter out primitive types
	$object_types = array_diff( $range, self::$primitive_types );

	// Return first object type
	return ! empty( $object_types ) ? reset( $object_types ) : null;
}