Yoast\WP\SEO\AI\Content_Planner\Application
Content_Outline_Command_Handler::build_outline
Builds a list of outline sections from the API response.
Метод класса: Content_Outline_Command_Handler{}
Хуков нет.
Возвращает
Section_List. The list of outline sections.
Использование
// private - только в коде основоного (родительского) класса $result = $this->build_outline( $response ): Section_List;
- $response(Response) (обязательный)
- The API response.
Код Content_Outline_Command_Handler::build_outline() Content Outline Command Handler::build outline Yoast 27.7
private function build_outline( Response $response ): Section_List {
$section_list = new Section_List();
$json = \json_decode( $response->get_body() );
if ( $json === null || ! isset( $json->choices ) ) {
return $section_list;
}
foreach ( $json->choices as $choice ) {
$section_list->add(
new Section(
( $choice->content_notes ?? [] ),
( $choice->subheading_text ?? null ),
),
);
}
return $section_list;
}