| 1 |
<?php |
| 2 |
/** |
| 3 |
* Term catalog proxy behavior (categories, tags, brands). |
| 4 |
* |
| 5 |
* @package WCPOS\WooCommercePOS\API\V2\Proxy |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WCPOS\WooCommercePOS\API\V2\Proxy; |
| 9 |
|
| 10 |
/** |
| 11 |
* Pins the stable name-sort tiebreak during the forward. |
| 12 |
* |
| 13 |
* The POS client's term lanes default to name ascending (mono#1371) and walk |
| 14 |
* multi-page windows; see {@see Stable_Sort} for why ties need a secondary key. |
| 15 |
*/ |
| 16 |
final class Terms_Proxy_Behavior extends Scoped_Proxy_Behavior { |
| 17 |
/** |
| 18 |
* Install this resource's hooks and return their removal tuples. |
| 19 |
* |
| 20 |
* @return array<int, array{0: string, 1: callable, 2: int}> |
| 21 |
*/ |
| 22 |
protected function install(): array { |
| 23 |
$filter = static function ( $clauses ) { |
| 24 |
return Stable_Sort::with_term_id_tiebreak( (array) $clauses ); |
| 25 |
}; |
| 26 |
add_filter( 'terms_clauses', $filter ); |
| 27 |
|
| 28 |
return array( array( 'terms_clauses', $filter, 10 ) ); |
| 29 |
} |
| 30 |
} |
| 31 |
|