Merge remote-tracking branch 'origin/master' into features/household-editor

This commit is contained in:
2021-06-07 17:32:29 +02:00
64 changed files with 1626 additions and 460 deletions

View File

@@ -2,10 +2,12 @@
namespace Chill\PersonBundle\Entity\Household;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Chill\MainBundle\Entity\Address;
use Symfony\Component\Serializer\Annotation as Serializer;
use Chill\MainBundle\Entity\Address;
use Chill\PersonBundle\Entity\Household\HouseholdMember;
/**
* @ORM\Entity
@@ -24,16 +26,10 @@ class Household
* @ORM\Column(type="integer")
* @Serializer\Groups({"read"})
*/
private $id;
public function getId(): ?int
{
return $this->id;
}
private ?int $id = null;
/**
* Addresses
* @var Collection
*
* @ORM\ManyToMany(
* targetEntity="Chill\MainBundle\Entity\Address",
@@ -41,8 +37,27 @@ class Household
* @ORM\JoinTable(name="chill_person_household_to_addresses")
* @ORM\OrderBy({"validFrom" = "DESC"})
*/
private $addresses;
private Collection $addresses;
/**
* @ORM\OneToMany(
* targetEntity=HouseholdMember::class,
* mappedBy="household"
* )
* @Serializer\Groups({"read"})
*/
private Collection $members;
public function __construct()
{
$this->addresses = new ArrayCollection();
$this->members = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @param Address $address
@@ -74,4 +89,34 @@ class Household
return $this->addresses;
}
/**
* @return Collection|HouseholdMember[]
*/
public function getMembers(): Collection
{
return $this->members;
}
public function addMember(HouseholdMember $member): self
{
if (!$this->members->contains($member)) {
$this->members[] = $member;
$member->setHousehold($this);
}
return $this;
}
public function removeMember(HouseholdMember $member): self
{
if ($this->members->removeElement($member)) {
// set the owning side to null (unless already changed)
if ($member->getHousehold() === $this) {
$member->setHousehold(null);
}
}
return $this;
}
}

View File

@@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping as ORM;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Household\Position;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
@@ -20,26 +21,31 @@ class HouseholdMember
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"read"})
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Position::class)
* @Serializer\Groups({"read"})
*/
private ?Position $position = null;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"})
*/
private ?\DateTimeImmutable $startDate = null;
/**
* @ORM\Column(type="date_immutable", nullable= true, options={"default": null})
* @Serializer\Groups({"read"})
*/
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Groups({"read"})
*/
private ?string $comment = NULL;
@@ -50,6 +56,7 @@ class HouseholdMember
/**
* @ORM\Column(type="boolean", options={"default": false})
* @Serializer\Groups({"read"})
*/
private bool $holder = false;
@@ -59,6 +66,7 @@ class HouseholdMember
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person"
* )
* @Serializer\Groups({"read"})
*/
private ?Person $person = null;
@@ -131,6 +139,9 @@ class HouseholdMember
return $this;
}
/**
* @Serializer\Groups({"read"})
*/
public function getShareHousehold(): ?bool
{
return $this->sharedHousehold;