367 lines
7.4 KiB
PHP

<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\FamilyMembersBundle\Entity;
use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\PersonBundle\Entity\MaritalStatus;
use Chill\PersonBundle\Entity\Person;
use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\MappedSuperclass
*/
abstract class AbstractFamilyMember implements HasCenterInterface
{
public const FAMILIAL_SITUATION = [
'a_charge' => 'A charge',
'garde_alternee' => 'Garde alternée',
'droit_de_visite' => 'Droit de visite et d\'hébergement',
'non_a_charge' => 'Non à charge',
];
/**
* @var date_immutable|null
*
* @ORM\Column(name="birthdate", type="date_immutable", nullable=true)
* @Assert\Date
*/
private ?\DateTimeImmutable $birthdate = null;
/**
*
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
* @Assert\Date
* @Assert\GreaterThan(
* propertyPath="startDate",
* message="The membership's end date should be after the start date"
* )
*/
private ?\DateTimeImmutable $endDate = null;
/**
* @var string
* @ORM\Column(name="familial_situation", type="string", length=200, nullable=true)
*/
private $familialSituation;
/**
* @ORM\Column(name="firstname", type="string", length=255)
*/
private string $firstname = '';
/**
* @ORM\Column(name="gender", type="string", length=20)
*/
private string $gender = '';
/**
* @ORM\Column(name="lastname", type="string", length=255)
*/
private string $lastname = '';
/**
* @ORM\Column(name="link", type="string", length=255)
*/
private string $link = '';
/**
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\MaritalStatus"
* )
*/
private ?\Chill\PersonBundle\Entity\MaritalStatus $maritalStatus = null;
/**
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person"
* )
*/
private ?\Chill\PersonBundle\Entity\Person $person = null;
/**
* @ORM\Column(name="professionnalSituation", type="text")
*/
private string $professionnalSituation = '';
/**
*
* @ORM\Column(name="startDate", type="datetime_immutable")
* @Assert\NotNull
* @Assert\Date
*/
private ?\DateTimeImmutable $startDate = null;
public function __construct()
{
$this->setStartDate(new DateTimeImmutable('now'));
}
/**
* Get birthdate.
*
* @return date_immutable|null
*/
public function getBirthdate()
{
return $this->birthdate;
}
public function getCenter(): \Chill\MainBundle\Entity\Center
{
return $this->getPerson()->getCenter();
}
/**
* Get endDate.
*
* @return DateTimeImmutable|null
*/
public function getEndDate()
{
return $this->endDate;
}
public function getFamilialSituation()
{
return $this->familialSituation;
}
/**
* Get firstname.
*
* @return string
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* Get gender.
*
* @return string
*/
public function getGender()
{
return $this->gender;
}
/**
* Get lastname.
*
* @return string
*/
public function getLastname()
{
return $this->lastname;
}
/**
* Get link.
*
* @return string
*/
public function getLink()
{
return $this->link;
}
/**
* @return MaritalStatus
*/
public function getMaritalStatus()
{
return $this->maritalStatus;
}
/**
* @return Person
*/
public function getPerson()
{
return $this->person;
}
/**
* Get professionnalSituation.
*
* @return string
*/
public function getProfessionnalSituation()
{
return $this->professionnalSituation;
}
/**
* Get startDate.
*
* @return DateTimeImmutable
*/
public function getStartDate()
{
return $this->startDate;
}
/**
* Set birthdate.
*
* @return FamilyMember
*/
public function setBirthdate(?DateTimeInterface $birthdate = null)
{
if ($birthdate instanceof DateTime) {
$this->birthdate = DateTimeImmutable::createFromMutable($birthdate);
} elseif (null === $birthdate || $birthdate instanceof DateTimeImmutable) {
$this->birthdate = $birthdate;
}
return $this;
}
/**
* Set endDate.
*
* @return FamilyMember
*/
public function setEndDate(?DateTimeInterface $endDate = null)
{
if ($endDate instanceof DateTime) {
$this->endDate = DateTimeImmutable::createFromMutable($endDate);
} elseif ($endDate instanceof DateTimeImmutable || null === $endDate) {
$this->endDate = $endDate;
}
return $this;
}
public function setFamilialSituation($familialSituation)
{
$this->familialSituation = $familialSituation;
return $this;
}
/**
* Set firstname.
*
* @param string $firstname
*
* @return FamilyMember
*/
public function setFirstname($firstname)
{
$this->firstname = (string) $firstname;
return $this;
}
/**
* Set gender.
*
* @param string $gender
*
* @return FamilyMember
*/
public function setGender($gender)
{
$this->gender = (string) $gender;
return $this;
}
/**
* Set lastname.
*
* @param string $lastname
*
* @return FamilyMember
*/
public function setLastname($lastname)
{
$this->lastname = (string) $lastname;
return $this;
}
/**
* Set link.
*
* @param string $link
*
* @return FamilyMember
*/
public function setLink($link)
{
$this->link = (string) $link;
return $this;
}
/**
* @param MaritalStatus $maritalStatus
*
* @return $this
*/
public function setMaritalStatus(?MaritalStatus $maritalStatus = null)
{
$this->maritalStatus = $maritalStatus;
return $this;
}
/**
* @return $this
*/
public function setPerson(Person $person)
{
$this->person = $person;
return $this;
}
/**
* Set professionnalSituation.
*
* @param string $professionnalSituation
*
* @return FamilyMember
*/
public function setProfessionnalSituation($professionnalSituation)
{
$this->professionnalSituation = (string) $professionnalSituation;
return $this;
}
/**
* Set startDate.
*
* @param DateTimeImmutable $startDate
*
* @return FamilyMember
*/
public function setStartDate(DateTimeInterface $startDate)
{
if ($startDate instanceof DateTime) {
$this->startDate = DateTimeImmutable::createFromMutable($startDate);
} elseif (null === $startDate || $startDate instanceof DateTimeImmutable) {
$this->startDate = $startDate;
}
return $this;
}
}