mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
first impl of person Mover + add fixtures
This commit is contained in:
@@ -14,7 +14,7 @@ use Chill\PersonBundle\Entity\Household\Position;
|
||||
* name="chill_person_household_members"
|
||||
* )
|
||||
*/
|
||||
class HouseholdMembers
|
||||
class HouseholdMember
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
@@ -26,27 +26,32 @@ class HouseholdMembers
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Position::class)
|
||||
*/
|
||||
private $position;
|
||||
private ?Position $position = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date")
|
||||
* @ORM\Column(type="date", nullable=true, options={"default": null})
|
||||
*/
|
||||
private $startDate;
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date")
|
||||
* @ORM\Column(type="date", nullable= true, options={"default": null})
|
||||
*/
|
||||
private $endDate;
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $comment;
|
||||
private ?string $comment = NULL;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $sharedHousehold;
|
||||
private bool $sharedHousehold = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
*/
|
||||
private bool $holder = false;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -55,7 +60,7 @@ class HouseholdMembers
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||
* )
|
||||
*/
|
||||
private $person;
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -64,21 +69,28 @@ class HouseholdMembers
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
||||
* )
|
||||
*/
|
||||
private $household;
|
||||
private ?Household $household = null;
|
||||
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPosition(): ?string
|
||||
public function getPosition(): ?Position
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function setPosition(?string $position): self
|
||||
public function setPosition(Position $position): self
|
||||
{
|
||||
if ($this->position instanceof Position) {
|
||||
throw new \LogicException("The position is already set. You cannot change ".
|
||||
"a position of a membership");
|
||||
}
|
||||
|
||||
$this->position = $position;
|
||||
$this->sharedHousehold = $position->getShareHousehold();
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -119,17 +131,11 @@ class HouseholdMembers
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSharedHousehold(): ?bool
|
||||
public function getShareHousehold(): ?bool
|
||||
{
|
||||
return $this->sharedHousehold;
|
||||
}
|
||||
|
||||
public function setSharedHousehold(bool $sharedHousehold): self
|
||||
{
|
||||
$this->sharedHousehold = $sharedHousehold;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPerson(): ?Person
|
||||
{
|
||||
@@ -138,8 +144,15 @@ class HouseholdMembers
|
||||
|
||||
public function setPerson(?Person $person): self
|
||||
{
|
||||
if ($this->person instanceof Person) {
|
||||
throw new \LogicException("You cannot change person ".
|
||||
"on a membership");
|
||||
}
|
||||
|
||||
$this->person = $person;
|
||||
|
||||
$person->addHouseholdParticipation($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -150,8 +163,25 @@ class HouseholdMembers
|
||||
|
||||
public function setHousehold(?Household $household): self
|
||||
{
|
||||
if ($this->household instanceof Household) {
|
||||
throw new \LogicException("You cannot change household ".
|
||||
"on a membership");
|
||||
}
|
||||
|
||||
$this->household = $household;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHolder(bool $holder): self
|
||||
{
|
||||
$this->holder = $holder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isHolder(): bool
|
||||
{
|
||||
return $this->holder;
|
||||
}
|
||||
}
|
@@ -55,12 +55,12 @@ class Position
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShareHouseHold(): ?bool
|
||||
public function getShareHousehold(): ?bool
|
||||
{
|
||||
return $this->shareHouseHold;
|
||||
}
|
||||
|
||||
public function setShareHouseHold(bool $shareHouseHold): self
|
||||
public function setShareHousehold(bool $shareHouseHold): self
|
||||
{
|
||||
$this->shareHouseHold = $shareHouseHold;
|
||||
|
||||
|
@@ -26,6 +26,7 @@ use ArrayIterator;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Country;
|
||||
use Chill\PersonBundle\Entity\MaritalStatus;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use DateTime;
|
||||
@@ -272,6 +273,14 @@ class Person implements HasCenterInterface
|
||||
*/
|
||||
private $fullnameCanonical;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=HouseholdMember::class,
|
||||
* mappedBy="person"
|
||||
* )
|
||||
*/
|
||||
private Collection $householdParticipations;
|
||||
|
||||
/**
|
||||
* Person constructor.
|
||||
*
|
||||
@@ -284,6 +293,7 @@ class Person implements HasCenterInterface
|
||||
$this->addresses = new ArrayCollection();
|
||||
$this->altNames = new ArrayCollection();
|
||||
$this->otherPhoneNumbers = new ArrayCollection();
|
||||
$this->householdParticipations = new ArrayCollection();
|
||||
|
||||
if ($opening === null) {
|
||||
$opening = new \DateTime();
|
||||
@@ -1180,4 +1190,16 @@ class Person implements HasCenterInterface
|
||||
$this->fullnameCanonical = $fullnameCanonical;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addHouseholdParticipation(HouseholdMember $member): self
|
||||
{
|
||||
$this->householdParticipations[] = $member;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHouseholdParticipations(): Collection
|
||||
{
|
||||
return $this->householdParticipations;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user