first impl of person Mover + add fixtures

This commit is contained in:
2021-05-28 16:41:37 +02:00
parent 94bcbac06a
commit 87ba68971c
13 changed files with 384 additions and 21 deletions

View File

@@ -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;
}
}

View File

@@ -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;