Yoast\WP\SEO\AI_Generator\Application
Suggestions_Provider::build_suggestions_array
Generates the list of 5 suggestions to return.
Метод класса: Suggestions_Provider{}
Хуков нет.
Возвращает
Suggestions_Bucket. The array of suggestions.
Использование
$Suggestions_Provider = new Suggestions_Provider(); $Suggestions_Provider->build_suggestions_array( $response ): Suggestions_Bucket;
- $response(Response) (обязательный)
- The response from the API.
Код Suggestions_Provider::build_suggestions_array() Suggestions Provider::build suggestions array Yoast 27.7
public function build_suggestions_array( Response $response ): Suggestions_Bucket {
$suggestions_bucket = new Suggestions_Bucket();
$json = \json_decode( $response->get_body() );
if ( $json === null || ! isset( $json->choices ) ) {
return $suggestions_bucket;
}
foreach ( $json->choices as $suggestion ) {
$suggestions_bucket->add_suggestion( new Suggestion( $suggestion->text ) );
}
return $suggestions_bucket;
}