Yoast\WP\SEO\Abilities\Infrastructure

Abstract_Field_Map::resolve_fields │ private │ Yoast 1.0

Resolves the fields and their validators, once, so the schemas and the updater always agree on them.

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

Хуков нет.

Возвращает

void. Ничего (null).

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

// private - только в коде основоного (родительского) класса
$result = $this->resolve_fields(): void;

Код Abstract_Field_Map::resolve_fields() Yoast 28.9

private function resolve_fields(): void {
	if ( $this->fields !== null ) {
		return;
	}

	$default_fields = $this->get_default_fields();
	$fields         = $this->get_filtered_fields( $default_fields );

	if ( ! \is_array( $fields ) ) {
		$fields = $default_fields;
	}

	$this->fields = [];

	foreach ( $fields as $field_name => $schema ) {
		// A field without a schema can neither be described to agents nor validated, so it is dropped.
		if ( ! \is_array( $schema ) ) {
			continue;
		}

		$validator = null;
		if ( \array_key_exists( 'validate_callback', $schema ) ) {
			if ( ! \is_callable( $schema['validate_callback'] ) ) {
				continue;
			}

			$validator = $schema['validate_callback'];

			// The callback is not part of the JSON schema that is published to agents.
			unset( $schema['validate_callback'] );
		}

		$schema = $this->resolve_extra_keys( $field_name, $schema );
		if ( $schema === null ) {
			continue;
		}

		if ( $validator !== null ) {
			$this->validators[ $field_name ] = $validator;
		}

		$this->fields[ $field_name ] = $schema;
	}
}