UserOrder.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\ListScreenRepository\Sort; |
| 6 | |
| 7 | use AC\Storage\Repository\ListScreenOrder; |
| 8 | use AC\Storage\Repository\TableListOrder; |
| 9 | use AC\Type\TableId; |
| 10 | use WP_User; |
| 11 | |
| 12 | class UserOrder extends ListIds |
| 13 | { |
| 14 | public function __construct(WP_User $user, TableId $table_id) |
| 15 | { |
| 16 | parent::__construct($this->get_manual_sorted_list_ids($user, $table_id)); |
| 17 | } |
| 18 | |
| 19 | private function get_manual_sorted_list_ids(WP_User $user, TableId $table_id): array |
| 20 | { |
| 21 | $list_order_user = (new TableListOrder($user->ID))->get_order($table_id); |
| 22 | $list_order = (new ListScreenOrder())->get($table_id); |
| 23 | |
| 24 | return array_unique(array_merge($list_order_user, $list_order)); |
| 25 | } |
| 26 | } |
| 27 |