|
1
|
|
|
<?php |
|
2
|
|
|
namespace keeko\core\serializer\base; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
*/ |
|
6
|
|
|
trait CurrencySerializerTrait { |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @param mixed $model |
|
10
|
|
|
* @param array $fields |
|
11
|
|
|
*/ |
|
12
|
|
|
public function getAttributes($model, array $fields = null) { |
|
|
|
|
|
|
13
|
|
|
return [ |
|
14
|
|
|
'id' => $model->Id(), |
|
15
|
|
|
'numeric' => $model->Numeric(), |
|
16
|
|
|
'alpha_3' => $model->Alpha3(), |
|
17
|
|
|
'name' => $model->Name(), |
|
18
|
|
|
'symbol_left' => $model->SymbolLeft(), |
|
19
|
|
|
'symbol_right' => $model->SymbolRight(), |
|
20
|
|
|
'decimal_digits' => $model->DecimalDigits(), |
|
21
|
|
|
'sub_divisor' => $model->SubDivisor(), |
|
22
|
|
|
'sub_symbol_left' => $model->SubSymbolLeft(), |
|
23
|
|
|
'sub_symbol_right' => $model->SubSymbolRight(), |
|
24
|
|
|
]; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
*/ |
|
29
|
|
|
public function getFields() { |
|
30
|
|
|
return ['id', 'numeric', 'alpha_3', 'name', 'symbol_left', 'symbol_right', 'decimal_digits', 'sub_divisor', 'sub_symbol_left', 'sub_symbol_right']; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param mixed $model |
|
35
|
|
|
*/ |
|
36
|
|
|
public function getId($model) { |
|
|
|
|
|
|
37
|
|
|
return $model->getId(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
*/ |
|
42
|
|
|
public function getSortFields() { |
|
43
|
|
|
return ['id', 'numeric', 'alpha_3', 'name', 'symbol_left', 'symbol_right', 'decimal_digits', 'sub_divisor', 'sub_symbol_left', 'sub_symbol_right']; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param mixed $model |
|
48
|
|
|
*/ |
|
49
|
|
|
public function getType($model) { |
|
|
|
|
|
|
50
|
|
|
return 'core/currency'; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param mixed $model |
|
55
|
|
|
* @param mixed $data |
|
56
|
|
|
*/ |
|
57
|
|
|
public function hydrate($model, $data) { |
|
|
|
|
|
|
58
|
|
|
// this model is read-only! |
|
59
|
|
|
return $model; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.