1 | <?php |
||
20 | class TableMultilanguageField extends Widget |
||
21 | { |
||
22 | /** |
||
23 | * Field name. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | public $name; |
||
28 | |||
29 | /** |
||
30 | * Field label. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | public $label; |
||
35 | |||
36 | /** |
||
37 | * The model of the current field. |
||
38 | * |
||
39 | * @var Model |
||
40 | */ |
||
41 | public $model; |
||
42 | |||
43 | /** |
||
44 | * Model of languages. |
||
45 | * |
||
46 | * @var LanguageFieldInterface |
||
47 | */ |
||
48 | protected $language; |
||
49 | |||
50 | /** |
||
51 | * The value of the empty field is the default. |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | public $default = '-'; |
||
56 | |||
57 | /** |
||
58 | * Set the language model. |
||
59 | * |
||
60 | * @param LanguageFieldInterface $language |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | public function setLanguage(LanguageFieldInterface $language): void |
||
68 | |||
69 | /** |
||
70 | * Returns the translation of the field. |
||
71 | * |
||
72 | * @throws InvalidConfigException |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | public function run(): string |
||
92 | |||
93 | /** |
||
94 | * Obtaining a field translation of another model along a given path through a series |
||
95 | * of entities, separated by a point. |
||
96 | * |
||
97 | * @param $name string, separated by dot. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | private function getDataByPath($name): string |
||
122 | } |
||
123 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: