1 | <?php |
||
12 | class Entry_Sort { |
||
13 | |||
14 | /** |
||
15 | * @var string An enum of sorts, sort direction identifier - ascending. |
||
16 | */ |
||
17 | const ASC = 'ASC'; |
||
18 | |||
19 | /** |
||
20 | * @var string An enum of sorts, sort direction identifier - descending. |
||
21 | */ |
||
22 | const DESC = 'DESC'; |
||
23 | |||
24 | /** |
||
25 | * @var string An enum of sorts, sort direction identifier - random. |
||
26 | */ |
||
27 | const RAND = 'RAND'; |
||
28 | |||
29 | /** |
||
30 | * @var string Numeric sort mode. |
||
31 | */ |
||
32 | const NUMERIC = 'NUMERIC'; |
||
33 | |||
34 | /** |
||
35 | * @var string Alpabetic sort mode. |
||
36 | */ |
||
37 | const ALPHA = 'ALPHA'; |
||
38 | |||
39 | /** |
||
40 | * @var \GV\Field The field that this sort is for. |
||
41 | */ |
||
42 | public $field; |
||
43 | |||
44 | /** |
||
45 | * @var string The direction (see self::ASC, self::DESC). |
||
46 | */ |
||
47 | public $direction; |
||
48 | |||
49 | /** |
||
50 | * @var string The sort mode (see self::NUMERIC, self::ALPHA). |
||
51 | */ |
||
52 | public $mode; |
||
53 | |||
54 | /** |
||
55 | * Instantiate a sort for a field. |
||
56 | * |
||
57 | * @param \GV\Field $field The field we're sorting by. |
||
58 | * @param string $direction The direction of this sort (\GV\Entry_Sort::ASC, \GV\Entry_Sort::DESC, etc.). Default: self::ASC. |
||
59 | * @param string $mode The sort mode (self::NUMERIC). Default: self::ALPHA. |
||
60 | * |
||
61 | * @api |
||
62 | * @since 2.0 |
||
63 | * |
||
64 | * @return \GV\Entry_Sort An instance of this class, pass to \GV\Entry_Collection::sort() |
||
|
|||
65 | */ |
||
66 | 9 | public function __construct( \GV\Field $field, $direction = self::ASC, $mode = self::ALPHA ) { |
|
67 | 9 | $this->field = $field; |
|
68 | 9 | $this->direction = $direction; |
|
69 | 9 | $this->mode = $mode; |
|
70 | 9 | } |
|
71 | |||
72 | /** |
||
73 | * Return search_criteria-compatible array. |
||
74 | * |
||
75 | * @return array [`key`, `direction`, `is_numeric`] |
||
76 | */ |
||
77 | public function to_sorting() { |
||
87 | } |
||
88 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.