From d621b9db29df06ce457de2753ac8a679bc7cfb84 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 8 Jan 2020 22:08:57 +0100 Subject: [PATCH] Added name and formalName to person --- api/src/Entity/Person.php | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/api/src/Entity/Person.php b/api/src/Entity/Person.php index 6f06477d..e107a54a 100644 --- a/api/src/Entity/Person.php +++ b/api/src/Entity/Person.php @@ -43,6 +43,25 @@ class Person */ private $id; + + /** + * @var string The full name of a person consisting of given and fammily name + * + * @example John Do + * + * @Groups({"read"}) + */ + private $name; + + /** + * @var string The full name of a person consisting of fammily and given name + * + * @example Do, John + * + * @Groups({"read"}) + */ + private $formalName; + /** * @var string Given name of this person * @@ -148,7 +167,25 @@ public function getId() { return $this->id; } - + + public function getName(): ?string + { + if($this->getAdditionalName()){ + return $this->givenName.' '.$this->additionalName.' '.$this->familyNames; + } + + return $this->givenName.' '.$this->familyNames; + } + + public function getFormalName(): ?string + { + if($this->getAdditionalName()){ + return $this->familyName.', '.$this->givenName.' '.$this->additionalName; + } + + return $this->familyName.', '.$this->givenName; + } + public function getGivenName(): ?string { return $this->givenName;