mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
[AccompanyingPeriod] add location to serialization
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user