Yoast\WP\SEO\AI\Content_Planner\Domain

Content_Suggestion_Response{} │ Yoast 1.0

The response to a content suggestion request, bundling suggestions with the recent content used to generate them.

Хуков нет.

Использование

$Content_Suggestion_Response = new Content_Suggestion_Response();
// use class methods

Методы

  1. public __construct( Content_Suggestion_List $suggestions, Post_List $recent_content )
  2. public get_recent_content()
  3. public get_suggestions()
  4. public to_array()

Код Content_Suggestion_Response{} Yoast 28.9

class Content_Suggestion_Response {

	/**
	 * The content suggestions.
	 *
	 * @var Content_Suggestion_List
	 */
	private $suggestions;

	/**
	 * The recent content used to generate the suggestions.
	 *
	 * @var Post_List
	 */
	private $recent_content;

	/**
	 * The constructor.
	 *
	 * @param Content_Suggestion_List $suggestions    The content suggestions.
	 * @param Post_List               $recent_content The recent content.
	 */
	public function __construct( Content_Suggestion_List $suggestions, Post_List $recent_content ) {
		$this->suggestions    = $suggestions;
		$this->recent_content = $recent_content;
	}

	/**
	 * Returns the content suggestions.
	 *
	 * @return Content_Suggestion_List The content suggestions.
	 */
	public function get_suggestions(): Content_Suggestion_List {
		return $this->suggestions;
	}

	/**
	 * Returns the recent content.
	 *
	 * @return Post_List The recent content.
	 */
	public function get_recent_content(): Post_List {
		return $this->recent_content;
	}

	/**
	 * Returns this object in array format.
	 *
	 * Uses the minimal Post representation so editor-only metadata
	 * (focus keyphrase, cornerstone flag, schema type) never crosses
	 * the REST boundary into the browser.
	 *
	 * @return array<string, array<array<string, string>>> The response as an array.
	 */
	public function to_array(): array {
		$result                   = $this->suggestions->to_array();
		$result['recent_content'] = $this->recent_content->to_minimal_array();
		return $result;
	}
}