|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Application\Api\Output; |
|
6
|
|
|
|
|
7
|
|
|
use Application\Model\Order; |
|
8
|
|
|
use Application\Model\OrderLine; |
|
9
|
|
|
use GraphQL\Type\Definition\Type; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Create a Pagination type for the entity extracted from name. |
|
13
|
|
|
* |
|
14
|
|
|
* For example, if given "ActionPagination", it will create a Pagination |
|
15
|
|
|
* type for the Action entity. |
|
16
|
|
|
*/ |
|
17
|
|
|
class PaginationTypeFactory extends \Ecodev\Felix\Api\Output\PaginationTypeFactory |
|
18
|
|
|
{ |
|
19
|
1 |
|
protected function getExtraFields(string $class): array |
|
20
|
|
|
{ |
|
21
|
1 |
|
$fields = []; |
|
22
|
|
|
// Add specific total fields if needed |
|
23
|
1 |
|
if ($class === OrderLine::class) { |
|
24
|
1 |
|
$fields['totalBalanceCHF'] = [ |
|
25
|
1 |
|
'type' => _types()->get('CHF'), |
|
26
|
1 |
|
'description' => 'The total balance', |
|
27
|
1 |
|
]; |
|
28
|
1 |
|
$fields['totalBalanceEUR'] = [ |
|
29
|
1 |
|
'type' => _types()->get('EUR'), |
|
30
|
1 |
|
'description' => 'The total balance', |
|
31
|
1 |
|
]; |
|
32
|
1 |
|
$fields['totalQuantity'] = [ |
|
33
|
1 |
|
'type' => Type::int(), |
|
34
|
1 |
|
'description' => 'The total quantity', |
|
35
|
1 |
|
]; |
|
36
|
1 |
|
} elseif ($class === Order::class) { |
|
37
|
1 |
|
$fields['totalBalanceCHF'] = [ |
|
38
|
1 |
|
'type' => _types()->get('CHF'), |
|
39
|
1 |
|
'description' => 'The total balance', |
|
40
|
1 |
|
]; |
|
41
|
1 |
|
$fields['totalBalanceEUR'] = [ |
|
42
|
1 |
|
'type' => _types()->get('EUR'), |
|
43
|
1 |
|
'description' => 'The total balance', |
|
44
|
1 |
|
]; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
1 |
|
return $fields; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|