]> _ Git - cubist_cms-back.git/commitdiff
wait #5040
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 3 Mar 2022 19:14:19 +0000 (20:14 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 3 Mar 2022 19:14:19 +0000 (20:14 +0100)
src/app/Magic/Models/CubistMagicAbstractModel.php

index d787671a19633683cedcc737a8273e7dcd7edc2a..151162bdc7a9166d81bbb18a354a6d97f4360443 100644 (file)
@@ -48,7 +48,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
 
     public $registerMediaConversionsUsingModelInstance = true;
 
-    protected static $_doctrineTypesMapping = ['int' => 'integer','longtext'=>'text'];
+    protected static $_doctrineTypesMapping = ['int' => 'integer', 'longtext' => 'text'];
 
     protected $connection = null;
     protected $primaryKey = 'id';
@@ -750,6 +750,11 @@ class CubistMagicAbstractModel extends Model implements HasMedia
         return $f->filterValue($value);
     }
 
+    protected function _randCollectionName($fieldname)
+    {
+        return str_replace('e', 'a', substr(hash('sha256', uniqid($fieldname, true)), 0, 10));
+    }
+
     /**
      * @param string $fieldname
      * @param string|\Symfony\Component\HttpFoundation\File\UploadedFile $filepath
@@ -767,7 +772,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
             if ($field->getAttribute('name_as_collection', false)) {
                 $collection = $fieldname;
             } else {
-                $collection = substr(hash('sha256', uniqid($fieldname, true)), 0, 10);
+                $collection = $this->_randCollectionName($fieldname);
             }
             $this->setAttribute($fieldname, $collection);
             $save = true;