1
|
|
|
<?php |
2
|
|
|
namespace keeko\core\serializer\base; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
*/ |
6
|
|
|
trait CountrySerializerTrait { |
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_2' => $model->Alpha2(), |
17
|
|
|
'alpha_3' => $model->Alpha3(), |
18
|
|
|
'short_name' => $model->ShortName(), |
19
|
|
|
'ioc' => $model->Ioc(), |
20
|
|
|
'tld' => $model->Tld(), |
21
|
|
|
'phone' => $model->Phone(), |
22
|
|
|
'capital' => $model->Capital(), |
23
|
|
|
'postal_code_format' => $model->PostalCodeFormat(), |
24
|
|
|
'postal_code_regex' => $model->PostalCodeRegex(), |
25
|
|
|
'continent_id' => $model->ContinentId(), |
26
|
|
|
'currency_id' => $model->CurrencyId(), |
27
|
|
|
'type_id' => $model->TypeId(), |
28
|
|
|
'subtype_id' => $model->SubtypeId(), |
29
|
|
|
'sovereignity_id' => $model->SovereignityId(), |
30
|
|
|
'formal_name' => $model->FormalName(), |
31
|
|
|
'formal_native_name' => $model->FormalNativeName(), |
32
|
|
|
'short_native_name' => $model->ShortNativeName(), |
33
|
|
|
'bbox_sw_lat' => $model->BboxSwLat(), |
34
|
|
|
'bbox_sw_lng' => $model->BboxSwLng(), |
35
|
|
|
'bbox_ne_lat' => $model->BboxNeLat(), |
36
|
|
|
'bbox_ne_lng' => $model->BboxNeLng(), |
37
|
|
|
]; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
*/ |
42
|
|
|
public function getFields() { |
43
|
|
|
return ['id', 'numeric', 'alpha_2', 'alpha_3', 'short_name', 'ioc', 'tld', 'phone', 'capital', 'postal_code_format', 'postal_code_regex', 'continent_id', 'currency_id', 'type_id', 'subtype_id', 'sovereignity_id', 'formal_name', 'formal_native_name', 'short_native_name', 'bbox_sw_lat', 'bbox_sw_lng', 'bbox_ne_lat', 'bbox_ne_lng']; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param mixed $model |
48
|
|
|
*/ |
49
|
|
|
public function getId($model) { |
|
|
|
|
50
|
|
|
return $model->getId(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
*/ |
55
|
|
|
public function getSortFields() { |
56
|
|
|
return ['id', 'numeric', 'alpha_2', 'alpha_3', 'short_name', 'ioc', 'tld', 'phone', 'capital', 'postal_code_format', 'postal_code_regex', 'continent_id', 'currency_id', 'type_id', 'subtype_id', 'sovereignity_id', 'formal_name', 'formal_native_name', 'short_native_name', 'bbox_sw_lat', 'bbox_sw_lng', 'bbox_ne_lat', 'bbox_ne_lng']; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param mixed $model |
61
|
|
|
*/ |
62
|
|
|
public function getType($model) { |
|
|
|
|
63
|
|
|
return 'core/country'; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param mixed $model |
68
|
|
|
* @param mixed $data |
69
|
|
|
*/ |
70
|
|
|
public function hydrate($model, $data) { |
|
|
|
|
71
|
|
|
// this model is read-only! |
72
|
|
|
return $model; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.