mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
138 lines
3.7 KiB
PHP
138 lines
3.7 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
namespace Chill\PersonBundle\Entity;
|
|
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
use Chill\PersonBundle\Entity\Person;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Annotation\Groups;
|
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
|
|
|
/**
|
|
* AccompanyingPeriodParticipation Class
|
|
*
|
|
* @package Chill\PersonBundle\Entity
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="chill_person_accompanying_period_participation")
|
|
* @DiscriminatorMap(typeProperty="type", mapping={
|
|
* "accompanying_period_participation"=AccompanyingPeriodParticipation::class
|
|
* })
|
|
*/
|
|
class AccompanyingPeriodParticipation
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
* @ORM\Column(type="integer")
|
|
* @Groups({"read"})
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations")
|
|
* @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false)
|
|
* @Groups({"read"})
|
|
*/
|
|
private $person;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"})
|
|
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
|
|
*/
|
|
private $accompanyingPeriod;
|
|
|
|
/**
|
|
* @ORM\Column(type="date", nullable=false)
|
|
* @Groups({"read"})
|
|
*/
|
|
private $startDate;
|
|
|
|
/**
|
|
* @ORM\Column(type="date", nullable=true)
|
|
* @Groups({"read"})
|
|
*/
|
|
private $endDate = null;
|
|
|
|
public function __construct(AccompanyingPeriod $accompanyingPeriod, Person $person)
|
|
{
|
|
$this->startDate = new \DateTimeImmutable('now');
|
|
$this->accompanyingPeriod = $accompanyingPeriod;
|
|
$this->person = $person;
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getPerson(): ?Person
|
|
{
|
|
return $this->person;
|
|
}
|
|
|
|
public function setPerson(?Person $person): self
|
|
{
|
|
$this->person = $person;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
|
{
|
|
return $this->accompanyingPeriod;
|
|
}
|
|
|
|
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
|
{
|
|
$this->accompanyingPeriod = $accompanyingPeriod;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getStartDate(): ?\DateTimeInterface
|
|
{
|
|
return $this->startDate;
|
|
}
|
|
|
|
/*
|
|
* public function setStartDate(\DateTimeInterface $startDate): self { $this->startDate = $startDate; return $this; }
|
|
*/
|
|
|
|
public function getEndDate(): ?\DateTimeInterface
|
|
{
|
|
return $this->endDate;
|
|
}
|
|
|
|
public function setEndDate(?\DateTimeInterface $endDate): self
|
|
{
|
|
$this->endDate = $endDate;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isOpen(): bool
|
|
{
|
|
return $this->endDate === null;
|
|
}
|
|
}
|