These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Itstructure\FieldWidgets; |
||
4 | |||
5 | use yii\base\{Model, Widget, InvalidConfigException}; |
||
6 | use Itstructure\FieldWidgets\interfaces\LanguageListInterface; |
||
7 | |||
8 | /** |
||
9 | * Class TableMultilanguage |
||
10 | * The output widget class for each specified translation list field. |
||
11 | * |
||
12 | * @property LanguageListInterface $languageModel |
||
13 | * @property array $fields |
||
14 | * @property Model $model |
||
15 | * |
||
16 | * @package Itstructure\FieldWidgets |
||
17 | */ |
||
18 | class TableMultilanguage extends Widget |
||
19 | { |
||
20 | /** |
||
21 | * Language model. |
||
22 | * For multilanguage mode. |
||
23 | * |
||
24 | * @var LanguageListInterface |
||
25 | */ |
||
26 | private $languageModel; |
||
27 | |||
28 | /** |
||
29 | * Field list |
||
30 | * For each field, you must specify its name: name. Optional parameter: label. |
||
31 | * To get the value of a field from other parts, you need to specify the path with the combination of entities through the point. |
||
32 | * Example: |
||
33 | * fields => [ |
||
34 | * [ |
||
35 | * 'name' => 'id', |
||
36 | * 'label' => 'Name', |
||
37 | * ], |
||
38 | * [ |
||
39 | * 'name' => 'title', |
||
40 | * 'label' => 'Title', |
||
41 | * ], |
||
42 | * [ |
||
43 | * 'name' => 'posts.tag', |
||
44 | * 'label' => 'Post tags', |
||
45 | * ] |
||
46 | * ]; |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | public $fields = []; |
||
51 | |||
52 | /** |
||
53 | * Model for current fields. |
||
54 | * |
||
55 | * @var Model |
||
56 | */ |
||
57 | private $model; |
||
58 | |||
59 | /** |
||
60 | * Sets the language model. |
||
61 | * |
||
62 | * @param mixed $languageModel |
||
63 | * |
||
64 | * @return void |
||
65 | */ |
||
66 | public function setLanguageModel(LanguageListInterface $languageModel): void |
||
67 | { |
||
68 | $this->languageModel = $languageModel; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Sets the model of the current fields. |
||
73 | * |
||
74 | * @param Model $model |
||
75 | * |
||
76 | * @return void |
||
77 | */ |
||
78 | public function setModel(Model $model): void |
||
79 | { |
||
80 | $this->model = $model; |
||
0 ignored issues
–
show
|
|||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Starts output for each specified field of the translation list. |
||
85 | * |
||
86 | * @throws InvalidConfigException |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | public function run(): string |
||
91 | { |
||
92 | if (null === $this->languageModel) { |
||
93 | throw new InvalidConfigException('Language model is not defined.'); |
||
94 | } |
||
95 | |||
96 | return $this->render('tableMultilanguage', [ |
||
97 | 'languageModel' => $this->languageModel, |
||
98 | 'fields' => $this->fields, |
||
99 | 'model' => $this->model, |
||
100 | ]); |
||
101 | } |
||
102 | } |
||
103 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..