PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / schema-aggregator / application / aggregate-site-schema-command-handler.php

aggregate-site-schema-command-handler.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/schema-aggregator/application/aggregate-site-schema-command-handler.php

70 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
4 namespace Yoast\WP\SEO\Schema_Aggregator\Application;
5
6 use Yoast\WP\SEO\Schema_Aggregator\Domain\Schema_Piece_Repository_Interface;
7
8 /**
9 * Class that handles the Aggregate_Site_Schema_Command.
10 */
11 class Aggregate_Site_Schema_Command_Handler {
12
13 /**
14 * The Schema_Piece_Repository instance.
15 *
16 * @var Schema_Piece_Repository_Interface
17 */
18 private $schema_piece_repository;
19
20 /**
21 * The Schema_Pieces_Aggregator instance.
22 *
23 * @var Schema_Pieces_Aggregator
24 */
25 private $schema_piece_aggregator;
26
27 /**
28 * The Schema_Aggregator_Response_Composer instance.
29 *
30 * @var Schema_Aggregator_Response_Composer
31 */
32 private $schema_response_composer;
33
34 /**
35 * Aggregate_Site_Schema_Command_Handler constructor.
36 *
37 * @param Schema_Piece_Repository_Interface $schema_piece_repository The collector of indexables that need to be aggregated.
38 * @param Schema_Pieces_Aggregator $schema_piece_aggregator The schema pieces aggregator.
39 * @param Schema_Aggregator_Response_Composer $schema_response_composer The schema response composer.
40 */
41 public function __construct(
42 Schema_Piece_Repository_Interface $schema_piece_repository,
43 Schema_Pieces_Aggregator $schema_piece_aggregator,
44 Schema_Aggregator_Response_Composer $schema_response_composer
45 ) {
46 $this->schema_piece_repository = $schema_piece_repository;
47 $this->schema_piece_aggregator = $schema_piece_aggregator;
48 $this->schema_response_composer = $schema_response_composer;
49 }
50
51 /**
52 * Handles the Aggregate_Site_Schema_Command.
53 *
54 * @param Aggregate_Site_Schema_Command $command The command.
55 *
56 * @return array<string> The aggregated schema.
57 */
58 public function handle( Aggregate_Site_Schema_Command $command ): array {
59
60 $schema_pieces = $this->schema_piece_repository->get(
61 $command->get_page_controls()->get_page(),
62 $command->get_page_controls()->get_page_size(),
63 $command->get_page_controls()->get_post_type(),
64 );
65
66 $aggregated_schema_pieces = $this->schema_piece_aggregator->aggregate( $schema_pieces );
67 return $this->schema_response_composer->compose( $aggregated_schema_pieces );
68 }
69 }
70