public function addImage(Image $image) { if ($this->images->isEmpty()) { $this->setDefaultImage($image->getPath()); } $image->setTag($this); $this->images->add($image); }
/** * @return static */ public function withTag() { $tag = $this->entity->getTag(); if (!empty($tag)) { $this->entityDTO->tag = $this->dtoBuilderFactory->getTagDTOBuilder($tag)->build(); } return $this; }
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); }
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()); }
public function getImage() { $image = new Image(); $image->setPath('http://lorempixel.com/400/200/'); $image->setWidth(400); $image->setHeight(200); $image->setSortOrder(0); return $image; }