mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Set requestor for accompanying period
This commit is contained in:
@@ -515,9 +515,9 @@ class AccompanyingPeriod
|
||||
return $this->requestorPerson;
|
||||
}
|
||||
|
||||
public function setRequestorPerson(Person $requestorPerson): self
|
||||
public function setRequestorPerson(Person $requestorPerson = null): self
|
||||
{
|
||||
$this->requestorPerson = ($this->requestorThirdParty === null) ? $requestorPerson : null;
|
||||
$this->requestorPerson = $requestorPerson;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -527,9 +527,9 @@ class AccompanyingPeriod
|
||||
return $this->requestorThirdParty;
|
||||
}
|
||||
|
||||
public function setRequestorThirdParty(ThirdParty $requestorThirdParty): self
|
||||
public function setRequestorThirdParty(ThirdParty $requestorThirdParty = null): self
|
||||
{
|
||||
$this->requestorThirdParty = ($this->requestorPerson === null) ? $requestorThirdParty : null;
|
||||
$this->requestorThirdParty = $requestorThirdParty;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -542,6 +542,37 @@ class AccompanyingPeriod
|
||||
return $this->requestorPerson ?? $this->requestorThirdParty;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a requestor
|
||||
*
|
||||
* The requestor is either an instance of ThirdParty, or an
|
||||
* instance of Person
|
||||
*
|
||||
* @param $requestor Person|ThirdParty
|
||||
* @return self
|
||||
* @throw UnexpectedValueException if the requestor is not a Person or ThirdParty
|
||||
*
|
||||
*/
|
||||
public function setRequestor($requestor): self
|
||||
{
|
||||
if ($requestor instanceof Person) {
|
||||
$this->setRequestorThirdParty(NULL);
|
||||
$this->setRequestorPerson($requestor);
|
||||
} elseif ($requestor instanceof ThirdParty) {
|
||||
$this->setRequestorThirdParty($requestor);
|
||||
$this->setRequestorPerson(NULL);
|
||||
} elseif (NULL === $requestor) {
|
||||
$this->setRequestorPerson(NULL);
|
||||
$this->setRequestorThirdParty(NULL);
|
||||
} else {
|
||||
throw new \UnexpectedValueException("requestor is not an instance of Person or ThirdParty");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function isRequestorAnonymous(): bool
|
||||
{
|
||||
return $this->requestorAnonymous;
|
||||
|
Reference in New Issue
Block a user