|
|
@@ -506,46 +506,6 @@ class Utils |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function duplicateEntity($entity){ |
|
|
|
$newEntity = clone $entity ; |
|
|
|
|
|
|
|
if($newEntity instanceof ImageInterface){ |
|
|
|
$this->duplicateImage($entity); |
|
|
|
$newEntity->setImage(null); |
|
|
|
} |
|
|
|
|
|
|
|
if($newEntity instanceof ProductFamilyInterface){ |
|
|
|
$this->productFamilyUtils->processBeforePersistProductFamily($newEntity); |
|
|
|
} |
|
|
|
|
|
|
|
$this->em->persist($newEntity) ; |
|
|
|
$this->em->flush(); |
|
|
|
|
|
|
|
return $newEntity; |
|
|
|
} |
|
|
|
|
|
|
|
public function duplicateImage($entity, $folder = false){ |
|
|
|
$basePath = $this->parameterBag->get('kernel.project_dir').'/public/uploads/images/' ; |
|
|
|
|
|
|
|
|
|
|
|
if($entity->getImage() && file_exists($basePath.$entity->getImage())) { |
|
|
|
dump(pathinfo($basePath.$entity->getImage())); |
|
|
|
} |
|
|
|
die(); |
|
|
|
|
|
|
|
|
|
|
|
$newImage = md5(uniqid()).'.jpg'; |
|
|
|
if($folder) $newImage = $folder.'/'.$newImage; |
|
|
|
|
|
|
|
if($entity->getImage() && file_exists($basePath.$entity->getImage())) { |
|
|
|
copy($basePath.$entity->getImage(), $basePath . $newImage); |
|
|
|
$entity->setImage($newImage); |
|
|
|
}else{ |
|
|
|
$entity->setImage(null); |
|
|
|
} |
|
|
|
return $entity; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |