1
|
|
|
<?php |
2
|
|
|
namespace keeko\core\serializer\base; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
*/ |
6
|
|
|
trait SubdivisionSerializerTrait { |
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
|
|
|
'code' => $model->Code(), |
16
|
|
|
'name' => $model->Name(), |
17
|
|
|
'native_name' => $model->NativeName(), |
18
|
|
|
'alt_names' => $model->AltNames(), |
19
|
|
|
'parent_id' => $model->ParentId(), |
20
|
|
|
'country_id' => $model->CountryId(), |
21
|
|
|
'type_id' => $model->TypeId(), |
22
|
|
|
]; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
*/ |
27
|
|
|
public function getFields() { |
28
|
|
|
return ['id', 'code', 'name', 'native_name', 'alt_names', 'parent_id', 'country_id', 'type_id']; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param mixed $model |
33
|
|
|
*/ |
34
|
|
|
public function getId($model) { |
|
|
|
|
35
|
|
|
return $model->getId(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
*/ |
40
|
|
|
public function getSortFields() { |
41
|
|
|
return ['id', 'code', 'name', 'native_name', 'alt_names', 'parent_id', 'country_id', 'type_id']; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param mixed $model |
46
|
|
|
*/ |
47
|
|
|
public function getType($model) { |
|
|
|
|
48
|
|
|
return 'core/subdivision'; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param mixed $model |
53
|
|
|
* @param mixed $data |
54
|
|
|
*/ |
55
|
|
|
public function hydrate($model, $data) { |
|
|
|
|
56
|
|
|
// this model is read-only! |
57
|
|
|
return $model; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.