mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
[AccompanyingPeriod] add location to serialization
This commit is contained in:
parent
8f9c8bc1a6
commit
f188cc2d27
@ -948,4 +948,67 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAddressLocation(): ?Address
|
||||
{
|
||||
return $this->addressLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
public function setAddressLocation(?Address $addressLocation = null): self
|
||||
{
|
||||
$this->addressLocation = $addressLocation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
public function getPersonLocation(): ?Person
|
||||
{
|
||||
return $this->personLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
public function setPersonLocation(?Person $person = null): self
|
||||
{
|
||||
$this->personLocation = $person;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the location, taking precedence into account
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
public function getLocation(\DateTimeImmutable $at = null): ?Address
|
||||
{
|
||||
if ($this->getPersonLocation() instanceof Person) {
|
||||
return $this->getPersonLocation()->getCurrentHouseholdAddress($at);
|
||||
}
|
||||
|
||||
return $this->getAddressLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get where the location is
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
public function getLocationStatus(): string
|
||||
{
|
||||
if ($this->getPersonLocation() instanceof Person) {
|
||||
return 'person';
|
||||
} elseif ($this->getAddressLocation() instanceof Address) {
|
||||
return 'address';
|
||||
} else {
|
||||
return 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -416,6 +416,26 @@ paths:
|
||||
This is my an initial comment.
|
||||
|
||||
Say hello to the new "parcours"!
|
||||
Setting person with id 8405 as locator:
|
||||
value:
|
||||
type: accompanying_period
|
||||
id: 0
|
||||
personLocation:
|
||||
type: person
|
||||
id: 8405
|
||||
Removing person location for both person and address:
|
||||
value:
|
||||
type: accompanying_period
|
||||
id: 0
|
||||
personLocation: null
|
||||
addressLocation: null
|
||||
Adding address with id 7960 as temporarily address:
|
||||
value:
|
||||
type: accompanying_period
|
||||
id: 0
|
||||
personLocation: null
|
||||
addressLocation:
|
||||
id: 7960
|
||||
responses:
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
|
Loading…
x
Reference in New Issue
Block a user