@@ -484,8 +484,8 @@ discard block |
||
| 484 | 484 | public function rules() |
| 485 | 485 | { |
| 486 | 486 | return [ |
| 487 | - ['id', function () { |
|
| 488 | - $this->id = (string)$this->id; |
|
| 487 | + ['id', function() { |
|
| 488 | + $this->id = (string) $this->id; |
|
| 489 | 489 | return true; |
| 490 | 490 | }], |
| 491 | 491 | ['id', 'required'], |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | |
| 499 | 499 | ['categoryId', 'required'], |
| 500 | 500 | ['categoryId', 'number', 'min' => 1], |
| 501 | - ['categoryId', function () { |
|
| 501 | + ['categoryId', function() { |
|
| 502 | 502 | if (strlen($this->categoryId) > 18) { |
| 503 | 503 | return false; |
| 504 | 504 | }; |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | ['oldprice', 'safe'], |
| 525 | 525 | // В <oldprice> указывается старая цена товара, которая должна быть обязательно выше новой цены (<price>). |
| 526 | 526 | // Скидка может показываться в процентах. |
| 527 | - ['oldprice', 'compare', 'compareAttribute' => 'price', 'operator' => '>', 'type' => 'number', 'when' => function (self $model) { |
|
| 527 | + ['oldprice', 'compare', 'compareAttribute' => 'price', 'operator' => '>', 'type' => 'number', 'when' => function(self $model) { |
|
| 528 | 528 | return strpos($this->oldprice, '%') === false; |
| 529 | 529 | }], |
| 530 | 530 | |
@@ -539,36 +539,36 @@ discard block |
||
| 539 | 539 | [['available', 'store', 'pickup', 'delivery', 'downloadable', 'adult', 'cpa'], 'boolean'], |
| 540 | 540 | // Булево должно быть преобразовано к строке "true"/"false" |
| 541 | 541 | // https://yandex.ru/support/partnermarket/elements/id-type-available.xml |
| 542 | - [['available', 'store', 'pickup', 'delivery', 'downloadable', 'adult', 'cpa'], function ($attribute) { |
|
| 542 | + [['available', 'store', 'pickup', 'delivery', 'downloadable', 'adult', 'cpa'], function($attribute) { |
|
| 543 | 543 | $this->$attribute = $this->$attribute ? 'true' : 'false'; |
| 544 | - }, 'when' => function ($model, $attribute) { |
|
| 544 | + }, 'when' => function($model, $attribute) { |
|
| 545 | 545 | /** @var $model self */ |
| 546 | 546 | return is_bool($model->$attribute); |
| 547 | 547 | }], |
| 548 | 548 | |
| 549 | 549 | ['barcode', 'safe'], |
| 550 | 550 | |
| 551 | - ['picture', 'string', 'max' => 512, 'when' => function ($model) { |
|
| 551 | + ['picture', 'string', 'max' => 512, 'when' => function($model) { |
|
| 552 | 552 | /** @var $model self */ |
| 553 | 553 | return is_string($model->picture); |
| 554 | 554 | }], |
| 555 | - ['picture', 'each', 'rule' => ['string', 'max' => 512], 'when' => function ($model) { |
|
| 555 | + ['picture', 'each', 'rule' => ['string', 'max' => 512], 'when' => function($model) { |
|
| 556 | 556 | /** @var $model self */ |
| 557 | 557 | return is_array($model->picture); |
| 558 | 558 | }], |
| 559 | - ['picture', function () { |
|
| 559 | + ['picture', function() { |
|
| 560 | 560 | if (count($this->picture) > 10) { |
| 561 | - $this->addError('Offer can contain maximum 10 pictures, ' . count($this->picture) . ' included'); |
|
| 561 | + $this->addError('Offer can contain maximum 10 pictures, '.count($this->picture).' included'); |
|
| 562 | 562 | return; |
| 563 | 563 | } |
| 564 | - }, 'when' => function ($model) { |
|
| 564 | + }, 'when' => function($model) { |
|
| 565 | 565 | /** @var self $model */ |
| 566 | 566 | return is_array($model->picture); |
| 567 | 567 | }], |
| 568 | 568 | |
| 569 | - ['rec', function () { |
|
| 569 | + ['rec', function() { |
|
| 570 | 570 | $this->rec = implode(',', $this->rec); |
| 571 | - }, 'when' => function (self $model) { |
|
| 571 | + }, 'when' => function(self $model) { |
|
| 572 | 572 | return is_array($model->rec); |
| 573 | 573 | }], |
| 574 | 574 | ['rec', 'string'], |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | return; |
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | - }, 'when' => function ($model) { |
|
| 587 | + }, 'when' => function($model) { |
|
| 588 | 588 | return !empty($model); |
| 589 | 589 | }] |
| 590 | 590 | ]; |