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 / llms-txt / application / available-posts / available-posts-repository.php

available-posts-repository.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/llms-txt/application/available-posts/available-posts-repository.php

54 lines 1.8 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\Llms_Txt\Application\Available_Posts;
5
6 use Yoast\WP\SEO\Llms_Txt\Domain\Available_Posts\Data_Provider\Available_Posts_Data;
7 use Yoast\WP\SEO\Llms_Txt\Domain\Available_Posts\Data_Provider\Available_Posts_Repository_Interface;
8 use Yoast\WP\SEO\Llms_Txt\Domain\Available_Posts\Data_Provider\Data_Container;
9 use Yoast\WP\SEO\Llms_Txt\Domain\Available_Posts\Data_Provider\Parameters;
10 use Yoast\WP\SEO\Llms_Txt\Infrastructure\Content\Automatic_Post_Collection;
11
12 /**
13 * The data provider for available posts.
14 */
15 class Available_Posts_Repository implements Available_Posts_Repository_Interface {
16
17 /**
18 * The automatic post collection.
19 *
20 * @var Automatic_Post_Collection $automatic_post_collection
21 */
22 private $automatic_post_collection;
23
24 /**
25 * The constructor.
26 *
27 * @param Automatic_Post_Collection $automatic_post_collection The automatic post collection.
28 */
29 public function __construct(
30 Automatic_Post_Collection $automatic_post_collection
31 ) {
32 $this->automatic_post_collection = $automatic_post_collection;
33 }
34
35 /**
36 * Gets the available posts' data.
37 *
38 * @param Parameters $parameters The parameters to use for getting the available posts.
39 *
40 * @return Data_Container
41 */
42 public function get_posts( Parameters $parameters ): Data_Container {
43 $available_posts = $this->automatic_post_collection->get_recent_posts( $parameters->get_post_type(), 100, $parameters->get_search_filter(), true );
44
45 $available_posts_data_container = new Data_Container();
46
47 foreach ( $available_posts as $available_post ) {
48 $available_posts_data_container->add_data( new Available_Posts_Data( $available_post ) );
49 }
50
51 return $available_posts_data_container;
52 }
53 }
54