WC_API_Server::error_to_array()
Convert an error to an array
This iterates over all error codes and messages to change it into a flat array. This enables simpler client behaviour, as it is represented as a list in JSON rather than an object/map
Метод класса: WC_API_Server{}
Хуков нет.
Возвращает
Массив
. List of associative arrays with code and message keys
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->error_to_array( $error );
- $error(WP_Error) (обязательный)
- -
Список изменений
С версии 2.1 | Введена. |
Код WC_API_Server::error_to_array() WC API Server::error to array WC 8.1.1
protected function error_to_array( $error ) { $errors = array(); foreach ( (array) $error->errors as $code => $messages ) { foreach ( (array) $messages as $message ) { $errors[] = array( 'code' => $code, 'message' => $message ); } } return array( 'errors' => $errors ); }