<?php
namespace App\Entity;
use App\Repository\SectionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="section")
* @ORM\Entity(repositoryClass=SectionRepository::class)
*/
class Section
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Program::class, inversedBy="sections")
* @ORM\JoinColumn(name="programme_id", referencedColumnName="id", nullable=false)
*/
private $program;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=Cycle::class, mappedBy="section")
*/
private $cycles;
public function __construct()
{
$this->cycles = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getProgram(): ?Program
{
return $this->program;
}
public function setProgram(?Program $program): self
{
$this->program = $program;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function __toString() {
$name = ( is_null($this->getName())) ? "" : $this->getName();
$programme = ( is_null($this->getProgram())) ? "" : $this->getProgram();
return (string) ($programme."/".$name );
}
/**
* @return Collection|Cycle[]
*/
public function getCycles(): Collection
{
return $this->cycles;
}
public function addCycle(Cycle $cycle): self
{
if (!$this->cycles->contains($cycle)) {
$this->cycles[] = $cycle;
$cycle->setSection($this);
}
return $this;
}
public function removeCycle(Cycle $cycle): self
{
if ($this->cycles->removeElement($cycle)) {
// set the owning side to null (unless already changed)
if ($cycle->getSection() === $this) {
$cycle->setSection(null);
}
}
return $this;
}
}