src/Entity/CategoryGroup.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JMS\Serializer\Annotation\Groups;
  7. /**
  8.  * @ORM\Table("CategoryGroup")
  9.  *
  10.  * @ORM\Entity(repositoryClass="App\Repository\CategoryGroupRepository")
  11.  */
  12. class CategoryGroup
  13. {
  14.     /**
  15.      * @Groups({"categorylist", "video_search", "imageset_search"})
  16.      *
  17.      * @ORM\Id()
  18.      *
  19.      * @ORM\GeneratedValue(strategy="AUTO")
  20.      *
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @Groups({"categorylist", "video_search", "imageset_search"})
  26.      *
  27.      * @ORM\Column(type="string", length=100)
  28.      */
  29.     private $name;
  30.     /**
  31.      * @Groups({"categorylist", "video_search", "imageset_search"})
  32.      *
  33.      * @ORM\Column(type="string", length=100)
  34.      */
  35.     private $slug;
  36.     /**
  37.      * @Groups({"categorylist"})
  38.      *
  39.      * @ORM\OrderBy({"sorting": "ASC", "name": "ASC"})
  40.      *
  41.      * @ORM\OneToMany(targetEntity="App\Entity\Category", mappedBy="group", orphanRemoval=true)
  42.      */
  43.     private $categories;
  44.     /**
  45.      * @Groups({"categorylist"})
  46.      *
  47.      * @ORM\Column(type="integer")
  48.      */
  49.     private $sorting 0;
  50.     /**
  51.      * @Groups({"categorylist"})
  52.      *
  53.      * @ORM\Column(type="string", length=100, unique=true, nullable=true)
  54.      */
  55.     private $filename;
  56.     /**
  57.      * @Groups({"categorylist"})
  58.      */
  59.     private ?string $imageUrl null;
  60.     public function __construct()
  61.     {
  62.         $this->categories = new ArrayCollection();
  63.     }
  64.     public function getId(): ?int
  65.     {
  66.         return $this->id;
  67.     }
  68.     public function getName(): ?string
  69.     {
  70.         return $this->name;
  71.     }
  72.     public function setName(string $name): self
  73.     {
  74.         $this->name $name;
  75.         return $this;
  76.     }
  77.     public function getSlug(): ?string
  78.     {
  79.         return $this->slug;
  80.     }
  81.     public function setSlug(string $slug): self
  82.     {
  83.         $this->slug $slug;
  84.         return $this;
  85.     }
  86.     /**
  87.      * @return Collection|Category[]
  88.      */
  89.     public function getCategories(): Collection
  90.     {
  91.         return $this->categories;
  92.     }
  93.     public function addCategory(Category $category): self
  94.     {
  95.         if (!$this->categories->contains($category)) {
  96.             $this->categories[] = $category;
  97.             $category->setGroupId($this);
  98.         }
  99.         return $this;
  100.     }
  101.     public function removeCategory(Category $category): self
  102.     {
  103.         if ($this->categories->contains($category)) {
  104.             $this->categories->removeElement($category);
  105.             // set the owning side to null (unless already changed)
  106.             if ($category->getGroupId() === $this) {
  107.                 $category->setGroupId(null);
  108.             }
  109.         }
  110.         return $this;
  111.     }
  112.     public function getSorting(): int
  113.     {
  114.         return $this->sorting;
  115.     }
  116.     public function setSorting(int $sorting): self
  117.     {
  118.         $this->sorting $sorting;
  119.         return $this;
  120.     }
  121.     public function getFilename(): ?string
  122.     {
  123.         return $this->filename;
  124.     }
  125.     public function setFilename(string $filename): self
  126.     {
  127.         $this->filename $filename;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return Category
  132.      */
  133.     public function setImageUrl(string $url): self
  134.     {
  135.         $this->imageUrl $url;
  136.         return $this;
  137.     }
  138.     public function getImageUrl(): ?string
  139.     {
  140.         return $this->imageUrl;
  141.     }
  142. }