Yoast\WP\SEO\Schema_Aggregator\Application

Schema_Pieces_Aggregator::aggregatepublicYoast 1.0

Main orchestrator method: deduplicates, merges and filter properties.

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

Хуков нет.

Возвращает

Schema_Piece_Collection. The aggregated schema pieces.

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

$Schema_Pieces_Aggregator = new Schema_Pieces_Aggregator();
$Schema_Pieces_Aggregator->aggregate( $schema_pieces ): Schema_Piece_Collection;
$schema_pieces(Schema_Piece_Collection) (обязательный)
The schema pieces to aggregate.

Код Schema_Pieces_Aggregator::aggregate() Yoast 27.7

public function aggregate( Schema_Piece_Collection $schema_pieces ): Schema_Piece_Collection {
	$aggregated_schema = [];

	$filtering_strategy     = $this->filtering_strategy_factory->create();
	$filtered_schema_pieces = $filtering_strategy->filter( $schema_pieces );

	foreach ( $filtered_schema_pieces->to_array() as $piece ) {

		$id = $piece->get_id();
		if ( \is_null( $id ) ) {
			continue;
		}

		if ( isset( $aggregated_schema[ $id ] ) ) {
			$aggregated_schema[ $id ] = $this->properties_merger->merge( $aggregated_schema[ $id ], $piece );
		}
		else {
			// Add new piece.
			$aggregated_schema[ $id ] = $piece;
		}
	}

	// Return only the values to get rid of the keys (which are @id) and wrap in a collection.
	return new Schema_Piece_Collection( \array_values( $aggregated_schema ) );
}