From b1fd461b958f2bbc9444a57e7fa75f71b2770f42 Mon Sep 17 00:00:00 2001 From: "lauris@weberp.lv" Date: Thu, 29 Apr 2021 03:28:58 +0300 Subject: [PATCH] D3Files component - copyFilesBetweenModels bugfix --- components/D3Files.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/D3Files.php b/components/D3Files.php index ea4946d..340be02 100755 --- a/components/D3Files.php +++ b/components/D3Files.php @@ -197,9 +197,10 @@ public static function uploadModelFile(ActiveRecord $model, string $className, */ public static function copyFilesBetweenModels(ActiveRecord $modelFrom, ActiveRecord $modelTo, ?string $modelFromClass = null) { - $modelName = $modelFromClass ?? get_class($modelFrom); + $modelFromName = $modelFromClass ?? get_class($modelFrom); + $modelToName = get_class($modelTo); - $modelFiles = ModelD3Files::getRecordFilesList($modelName, $modelFrom->id); + $modelFiles = ModelD3Files::getRecordFilesList($modelFromName, $modelFrom->id); foreach ($modelFiles as $file) { @@ -212,14 +213,14 @@ public static function copyFilesBetweenModels(ActiveRecord $modelFrom, ActiveRec $ext = pathinfo($file['file_name'], PATHINFO_EXTENSION); - $fileTypes = self::getAllowedFileTypes($modelName); + $fileTypes = self::getAllowedFileTypes($modelToName); if (!preg_match($fileTypes, $ext)) { continue; } ModelD3Files::saveContent( $file['file_name'], - $modelName, + $modelToName, $modelTo->id, $fileContent, $fileTypes