src/Entity/Program.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProgramRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="programme")
  9.  * @ORM\Entity(repositoryClass=ProgramRepository::class)
  10.  */
  11. class Program
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $name;
  23.     /**
  24.      * @ORM\OneToMany(targetEntity=Section::class, mappedBy="program")
  25.      */
  26.     private $sections;
  27.     public function __construct()
  28.     {
  29.         $this->sections = new ArrayCollection();
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getName(): ?string
  36.     {
  37.         return $this->name;
  38.     }
  39.     public function setName(string $name): self
  40.     {
  41.         $this->name $name;
  42.         return $this;
  43.     }
  44.     public function __toString() {
  45.         $name = ( is_null($this->getName())) ? "" $this->getName();
  46.         return (string) ($name );
  47.     }
  48.     /**
  49.      * @return Collection|Section[]
  50.      */
  51.     public function getSections(): Collection
  52.     {
  53.         return $this->sections;
  54.     }
  55.     public function addSection(Section $section): self
  56.     {
  57.         if (!$this->sections->contains($section)) {
  58.             $this->sections[] = $section;
  59.             $section->setProgram($this);
  60.         }
  61.         return $this;
  62.     }
  63.     public function removeSection(Section $section): self
  64.     {
  65.         if ($this->sections->removeElement($section)) {
  66.             // set the owning side to null (unless already changed)
  67.             if ($section->getProgram() === $this) {
  68.                 $section->setProgram(null);
  69.             }
  70.         }
  71.         return $this;
  72.     }
  73. }