src/Entity/PointsCatalog/CatalogSizeGroup.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity\PointsCatalog;
  3. use App\Annotation\SiteAware;
  4. use App\Entity\AbstractBase;
  5. use App\Entity\Interfaces\SiteInterface;
  6. use App\Entity\MiniAbstractBase;
  7. use App\Entity\Traits\NameTrait;
  8. use App\Entity\Traits\PublishedTrait;
  9. use App\Entity\Traits\SiteTrait;
  10. use App\Repository\PointsCatalog\CatalogSizeGroupRepository;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Gedmo\Mapping\Annotation as Gedmo;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. /**
  17.  * @ORM\Table(name="vulco_points_catalog_size_group", indexes={@ORM\Index(name="catalog_size_group_site_idx", columns={"site"})})
  18.  * @ORM\Entity(repositoryClass=CatalogSizeGroupRepository::class)
  19.  * @Gedmo\SoftDeleteable(fieldName="removedAt", timeAware=false)
  20.  * @SiteAware(siteFieldName="site")
  21.  */
  22. class CatalogSizeGroup extends AbstractBase implements SiteInterface
  23. {
  24.     use NameTrait;
  25.     use PublishedTrait;
  26.     use SiteTrait;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      * @Assert\NotBlank()
  30.      */
  31.     private string $name;
  32.     /**
  33.      * @ORM\OneToMany(targetEntity="App\Entity\PointsCatalog\CatalogSize", mappedBy="group", cascade={"persist"}, orphanRemoval=true)
  34.      * @Assert\Valid()
  35.      */
  36.     private ?Collection $sizes;
  37.     public function __construct()
  38.     {
  39.         $this->sizes = new ArrayCollection();
  40.     }
  41.     public function getSizes(): ?Collection
  42.     {
  43.         return $this->sizes;
  44.     }
  45.     public function setSizes(?Collection $sizes): self
  46.     {
  47.         $this->sizes $sizes;
  48.         return $this;
  49.     }
  50.     public function addSize(CatalogSize $size): self
  51.     {
  52.         if (!$this->sizes->contains($size)) {
  53.             $size->setGroup($this);
  54.             $this->sizes->add($size);
  55.         }
  56.         return $this;
  57.     }
  58.     public function removeSize(CatalogSize $size): self
  59.     {
  60.         $this->sizes->removeElement($size);
  61.         return $this;
  62.     }
  63.     public function __toString(): string
  64.     {
  65.         return $this->name $this->getName() : MiniAbstractBase::DEFAULT_EMPTY_STRING;
  66.     }
  67. }