indexable_posts_collector = $indexable_posts_collector; $this->post_meta_posts_collector = $post_meta_posts_collector; $this->indexable_helper = $indexable_helper; } /** * Returns a page of posts for the given query. * * Reads from the indexable table when indexables are active, and falls back to post meta otherwise. * * @param Posts_Query $query The query describing the page to get. * * @return Posts_Page The posts together with the totals for pagination. */ public function get_posts( Posts_Query $query ): Posts_Page { if ( $this->indexable_helper->should_index_indexables() ) { return $this->indexable_posts_collector->get_posts( $query ); } return $this->post_meta_posts_collector->get_posts( $query ); } }