WP_CLI
Formatter::show_table
Show items in a \cli\Table.
Метод класса: Formatter{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = Formatter::show_table( $items, $fields, $ascii_pre_colorized );
- $items(массив) (обязательный)
- .
- $fields(массив) (обязательный)
- .
- $ascii_pre_colorized(true|false|массив)
- A boolean or an array of booleans to pass to
Table::setAsciiPreColorized()if items in the table are pre-colorized.
По умолчанию:false
Код Formatter::show_table() Formatter::show table WP-CLI 2.13.0-alpha
private static function show_table( $items, $fields, $ascii_pre_colorized = false ) {
$table = new Table();
$enabled = WP_CLI::get_runner()->in_color();
if ( $enabled ) {
Colors::disable( true );
}
$table->setAsciiPreColorized( $ascii_pre_colorized );
$table->setHeaders( $fields );
foreach ( $items as $item ) {
$table->addRow( array_values( Utils\pick_fields( $item, $fields ) ) );
}
foreach ( $table->getDisplayLines() as $line ) {
WP_CLI::line( $line );
}
if ( $enabled ) {
Colors::enable( true );
}
}