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.

Method of the class: Connection{}

No Hooks.

Returns

self. A Connection marked as already sliced.

Usage

$result = Connection::pre_sliced( $edges, $page_info, $total_count ): self;
$edges(Edge[]) (required)
The already-paginated edges.
$page_info(PageInfo) (required)
The pagination info.
$total_count(int) (required)
The total count before pagination.

Connection::pre_sliced() code WC 10.9.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;
}