1
|
|
|
<?php |
2
|
|
|
namespace keeko\core\serializer\base; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
*/ |
6
|
|
|
trait LanguageSerializerTrait { |
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
|
|
|
'alpha_2' => $model->Alpha2(), |
16
|
|
|
'alpha_3T' => $model->Alpha3T(), |
17
|
|
|
'alpha_3B' => $model->Alpha3B(), |
18
|
|
|
'alpha_3' => $model->Alpha3(), |
19
|
|
|
'parent_id' => $model->ParentId(), |
20
|
|
|
'macrolanguage_status' => $model->MacrolanguageStatus(), |
21
|
|
|
'name' => $model->Name(), |
22
|
|
|
'native_name' => $model->NativeName(), |
23
|
|
|
'collate' => $model->Collate(), |
24
|
|
|
'subtag' => $model->Subtag(), |
25
|
|
|
'prefix' => $model->Prefix(), |
26
|
|
|
'scope_id' => $model->ScopeId(), |
27
|
|
|
'type_id' => $model->TypeId(), |
28
|
|
|
'family_id' => $model->FamilyId(), |
29
|
|
|
'default_script_id' => $model->DefaultScriptId(), |
30
|
|
|
]; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
*/ |
35
|
|
|
public function getFields() { |
36
|
|
|
return ['id', 'alpha_2', 'alpha_3T', 'alpha_3B', 'alpha_3', 'parent_id', 'macrolanguage_status', 'name', 'native_name', 'collate', 'subtag', 'prefix', 'scope_id', 'type_id', 'family_id', 'default_script_id']; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param mixed $model |
41
|
|
|
*/ |
42
|
|
|
public function getId($model) { |
|
|
|
|
43
|
|
|
return $model->getId(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
*/ |
48
|
|
|
public function getSortFields() { |
49
|
|
|
return ['id', 'alpha_2', 'alpha_3T', 'alpha_3B', 'alpha_3', 'parent_id', 'macrolanguage_status', 'name', 'native_name', 'collate', 'subtag', 'prefix', 'scope_id', 'type_id', 'family_id', 'default_script_id']; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param mixed $model |
54
|
|
|
*/ |
55
|
|
|
public function getType($model) { |
|
|
|
|
56
|
|
|
return 'core/language'; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param mixed $model |
61
|
|
|
* @param mixed $data |
62
|
|
|
*/ |
63
|
|
|
public function hydrate($model, $data) { |
|
|
|
|
64
|
|
|
// this model is read-only! |
65
|
|
|
return $model; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.