From 9ae4e4ea78f9c4020cf389d2535d2c1e17b81a2f Mon Sep 17 00:00:00 2001 From: maxdancepro <31630905+maxdancepro@users.noreply.github.com> Date: Tue, 4 Jun 2019 00:39:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D1=87=D0=B0=20=D1=83=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавлена возможность удаления файла по переданному названию --- src/Behavior.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Behavior.php b/src/Behavior.php index f9e3f83..c3b3146 100644 --- a/src/Behavior.php +++ b/src/Behavior.php @@ -78,6 +78,8 @@ class Behavior extends \yii\base\Behavior */ public $urlPrefix; + public $deleteFileName; + /** * @inheritdoc */ @@ -370,7 +372,11 @@ private function deleteFiles($attr) if ($model->isNewRecord) { $value = $model->{$attr}; } else { - $value = $model->oldAttributes[$attr]; + if (isset($this->deleteFileName)) { + $value = $this->deleteFileName; + } else { + $value = $model->oldAttributes[$attr]; + } } $file = $base . $value;