|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: execut |
|
5
|
|
|
* Date: 12/19/17 |
|
6
|
|
|
* Time: 5:51 PM |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace execut\import\example\withRelations; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
use execut\import\example\models\Article; |
|
13
|
|
|
use execut\import\example\models\Brand; |
|
14
|
|
|
use execut\import\example\models\Product; |
|
15
|
|
|
use execut\import\models\File; |
|
16
|
|
|
use execut\navigation\Component; |
|
17
|
|
|
|
|
18
|
|
|
class Plugin implements \execut\import\Plugin |
|
19
|
|
|
{ |
|
20
|
|
|
public function getDictionaries() { |
|
21
|
|
|
return [ |
|
22
|
|
|
'example_product_id' => Product::find(), |
|
23
|
|
|
'example_article_id' => Article::find(), |
|
24
|
|
|
'example_brand_id' => Brand::find(), |
|
25
|
|
|
]; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Возвращает настройки парсеров моделей |
|
30
|
|
|
* |
|
31
|
|
|
* @return array |
|
32
|
|
|
*/ |
|
33
|
|
|
public function getParsersByTypesSettings() { |
|
34
|
|
|
$queries = $this->getDictionaries(); |
|
35
|
|
|
return [ |
|
36
|
|
|
'example_product_id' => [ |
|
37
|
|
|
'example_brand_id' => [ |
|
38
|
|
|
'isNoUpdate' => true, |
|
39
|
|
|
'query' => $queries['example_brand_id'], |
|
40
|
|
|
'attributes' => [ |
|
41
|
|
|
'name' => [ |
|
42
|
|
|
'isFind' => true, |
|
43
|
|
|
], |
|
44
|
|
|
], |
|
45
|
|
|
], |
|
46
|
|
|
'example_article_id' => [ |
|
47
|
|
|
'isImport' => true, |
|
48
|
|
|
'isNoUpdate' => true, |
|
49
|
|
|
'query' => $queries['example_article_id'], |
|
50
|
|
|
'attributes' => [ |
|
51
|
|
|
'article' => [ |
|
52
|
|
|
'key' => 'article', |
|
53
|
|
|
'isFind' => true, |
|
54
|
|
|
], |
|
55
|
|
|
'example_brand_id' => [ |
|
56
|
|
|
'isFind' => true, |
|
57
|
|
|
], |
|
58
|
|
|
], |
|
59
|
|
|
], |
|
60
|
|
|
'example_product_id' => [ |
|
61
|
|
|
'isImport' => true, |
|
62
|
|
|
'isDelete' => true, |
|
63
|
|
|
'query' => $queries['example_product_id'], |
|
64
|
|
|
'attributes' => [ |
|
65
|
|
|
'name' => [ |
|
66
|
|
|
'key' => 'name', |
|
67
|
|
|
'isFind' => false, |
|
68
|
|
|
], |
|
69
|
|
|
'price' => [ |
|
70
|
|
|
'key' => 'price', |
|
71
|
|
|
'isFind' => false, |
|
72
|
|
|
], |
|
73
|
|
|
'price' => [ |
|
74
|
|
|
'key' => 'price', |
|
75
|
|
|
'isFind' => false, |
|
76
|
|
|
], |
|
77
|
|
|
'example_article_id' => [ |
|
78
|
|
|
'isFind' => true, |
|
79
|
|
|
], |
|
80
|
|
|
], |
|
81
|
|
|
], |
|
82
|
|
|
], |
|
83
|
|
|
]; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Список искомых записей на одну строчку |
|
88
|
|
|
* |
|
89
|
|
|
* @return array |
|
90
|
|
|
*/ |
|
91
|
|
|
public function getAttributesSetsTypesList() { |
|
92
|
|
|
return [ |
|
93
|
|
|
'example_product_id' => 'Product', |
|
94
|
|
|
]; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Список возможных значений настроек |
|
99
|
|
|
* |
|
100
|
|
|
* @return array |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getAttributesValuesTypesList() { |
|
103
|
|
|
return [ |
|
104
|
|
|
'example_product_id.price' => 'Product price', |
|
105
|
|
|
'example_product_id.name' => 'Product name', |
|
106
|
|
|
'example_article_id.article' => 'Article', |
|
107
|
|
|
'example_brand_id.name' => 'Brand', |
|
108
|
|
|
]; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Список обязательных значений настроек |
|
113
|
|
|
* |
|
114
|
|
|
* @return array |
|
115
|
|
|
*/ |
|
116
|
|
|
public function getRequiredAttributesByTypes() { |
|
117
|
|
|
return [ |
|
118
|
|
|
'example_product_id' => [ |
|
119
|
|
|
'example_product_id.name', |
|
120
|
|
|
'example_product_id.price', |
|
121
|
|
|
'example_article_id.article', |
|
122
|
|
|
'example_brand_id.name', |
|
123
|
|
|
], |
|
124
|
|
|
]; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Удаляет привязанные к файлу импорта записи |
|
129
|
|
|
*/ |
|
130
|
|
|
public function deleteRelatedRecords(File $importFile) { |
|
|
|
|
|
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
public function getAllowedRoles() { |
|
134
|
|
|
return []; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function getFilesCrudFieldsPlugins() { |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
public function getSettingsCrudFieldsPlugins() { |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
public function getSettingsSheetsCrudFieldsPlugins() { |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
public function bootstrapNavigation(Component $navigation) { |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Удаляет привязанные к файлу импорта записи |
|
151
|
|
|
*/ |
|
152
|
|
|
public function getOldIdsByFile(File $importFile) |
|
153
|
|
|
{ |
|
154
|
|
|
return Product::find()->select('id')->column(); |
|
155
|
|
|
} |
|
156
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.