Automattic\WooCommerce\Api\Pagination

Connection::pre_slicedpublic staticWC 1.0

Create a pre-sliced connection for the performance path.

Use this when the DB query already applied pagination limits, so no further slicing is needed.

Метод класса: Connection{}

Хуков нет.

Возвращает

self. A Connection marked as already sliced.

Использование

$result = Connection::pre_sliced( $edges, $page_info, $total_count ): self;
$edges(Edge[]) (обязательный)
The already-paginated edges.
$page_info(PageInfo) (обязательный)
The pagination info.
$total_count(int) (обязательный)
The total count before pagination.

Код Connection::pre_sliced() WC 11.0.1

public static function pre_sliced( array $edges, PageInfo $page_info, int $total_count ): self {
	$connection              = new self();
	$connection->edges       = $edges;
	$connection->nodes       = array_map( fn( Edge $e ) => $e->node, $edges );
	$connection->page_info   = $page_info;
	$connection->total_count = $total_count;
	$connection->sliced      = true;

	return $connection;
}