Features/new phones

This commit is contained in:
Jean-Francois Monfort
2021-04-02 12:11:20 +00:00
committed by Julien Fastré
parent 6ea45e4d16
commit 27c680bb03
14 changed files with 502 additions and 123 deletions

View File

@@ -72,7 +72,7 @@ class Person implements HasCenterInterface
* @ORM\Column(type="string", length=255)
*/
private $lastName;
/**
* @var Collection
*
@@ -177,6 +177,18 @@ class Person implements HasCenterInterface
*/
private $mobilenumber = '';
/**
* @var Collection
*
* @ORM\OneToMany(
* targetEntity="Chill\PersonBundle\Entity\PersonPhone",
* mappedBy="person",
* cascade={"persist", "remove", "merge", "detach"},
* orphanRemoval=true
* )
*/
private $otherPhoneNumbers;
//TO-ADD caseOpeningDate
//TO-ADD nativeLanguag
@@ -248,15 +260,14 @@ class Person implements HasCenterInterface
* @ORM\OrderBy({"validFrom" = "DESC"})
*/
private $addresses;
/**
* @var string
*
* @ORM\Column(type="text", nullable=true)
*/
private $fullnameCanonical;
/**
* Person constructor.
*
@@ -268,6 +279,7 @@ class Person implements HasCenterInterface
$this->spokenLanguages = new ArrayCollection();
$this->addresses = new ArrayCollection();
$this->altNames = new ArrayCollection();
$this->otherPhoneNumbers = new ArrayCollection();
if ($opening === null) {
$opening = new \DateTime();
@@ -285,7 +297,7 @@ class Person implements HasCenterInterface
$accompanyingPeriod->setPerson($this);
$this->accompanyingPeriods->add($accompanyingPeriod);
}
/**
* @param AccompanyingPeriod $accompanyingPeriod
*/
@@ -476,7 +488,7 @@ class Person implements HasCenterInterface
{
return $this->lastName;
}
/**
* @return Collection
*/
@@ -484,7 +496,7 @@ class Person implements HasCenterInterface
{
return $this->altNames;
}
/**
* @param Collection $altNames
* @return $this
@@ -492,10 +504,10 @@ class Person implements HasCenterInterface
public function setAltNames(Collection $altNames)
{
$this->altNames = $altNames;
return $this;
}
/**
* @param PersonAltName $altName
* @return $this
@@ -506,24 +518,24 @@ class Person implements HasCenterInterface
$this->altNames->add($altName);
$altName->setPerson($this);
}
return $this;
}
/**
* @param PersonAltName $altName
* @return $this
*/
public function removeAltName(PersonAltName $altName)
public function removeAltName(PersonAltName $altName)
{
if ($this->altNames->contains($altName)) {
$altName->setPerson(null);
$this->altNames->removeElement($altName);
}
return $this;
}
/**
* Set birthdate
*
@@ -760,7 +772,7 @@ class Person implements HasCenterInterface
{
return $this->nationality;
}
/**
* @return string
*/
@@ -863,7 +875,53 @@ class Person implements HasCenterInterface
{
return $this->mobilenumber;
}
/**
* @return Collection
*/
public function getOtherPhoneNumbers(): Collection
{
return $this->otherPhoneNumbers;
}
/**
* @param Collection $otherPhoneNumbers
* @return $this
*/
public function setOtherPhoneNumbers(Collection $otherPhoneNumbers)
{
$this->otherPhoneNumbers = $otherPhoneNumbers;
return $this;
}
/**
* @param PersonPhone $otherPhoneNumber
* @return $this
*/
public function addOtherPhoneNumber(PersonPhone $otherPhoneNumber)
{
if (false === $this->otherPhoneNumbers->contains($otherPhoneNumber)) {
$otherPhoneNumber->setPerson($this);
$this->otherPhoneNumbers->add($otherPhoneNumber);
}
return $this;
}
/**
* @param PersonPhone $otherPhoneNumber
* @return $this
*/
public function removeOtherPhoneNumber(PersonPhone $otherPhoneNumber)
{
if ($this->otherPhoneNumbers->contains($otherPhoneNumber)) {
$this->otherPhoneNumbers->removeElement($otherPhoneNumber);
}
return $this;
}
/**
* @return string
*/
@@ -894,7 +952,7 @@ class Person implements HasCenterInterface
{
return $this->spokenLanguages;
}
/**
* @param Address $address
* @return $this
@@ -905,7 +963,7 @@ class Person implements HasCenterInterface
return $this;
}
/**
* @param Address $address
*/
@@ -924,7 +982,7 @@ class Person implements HasCenterInterface
{
return $this->addresses;
}
/**
* @param \DateTime|null $date
* @return null

View File

@@ -0,0 +1,115 @@
<?php
namespace Chill\PersonBundle\Entity;
use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\Mapping as ORM;
/**
* Person Phones
*
* @ORM\Entity()
* @ORM\Table(name="chill_person_phone")
*/
class PersonPhone
{
/**
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id;
/**
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\Person",
* inversedBy="otherPhoneNumbers"
* )
*/
private Person $person;
/**
* @ORM\Column(type="text", length=40, nullable=true)
*/
private ?string $type;
/**
* @ORM\Column(type="text", length=40, nullable=false)
*/
private string $phonenumber = '';
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $description = null;
/**
* @ORM\Column(type="datetime", nullable=false)
*/
private \DateTime $date;
public function __construct()
{
$this->date = new \DateTime();
}
public function getId(): int
{
return $this->id;
}
public function getPerson(): Person
{
return $this->person;
}
public function setPerson(Person $person): void
{
$this->person = $person;
}
public function getType(): string
{
return $this->type;
}
public function setType(string $type): void
{
$this->type = $type;
}
public function getPhonenumber(): string
{
return $this->phonenumber;
}
public function setPhonenumber(string $phonenumber): void
{
$this->phonenumber = $phonenumber;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): void
{
$this->description = $description;
}
public function getDate(): \DateTime
{
return $this->date;
}
public function setDate(\DateTime $date): void
{
$this->date = $date;
}
public function isEmpty(): bool
{
return empty($this->getDescription()) && empty($this->getPhonenumber());
}
}