src/Entity/Catalog.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\CatalogRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\UX\Turbo\Attribute\Broadcast;
  10. #[ORM\Entity(repositoryClassCatalogRepository::class)]
  11. #[Broadcast]
  12. #[ApiResource]
  13. class Catalog
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255)]
  20.     private ?string $name null;
  21.     #[ORM\Column(typeTypes::TEXT)]
  22.     private ?string $description null;
  23.     #[ORM\ManyToOne(inversedBy'catalogs')]
  24.     private ?Portal $portal null;
  25.     #[ORM\ManyToMany(targetEntityCourse::class, mappedBy'catalog')]
  26.     private Collection $courses;
  27.     #[ORM\OneToMany(mappedBy'catalog'targetEntityCourseLicense::class)]
  28.     private Collection $courseLicenses;
  29.     public function __construct()
  30.     {
  31.         $this->courses = new ArrayCollection();
  32.         $this->setDescription('Beschreibung');
  33.         $this->courseLicenses = new ArrayCollection();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function __toString(): string
  40.     {
  41.         return $this->name;
  42.     }
  43.     public function getName(): ?string
  44.     {
  45.         return $this->name;
  46.     }
  47.     public function setName(string $name): self
  48.     {
  49.         $this->name $name;
  50.         return $this;
  51.     }
  52.     public function getDescription(): ?string
  53.     {
  54.         return $this->description;
  55.     }
  56.     public function setDescription(string $description): self
  57.     {
  58.         $this->description $description;
  59.         return $this;
  60.     }
  61.     public function getPortal(): ?Portal
  62.     {
  63.         return $this->portal;
  64.     }
  65.     public function setPortal(?Portal $portal): self
  66.     {
  67.         $this->portal $portal;
  68.         return $this;
  69.     }
  70.     /**
  71.      * @return Collection<int, Course>
  72.      */
  73.     public function getCourses(): Collection
  74.     {
  75.         return $this->courses;
  76.     }
  77.     public function addCourse(Course $course): self
  78.     {
  79.         if (!$this->courses->contains($course)) {
  80.             $this->courses->add($course);
  81.             $course->addCatalog($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeCourse(Course $course): self
  86.     {
  87.         if ($this->courses->removeElement($course)) {
  88.             $course->removeCatalog($this);
  89.         }
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return Collection<int, CourseLicense>
  94.      */
  95.     public function getCourseLicenses(): Collection
  96.     {
  97.         return $this->courseLicenses;
  98.     }
  99.     public function addCourseLicense(CourseLicense $courseLicense): self
  100.     {
  101.         if (!$this->courseLicenses->contains($courseLicense)) {
  102.             $this->courseLicenses->add($courseLicense);
  103.             $courseLicense->setCatalog($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function removeCourseLicense(CourseLicense $courseLicense): self
  108.     {
  109.         if ($this->courseLicenses->removeElement($courseLicense)) {
  110.             // set the owning side to null (unless already changed)
  111.             if ($courseLicense->getCatalog() === $this) {
  112.                 $courseLicense->setCatalog(null);
  113.             }
  114.         }
  115.         return $this;
  116.     }
  117. }