public function testUnsupportedAttachments() { $entity = new TestClass(); $this->attachmentConfig->expects($this->once())->method('isAttachmentAssociationEnabled')->with($entity)->willReturn(false); $result = $this->attachmentProvider->getEntityAttachments($entity); $this->assertEquals([], $result); }
/** * @param $entity * * @return array */ public function getScopeEntityAttachments($entity) { $attachments = []; $oroAttachments = $this->attachmentProvider->getEntityAttachments($entity); foreach ($oroAttachments as $oroAttachment) { $attachments[] = $this->emailAttachmentTransformer->oroToModel($oroAttachment); } return $attachments; }
/** * @param Product $product * @param Product $productCopy */ protected function cloneChildObjects(Product $product, Product $productCopy) { foreach ($product->getUnitPrecisions() as $unitPrecision) { $productCopy->addUnitPrecision(clone $unitPrecision); } if ($imageFile = $product->getImage()) { $imageFileCopy = $this->attachmentManager->copyAttachmentFile($imageFile); $productCopy->setImage($imageFileCopy); } $attachments = $this->attachmentProvider->getEntityAttachments($product); foreach ($attachments as $attachment) { $attachmentCopy = clone $attachment; $attachmentFileCopy = $this->attachmentManager->copyAttachmentFile($attachment->getFile()); $attachmentCopy->setFile($attachmentFileCopy); $attachmentCopy->setTarget($productCopy); $this->doctrineHelper->getEntityManager($attachmentCopy)->persist($attachmentCopy); } }