PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.6
28.6 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 All 130 releases
wordpress-seo / src / dashboard / application / search-rankings / top-page-repository.php

top-page-repository.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.6, at src/dashboard/application/search-rankings/top-page-repository.php

76 lines 2.6 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\Dashboard\Application\Search_Rankings;
5
6 use Yoast\WP\SEO\Dashboard\Domain\Data_Provider\Dashboard_Repository_Interface;
7 use Yoast\WP\SEO\Dashboard\Domain\Data_Provider\Data_Container;
8 use Yoast\WP\SEO\Dashboard\Domain\Data_Provider\Parameters;
9 use Yoast\WP\SEO\Dashboard\Domain\Time_Based_Seo_Metrics\Data_Source_Not_Available_Exception;
10 use Yoast\WP\SEO\Dashboard\Infrastructure\Indexables\Top_Page_Indexable_Collector;
11 use Yoast\WP\SEO\Dashboard\Infrastructure\Integrations\Site_Kit;
12 use Yoast\WP\SEO\Dashboard\Infrastructure\Search_Console\Site_Kit_Search_Console_Adapter;
13
14 /**
15 * The data provider for top page data.
16 */
17 class Top_Page_Repository implements Dashboard_Repository_Interface {
18
19 /**
20 * The adapter.
21 *
22 * @var Site_Kit_Search_Console_Adapter
23 */
24 private $site_kit_search_console_adapter;
25
26 /**
27 * The top page indexable collector.
28 *
29 * @var Top_Page_Indexable_Collector
30 */
31 private $top_page_indexable_collector;
32
33 /**
34 * The site kit configuration object.
35 *
36 * @var Site_Kit
37 */
38 private $site_kit_configuration;
39
40 /**
41 * The constructor.
42 *
43 * @param Site_Kit_Search_Console_Adapter $site_kit_search_console_adapter The adapter.
44 * @param Top_Page_Indexable_Collector $top_page_indexable_collector The top page indexable collector.
45 * @param Site_Kit $site_kit_configuration The site kit configuration object.
46 */
47 public function __construct(
48 Site_Kit_Search_Console_Adapter $site_kit_search_console_adapter,
49 Top_Page_Indexable_Collector $top_page_indexable_collector,
50 Site_Kit $site_kit_configuration
51 ) {
52 $this->site_kit_search_console_adapter = $site_kit_search_console_adapter;
53 $this->top_page_indexable_collector = $top_page_indexable_collector;
54 $this->site_kit_configuration = $site_kit_configuration;
55 }
56
57 /**
58 * Gets the top pages' data.
59 *
60 * @param Parameters $parameters The parameter to use for getting the top pages.
61 *
62 * @return Data_Container
63 *
64 * @throws Data_Source_Not_Available_Exception When this repository is used without the needed prerequisites ready.
65 */
66 public function get_data( Parameters $parameters ): Data_Container {
67 if ( ! $this->site_kit_configuration->is_onboarded() ) {
68 throw new Data_Source_Not_Available_Exception( 'Top page repository' );
69 }
70 $top_pages_search_ranking_data = $this->site_kit_search_console_adapter->get_data( $parameters );
71 $top_pages_full_data = $this->top_page_indexable_collector->get_data( $top_pages_search_ranking_data );
72
73 return $top_pages_full_data;
74 }
75 }
76