Strategy.php
790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace ACP\Sorting;
abstract class Strategy
{
protected $model;
public function __construct(AbstractModel $model)
{
$this->model = $model;
}
abstract public function manage_sorting(): void;
/**
* Add the meta query for sorting to an existing meta query
*/
protected static function add_meta_query(array $sorting_meta_query, array $meta_query): array
{
if (empty($meta_query)) {
return $sorting_meta_query;
}
$meta_query['relation'] = 'AND';
$meta_query[] = $sorting_meta_query;
return $meta_query;
}
/**
* Check if a key is a universal id
*/
protected static function is_universal_id(string $key): bool
{
return 'ids' === $key;
}
}