normalization for docgen:read: add groups and so on (wip)

This commit is contained in:
2021-12-06 13:18:59 +01:00
parent 51fd81c661
commit c4998f4ac1
15 changed files with 166 additions and 70 deletions

View File

@@ -59,7 +59,7 @@ class Household
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id = null;
@@ -68,17 +68,19 @@ class Household
* targetEntity=HouseholdMember::class,
* mappedBy="household"
* )
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
*/
private Collection $members;
/**
* @ORM\Column(type="boolean", name="waiting_for_birth", options={"default": false})
* @Serializer\Groups({"docgen:read"})
*/
private bool $waitingForBirth = false;
/**
* @ORM\Column(type="date_immutable", name="waiting_for_birth_date", nullable=true, options={"default": null})
* @Serializer\Groups({"docgen:read"})
*/
private ?DateTimeImmutable $waitingForBirthDate = null;
@@ -134,7 +136,7 @@ class Household
}
/**
* @Serializer\Groups({ "read" })
* @Serializer\Groups({"read", "docgen:read"})
* @Serializer\SerializedName("current_address")
*/
public function getCurrentAddress(?DateTime $at = null): ?Address
@@ -154,6 +156,11 @@ class Household
return null;
}
/**
* @param DateTimeImmutable|null $now
* @return Collection
* @Serializer\Groups({"docgen:read"})
*/
public function getCurrentMembers(?DateTimeImmutable $now = null): Collection
{
return $this->getMembers()->matching($this->buildCriteriaCurrentMembers($now));

View File

@@ -28,13 +28,13 @@ class HouseholdMember
{
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?string $comment = null;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
* @Assert\GreaterThan(
* propertyPath="startDate",
* message="household_membership.The end date must be after start date",
@@ -45,7 +45,7 @@ class HouseholdMember
/**
* @ORM\Column(type="boolean", options={"default": false})
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
*/
private bool $holder = false;
@@ -63,7 +63,7 @@ class HouseholdMember
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
*/
private $id;
@@ -72,7 +72,7 @@ class HouseholdMember
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person"
* )
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
* @Assert\Valid(groups={"household_memberships"})
* @Assert\NotNull(groups={"household_memberships"})
*/
@@ -80,7 +80,7 @@ class HouseholdMember
/**
* @ORM\ManyToOne(targetEntity=Position::class)
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
* @Assert\NotNull(groups={"household_memberships_created"})
*/
private ?Position $position = null;
@@ -92,7 +92,7 @@ class HouseholdMember
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"})
* @Serializer\Groups({"read", "docgen:read"})
* @Assert\NotNull(groups={"household_memberships"})
*/
private ?DateTimeImmutable $startDate = null;

View File

@@ -33,25 +33,25 @@ class Position
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({ "read" })
* @Serializer\Groups({"read", "docgen:read"})
*/
private ?int $id;
/**
* @ORM\Column(type="json")
* @Serializer\Groups({ "read" })
* @Serializer\Groups({"read", "docgen:read"})
*/
private array $label = [];
/**
* @ORM\Column(type="float")
* @Serializer\Groups({ "read" })
* @Serializer\Groups({"read"})
*/
private float $ordering = 0.00;
/**
* @ORM\Column(type="boolean")
* @Serializer\Groups({ "read" })
* @Serializer\Groups({"read"})
*/
private bool $shareHouseHold = true;