ninenote/src/ninenote-1.0/src/Entity/Period.php

179 lines
3.8 KiB
PHP

<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* Period
*
* @ORM\Entity(repositoryClass="App\Repository\PeriodRepository")
* @ORM\Table(name="period",uniqueConstraints={@ORM\UniqueConstraint(name="unique01", columns={"year_id","name"})})
* @UniqueEntity(fields={"year","name"}, message="Cette période existe déjà")
*/
class Period
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(name="name", type="string")
*
*/
private $name;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $datestart;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateend;
/**
* @ORM\ManyToOne(targetEntity="Year", inversedBy="periods")
*/
private $year;
/**
* @ORM\OneToMany(targetEntity="Control", mappedBy="period")
*/
private $controls;
/**
* @ORM\OneToMany(targetEntity="Report", mappedBy="period")
*/
private $reports;
public function __construct()
{
$this->controls = new ArrayCollection();
$this->reports = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDatestart(): ?\DateTimeInterface
{
return $this->datestart;
}
public function setDatestart(?\DateTimeInterface $datestart): self
{
$this->datestart = $datestart;
return $this;
}
public function getDateend(): ?\DateTimeInterface
{
return $this->dateend;
}
public function setDateend(?\DateTimeInterface $dateend): self
{
$this->dateend = $dateend;
return $this;
}
public function getYear(): ?Year
{
return $this->year;
}
public function setYear(?Year $year): self
{
$this->year = $year;
return $this;
}
/**
* @return Collection|Control[]
*/
public function getControls(): Collection
{
return $this->controls;
}
public function addControl(Control $control): self
{
if (!$this->controls->contains($control)) {
$this->controls[] = $control;
$control->setPeriod($this);
}
return $this;
}
public function removeControl(Control $control): self
{
if ($this->controls->contains($control)) {
$this->controls->removeElement($control);
// set the owning side to null (unless already changed)
if ($control->getPeriod() === $this) {
$control->setPeriod(null);
}
}
return $this;
}
/**
* @return Collection|Report[]
*/
public function getReports(): Collection
{
return $this->reports;
}
public function addReport(Report $report): self
{
if (!$this->reports->contains($report)) {
$this->reports[] = $report;
$report->setPeriod($this);
}
return $this;
}
public function removeReport(Report $report): self
{
if ($this->reports->contains($report)) {
$this->reports->removeElement($report);
// set the owning side to null (unless already changed)
if ($report->getPeriod() === $this) {
$report->setPeriod(null);
}
}
return $this;
}
}