1 | <?php |
||
24 | class YmlCatalog extends Object |
||
25 | { |
||
26 | /** |
||
27 | * @var BaseFileStream |
||
28 | */ |
||
29 | public $handle; |
||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | public $shopClass; |
||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | public $currencyClass; |
||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | public $categoryClass; |
||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | public $offerClass; |
||
46 | /** |
||
47 | * @var null|string |
||
48 | */ |
||
49 | public $date; |
||
50 | |||
51 | /** |
||
52 | * @var null|callable |
||
53 | */ |
||
54 | public $onValidationError; |
||
55 | |||
56 | /** |
||
57 | * @var null|string |
||
58 | */ |
||
59 | public $customOfferClass; |
||
60 | |||
61 | /** |
||
62 | * @var null|string |
||
63 | */ |
||
64 | public $deliveryOptionClass; |
||
65 | |||
66 | /** |
||
67 | * @return null|string |
||
68 | */ |
||
69 | protected function getFormattedDate() |
||
79 | |||
80 | /** |
||
81 | * @throws Exception |
||
82 | 9 | */ |
|
83 | 9 | public function generate() |
|
106 | 9 | ||
107 | 9 | /** |
|
108 | 9 | * @param string $string |
|
109 | 9 | * @throws \Exception |
|
110 | 9 | */ |
|
111 | 9 | protected function write($string) |
|
115 | 9 | ||
116 | 9 | /** |
|
117 | 9 | * @param string $string tag name |
|
118 | 4 | */ |
|
119 | 6 | protected function writeTag($string) |
|
123 | 6 | ||
124 | /** |
||
125 | * @param BaseModel $model |
||
126 | * @param $valuesModel |
||
127 | * @throws Exception |
||
128 | 9 | */ |
|
129 | protected function writeModel(BaseModel $model, $valuesModel) |
||
136 | 9 | ||
137 | protected function writeTags($tags) |
||
154 | 9 | ||
155 | /** |
||
156 | * @param string|array $modelClass class name or yii configuration array. You can also set params: |
||
157 | * `findParams`: array of additional find params; |
||
158 | * `query`: ActiveQuery object to generate yml use already created object; |
||
159 | * `dataProvider`: ActiveDataProvider or true to generate yml with pagination; |
||
160 | */ |
||
161 | 9 | protected function writeEachModel($modelClass) |
|
218 | |||
219 | 9 | // /** |
|
220 | // * @param string|array $modelClass class name or yii configuration array. You can also set params: |
||
221 | 9 | // * `findParams`: array of additional find params; |
|
222 | 9 | // * `query`: ActiveQuery object to generate yml use already created object; |
|
223 | 6 | // * `dataProvider`: ActiveDataProvider or true to generate yml with pagination; |
|
224 | 9 | // */ |
|
225 | 9 | // protected function writeEachModel($modelClass) |
|
226 | 3 | // { |
|
227 | 3 | // /** |
|
228 | 6 | // * @var mixed |
|
229 | 6 | // */ |
|
230 | 4 | // $findParams = []; |
|
231 | // if (is_array($modelClass)) { |
||
232 | // if (array_key_exists('findParams', $modelClass)) { |
||
233 | // $findParams = $modelClass['findParams']; |
||
234 | 9 | // unset($modelClass['findParams']); |
|
235 | // } |
||
236 | // |
||
237 | // $modelClass = $modelClass['class']; |
||
238 | // } |
||
239 | // |
||
240 | // $interfaces = class_implements($modelClass); |
||
241 | // if (!isset($interfaces[ActiveRecordInterface::class])) { |
||
242 | // return $this->writeModel($this->getNewModel($modelClass), \Yii::createObject($modelClass)); |
||
243 | // } |
||
244 | // |
||
245 | // /* @var \yii\db\ActiveQuery $query */ |
||
246 | // $query = $modelClass::findYml($findParams); |
||
247 | // |
||
248 | // $newModel = $this->getNewModel($modelClass); |
||
249 | // foreach ($query->batch(100) as $models) { |
||
250 | //// |
||
251 | //// /** |
||
252 | //// * @var ActiveQuery |
||
253 | //// */ |
||
254 | //// $query = null; |
||
255 | //// |
||
256 | //// /** |
||
257 | //// * @var ActiveDataProvider |
||
258 | //// */ |
||
259 | //// $dataProvider = null; |
||
260 | //// |
||
261 | //// if (is_array($modelClass)) { |
||
262 | //// foreach (['findParams', 'query', 'dataProvider'] as $name) { |
||
263 | //// if (array_key_exists($name, $modelClass)) { |
||
264 | //// $$name = $modelClass[$name]; |
||
265 | //// unset($modelClass[$name]); |
||
266 | //// } |
||
267 | //// } |
||
268 | //// } |
||
269 | //// |
||
270 | //// /** |
||
271 | //// * @var BaseFindYmlInterface $class |
||
272 | //// */ |
||
273 | //// $class = \Yii::createObject($modelClass); |
||
274 | //// |
||
275 | //// /** |
||
276 | //// * @var ReaderInterface |
||
277 | //// */ |
||
278 | //// $reader = ReaderFactory::build( |
||
279 | //// $class, |
||
280 | //// $dataProvider, |
||
281 | //// $query, |
||
282 | //// $findParams |
||
283 | //// ); |
||
284 | //// |
||
285 | //// $newModel = $this->getNewModel($class); |
||
286 | //// |
||
287 | //// foreach ($reader as $models) { |
||
288 | // foreach ($models as $model) { |
||
289 | // $this->writeModel($newModel, $model); |
||
290 | // } |
||
291 | // $this->gc(); |
||
292 | // } |
||
293 | // } |
||
294 | |||
295 | /** |
||
296 | * @param $modelClass |
||
297 | * @return Category|Currency|SimpleOffer |
||
298 | * @throws Exception |
||
299 | */ |
||
300 | protected function getNewModel($modelClass) |
||
308 | |||
309 | /** |
||
310 | * Performs PHP memory garbage collection. |
||
311 | */ |
||
312 | protected function gc() |
||
319 | } |
||
320 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.