mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 21:13:57 +00:00
add model + form to handle alt names
This commit is contained in:
@@ -42,6 +42,12 @@ class Person implements HasCenterInterface {
|
||||
|
||||
/** @var string The person's last name */
|
||||
private $lastName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
private $altNames;
|
||||
|
||||
/** @var \DateTime The person's birthdate */
|
||||
private $birthdate; //to change in birthdate
|
||||
@@ -123,6 +129,7 @@ class Person implements HasCenterInterface {
|
||||
$this->accompanyingPeriods = new ArrayCollection();
|
||||
$this->spokenLanguages = new ArrayCollection();
|
||||
$this->addresses = new ArrayCollection();
|
||||
$this->altNames = new ArrayCollection();
|
||||
|
||||
if ($opening === null) {
|
||||
$opening = new \DateTime();
|
||||
@@ -324,7 +331,39 @@ class Person implements HasCenterInterface {
|
||||
{
|
||||
return $this->lastName;
|
||||
}
|
||||
|
||||
public function getAltNames(): \Doctrine\Common\Collections\Collection
|
||||
{
|
||||
return $this->altNames;
|
||||
}
|
||||
|
||||
public function setAltNames(\Doctrine\Common\Collections\Collection $altNames)
|
||||
{
|
||||
$this->altNames = $altNames;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addAltName(PersonAltName $altName)
|
||||
{
|
||||
if (FALSE === $this->altNames->contains($altName)) {
|
||||
$this->altNames->add($altName);
|
||||
$altName->setPerson($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeAltName(PersonAltName $altName)
|
||||
{
|
||||
if ($this->altNames->contains($altName)) {
|
||||
$altName->setPerson(null);
|
||||
$this->altNames->removeElement($altName);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set birthdate
|
||||
*
|
||||
|
118
Entity/PersonAltName.php
Normal file
118
Entity/PersonAltName.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* PersonAltName
|
||||
*
|
||||
* @ORM\Table(name="person_alt_name")
|
||||
* @ORM\Entity(repositoryClass="Chill\PersonBundle\Repository\PersonAltNameRepository")
|
||||
*/
|
||||
class PersonAltName
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="key", type="string", length=255)
|
||||
*/
|
||||
private $key;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="label", type="text")
|
||||
*/
|
||||
private $label;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Person
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\PersonBundle\Entity\Person",
|
||||
* mappedBy="altNames"
|
||||
* )
|
||||
*/
|
||||
private $person;
|
||||
|
||||
|
||||
/**
|
||||
* Get id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set key.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return PersonAltName
|
||||
*/
|
||||
public function setKey($key)
|
||||
{
|
||||
$this->key = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set label.
|
||||
*
|
||||
* @param string $label
|
||||
*
|
||||
* @return PersonAltName
|
||||
*/
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get label.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function getPerson(): Person
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
public function setPerson(?Person $person = null)
|
||||
{
|
||||
$this->person = $person;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user