src/Entity/OperatorInfo.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Repository\OperatorInfoRepository;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. #[ORM\Entity(repositoryClassOperatorInfoRepository::class)]
  8. class OperatorInfo
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\Column(type'string'length255)]
  15.     private $name;
  16.     #[ORM\Column(type'text'nullabletrue)]
  17.     private $description;
  18.     #[ORM\OneToOne(targetEntityOperator::class, inversedBy'operatorInfo'cascade: ['persist''remove'])]
  19.     private $owner;
  20.     #[ORM\OneToMany(mappedBy'operator'targetEntityCourse::class)]
  21.     private Collection $associatedCourses;
  22.     public function __construct()
  23.     {
  24.         $this->associatedCourses = new ArrayCollection();
  25.     }
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     public function getName(): ?string
  31.     {
  32.         return $this->name;
  33.     }
  34.     public function setName(string $name): self
  35.     {
  36.         $this->name $name;
  37.         return $this;
  38.     }
  39.     public function getDescription(): ?string
  40.     {
  41.         return $this->description;
  42.     }
  43.     public function setDescription(?string $description): self
  44.     {
  45.         $this->description $description;
  46.         return $this;
  47.     }
  48.     public function getOwner(): ?Operator
  49.     {
  50.         return $this->owner;
  51.     }
  52.     public function setOwner(Operator $owner): self
  53.     {
  54.         $this->owner $owner;
  55.         return $this;
  56.     }
  57.     /**
  58.      * @return Collection<int, Course>
  59.      */
  60.     public function getAssociatedCourses(): Collection
  61.     {
  62.         return $this->associatedCourses;
  63.     }
  64.     public function addAssociatedCourse(Course $associatedCourse): static
  65.     {
  66.         if (!$this->associatedCourses->contains($associatedCourse)) {
  67.             $this->associatedCourses->add($associatedCourse);
  68.             $associatedCourse->setOperator($this);
  69.         }
  70.         return $this;
  71.     }
  72.     public function removeAssociatedCourse(Course $associatedCourse): static
  73.     {
  74.         if ($this->associatedCourses->removeElement($associatedCourse)) {
  75.             // set the owning side to null (unless already changed)
  76.             if ($associatedCourse->getOperator() === $this) {
  77.                 $associatedCourse->setOperator(null);
  78.             }
  79.         }
  80.         return $this;
  81.     }
  82. }