WIP: Implement profile editing
This commit is contained in:
@@ -25,13 +25,14 @@ class Address
|
||||
#[ORM\Column(type: 'string', nullable: true)]
|
||||
protected ?string $country = null;
|
||||
|
||||
public function toArray(): array
|
||||
public function toPayload(): array
|
||||
{
|
||||
return [
|
||||
'street' => $this->getStreet(),
|
||||
'post_code' => $this->getPostCode(),
|
||||
'city' => $this->getCity(),
|
||||
'country' => $this->getCountry(),
|
||||
'strasse' => $this->getStreet(),
|
||||
'plz' => $this->getPostCode(),
|
||||
'ort' => $this->getCity(),
|
||||
'ortsteil' => '',
|
||||
'land' => $this->getCountry(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,15 @@ class Communication
|
||||
#[Assert\Email(mode: 'strict')]
|
||||
protected ?string $email = null;
|
||||
|
||||
public function toPayload(): array
|
||||
{
|
||||
return [
|
||||
'email' => $this->getEmail(),
|
||||
'telefonmobil' => $this->getMobile(),
|
||||
'telefonprivat' => $this->getPhone(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function fromApiResponse(ProfileResponse $profileResponse): static
|
||||
{
|
||||
$communication = $profileResponse->getCommunication();
|
||||
|
||||
@@ -117,6 +117,28 @@ class Teamer implements TimestampableEntityInterface
|
||||
$this->dispositions = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function toPayload(): array
|
||||
{
|
||||
// Transform gender value
|
||||
$gender = strtoupper($this->getGender());
|
||||
$gender = 'F' ? 'W' : $gender;
|
||||
|
||||
// Ensure date of birth is populated
|
||||
if (null === $dob = $this->getDateOfBirth()) {
|
||||
$dob = new \DateTimeImmutable('18 years ago');
|
||||
}
|
||||
|
||||
return [
|
||||
'geburtsdatum' => $dob->format('d.m.Y'),
|
||||
'geschlecht' => $gender,
|
||||
'titel' => $this->getAcademicTitle(),
|
||||
'vorname' => $this->getFirstName(),
|
||||
'name' => $this->getLastName(),
|
||||
'anschrift' => $this->getAddress()->toPayload(),
|
||||
'kommunikation' => $this->getCommunication()->toPayload(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function fromApiResponse(ProfileResponse $profileResponse): static
|
||||
{
|
||||
$instance = new static();
|
||||
|
||||
Reference in New Issue
Block a user