Automattic\WooCommerce\Blueprint\ResultFormatters
JsonResultFormatter::format
Format the results.
Метод класса: JsonResultFormatter{}
Хуков нет.
Возвращает
Массив.
Использование
$JsonResultFormatter = new JsonResultFormatter(); $JsonResultFormatter->format( $message_type );
- $message_type(строка)
- The message type to format.
По умолчанию:'all'
Код JsonResultFormatter::format() JsonResultFormatter::format WC 10.7.0
public function format( $message_type = 'all' ) {
$data = array(
'is_success' => $this->is_success(),
'messages' => array(),
);
foreach ( $this->results as $result ) {
$step_name = $result->get_step_name();
foreach ( $result->get_messages( $message_type ) as $message ) {
if ( ! isset( $data['messages'][ $message['type'] ] ) ) {
$data['messages'][ $message['type'] ] = array();
}
$data['messages'][ $message['type'] ][] = array(
'step' => $step_name,
'type' => $message['type'],
'message' => $message['message'],
);
}
}
return $data;
}