Esempio n. 1
0
 public function addImage(Image $image)
 {
     if ($this->images->isEmpty()) {
         $this->setDefaultImage($image->getPath());
     }
     $image->setTag($this);
     $this->images->add($image);
 }
Esempio n. 2
0
 /**
  * @return static
  */
 public function withTag()
 {
     $tag = $this->entity->getTag();
     if (!empty($tag)) {
         $this->entityDTO->tag = $this->dtoBuilderFactory->getTagDTOBuilder($tag)->build();
     }
     return $this;
 }
Esempio n. 3
0
 public function createImageForTag(UploadFileDTO $uploadFileDTO, UuidInterface $tagId)
 {
     $managedFile = $this->fileManager->saveFile($uploadFileDTO->getFilePath());
     $image = new Image();
     $image->setPath($managedFile->getUri());
     $image->setWidth($managedFile->getWidth());
     $image->setHeight($managedFile->getHeight());
     $tag = $this->tagRepository->findOneById($tagId);
     $tag->addImage($image);
     $this->create($image);
 }
Esempio n. 4
0
 public function testCreate()
 {
     $product = $this->dummyData->getProduct();
     $tag = $this->dummyData->getTag();
     $image = new Image();
     $image->setPath('http://lorempixel.com/400/200/');
     $image->setWidth(400);
     $image->setHeight(200);
     $image->setSortOrder(2);
     $image->setProduct($product);
     $image->setTag($tag);
     $this->assertEntityValid($image);
     $this->assertSame('http://lorempixel.com/400/200/', $image->getPath());
     $this->assertSame(400, $image->getWidth());
     $this->assertSame(200, $image->getHeight());
     $this->assertSame(2, $image->getSortOrder());
     $this->assertSame($product, $image->getProduct());
     $this->assertSame($tag, $image->getTag());
 }
Esempio n. 5
0
 public function getImage()
 {
     $image = new Image();
     $image->setPath('http://lorempixel.com/400/200/');
     $image->setWidth(400);
     $image->setHeight(200);
     $image->setSortOrder(0);
     return $image;
 }