1 | <?php |
||
22 | class Field extends Base |
||
23 | { |
||
24 | /** |
||
25 | * @var number[] |
||
26 | */ |
||
27 | private $groups; |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | 6 | public function getRecordDefinition(Model $record): array |
|
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 3 | public function saveRecord(Model $record, array $definition): bool |
|
53 | { |
||
54 | 3 | if (array_key_exists('group', $definition)) { |
|
55 | 3 | $record->groupId = $this->getGroupIdByName($definition['group']); |
|
56 | } |
||
57 | |||
58 | return Craft::$app->fields->saveField($record); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 5 | public function deleteRecord(Model $record): bool |
|
68 | |||
69 | /** |
||
70 | * Get group id by name. |
||
71 | * |
||
72 | * @param string $name |
||
73 | * |
||
74 | * @return int|null |
||
75 | */ |
||
76 | 3 | private function getGroupIdByName(string $name) |
|
97 | |||
98 | /** |
||
99 | * Reset craft fields service groups cache using reflection. |
||
100 | */ |
||
101 | 3 | private function resetCraftFieldsServiceGroupsCache() |
|
109 | } |
||
110 |