Example #1
0
 public function testRemoveTag()
 {
     $tag1 = $this->dummyData->getTag();
     $tag2 = $this->dummyData->getTag();
     $product = new Product();
     $product->addTag($tag1);
     $product->addTag($tag2);
     $this->assertSame(2, count($product->getTags()));
     $product->removeTag($tag2);
     $this->assertSame(1, count($product->getTags()));
 }
 public function isTagValid(Product $product)
 {
     if ($this->tag === null) {
         return true;
     }
     foreach ($product->getTags() as $tag) {
         if ($tag->getId() !== null and $tag->getId() == $this->tag->getId()) {
             return true;
         }
     }
     return false;
 }
 /**
  * @return static
  */
 public function withImages()
 {
     foreach ($this->entity->getImages() as $image) {
         $this->entityDTO->images[] = $this->dtoBuilderFactory->getImageDTOBuilder($image)->build();
     }
     foreach ($this->entity->getTags() as $tag) {
         foreach ($tag->getImages() as $image) {
             $this->entityDTO->tagImages[] = $this->dtoBuilderFactory->getImageDTOBuilder($image)->build();
         }
     }
     return $this;
 }