@@ 16-40 (lines=25) @@ | ||
13 | * |
|
14 | * @see FilterOperation |
|
15 | */ |
|
16 | class FilterHandler extends AbstractHandler |
|
17 | { |
|
18 | use DatabaseFilterHandlerTrait; |
|
19 | ||
20 | public function getPriority() |
|
21 | { |
|
22 | return Priority::MAIN; |
|
23 | } |
|
24 | ||
25 | /** |
|
26 | * Applies operation to data source and returns modified data source. |
|
27 | * |
|
28 | * @param Builder $src |
|
29 | * @return Builder |
|
30 | */ |
|
31 | public function apply($src) |
|
32 | { |
|
33 | /** @var FilterOperation $operation */ |
|
34 | $operation = $this->operation; |
|
35 | list($operator, $value) = $this->getOperatorAndValue(); |
|
36 | $fieldName = $operation->getField(); |
|
37 | $src->where($fieldName, $operator, $value); |
|
38 | return $src; |
|
39 | } |
|
40 | } |
|
41 |
@@ 15-37 (lines=23) @@ | ||
12 | * |
|
13 | * @see SortOperation |
|
14 | */ |
|
15 | class SortHandler extends AbstractHandler |
|
16 | { |
|
17 | public function getPriority() |
|
18 | { |
|
19 | return Priority::MAIN; |
|
20 | } |
|
21 | ||
22 | /** |
|
23 | * Applies operation to data source and returns modified data source. |
|
24 | * |
|
25 | * @param Builder $src |
|
26 | * @return Builder |
|
27 | */ |
|
28 | public function apply($src) |
|
29 | { |
|
30 | /** @var SortOperation $operation */ |
|
31 | $operation = $this->operation; |
|
32 | $field = $operation->getField(); |
|
33 | $order = $operation->getOrder(); |
|
34 | $src->orderBy($field, $order); |
|
35 | return $src; |
|
36 | } |
|
37 | } |
|
38 |