PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.4
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 / schema-aggregator / infrastructure / indexable-repository / indexable-repository-factory.php

indexable-repository-factory.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.4, at src/schema-aggregator/infrastructure/indexable-repository/indexable-repository-factory.php

53 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3 namespace Yoast\WP\SEO\Schema_Aggregator\Infrastructure\Indexable_Repository;
4
5 /**
6 * Factory for creating indexable repositories based on availability.
7 */
8 class Indexable_Repository_Factory {
9
10 /**
11 * The native indexable repository.
12 *
13 * @var Indexable_Repository
14 */
15 private $native_repository;
16
17 /**
18 * The WordPress indexable repository.
19 *
20 * @var WordPress_Query_Repository
21 */
22 private $wordpress_repository;
23
24 /**
25 * Constructor.
26 *
27 * @param Indexable_Repository $native_repository The native indexable repository.
28 * @param WordPress_Query_Repository $wordpress_repository The WordPress indexable repository.
29 */
30 public function __construct(
31 Indexable_Repository $native_repository,
32 WordPress_Query_Repository $wordpress_repository
33 ) {
34 $this->native_repository = $native_repository;
35 $this->wordpress_repository = $wordpress_repository;
36 }
37
38 /**
39 * Gets the appropriate indexable repository based on availability.
40 *
41 * @param bool $indexables_available Whether native indexables are available.
42 *
43 * @return Indexable_Repository_Interface The selected indexable repository.
44 */
45 public function get_repository( bool $indexables_available ): Indexable_Repository_Interface {
46 if ( $indexables_available ) {
47 return $this->native_repository;
48 }
49
50 return $this->wordpress_repository;
51 }
52 }
53