<?php /** * Copyright (C) 2019 Leipzig University Library * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ namespace fid\Service\DataTransferObject; use Symfony\Component\Serializer\Annotation\Groups; class User { /** * @var null|string * @Groups({ * "user:details:response", * "user:creation:response", * "user:update:response" * }) */ protected $id; /** * @var null|string * @Groups({ * "user:details:response", * "user:creation:request", * "user:creation:response", * "user:update:response" * }) */ protected $username; /** * @var null|string * @Groups({ * "user:details:response", * "user:creation:request", * "user:update:request", * "user:update:response", * }) */ protected $password; /** * @var string * @Groups({ * "user:details:response", * "user:creation:request", * "user:creation:response", * "user:update:request", * "user:update:response" * }) */ protected $salutation; /** * @var string * @Groups({ * "user:details:response", * "user:creation:request", * "user:creation:response", * "user:update:request", * "user:update:response" * }) */ protected $academicTitle; /** * @var null|string * @Groups({ * "user:details:response", * "user:creation:request", * "user:creation:response", * "user:update:request", * "user:update:response" * }) */ protected $firstname; /** * @var null|string * @Groups({ * "user:details:response", * "user:creation:request", * "user:creation:response", * "user:update:request", * "user:update:response" * }) */ protected $lastname; /** * @var null|int * @Groups({ * "user:details:response", * "user:creation:request", * "user:creation:response", * "user:update:request", * "user:update:response" * }) */ protected $yearOfBirth; /** * @var null|string * @Groups({ * "user:details:response", * "user:creation:request", * "user:creation:response", * "user:update:request", * "user:update:response" * }) */ protected $homeLibrary; /** * @var string * @Groups({ * "user:details:response", * "user:creation:request", * "user:creation:response", * "user:update:request", * "user:update:response" * }) */ protected $college; /** * @var string * @Groups({ * "user:details:response", * "user:creation:request", * "user:creation:response", * "user:update:request", * "user:update:response" * }) */ protected $jobTitle; /** * @var Address[] * @Groups({ * "user:details:response", * "user:creation:request", * "user:creation:response", * "user:update:request", * "user:update:response" * }) */ protected $addresses = []; /** * @var string|null */ protected $role; /** * @var array[] * @Groups({ * "user:details:response", * "user:creation:request", * "user:creation:response", * "user:update:request", * "user:update:response" * }) */ protected $permissions = []; /** * @return string|null */ public function getId(): ?string { return $this->id; } /** * @param string|null $id */ public function setId(?string $id): void { $this->id = $id; } /** * @return string|null */ public function getUsername(): ?string { return $this->username; } /** * @param string|null $username */ public function setUsername(?string $username): void { $this->username = $username; } /** * @return string|null */ public function getPassword(): ?string { return $this->password; } /** * @param string|null $password */ public function setPassword(?string $password): void { $this->password = $password; } /** * @return string|null */ public function getSalutation(): ?string { return $this->salutation; } /** * @param string|null $salutation */ public function setSalutation(?string $salutation): void { $this->salutation = $salutation; } /** * @return string|null */ public function getAcademicTitle(): ?string { return $this->academicTitle; } /** * @param string|null $academicTitle */ public function setAcademicTitle(?string $academicTitle): void { $this->academicTitle = $academicTitle; } /** * @return string|null */ public function getFirstname(): ?string { return $this->firstname; } /** * @param string|null $firstname */ public function setFirstname(?string $firstname): void { $this->firstname = $firstname; } /** * @return string|null */ public function getLastname(): ?string { return $this->lastname; } /** * @param string|null $lastname */ public function setLastname(?string $lastname): void { $this->lastname = $lastname; } /** * @return int|null */ public function getYearOfBirth(): ?int { return $this->yearOfBirth; } /** * @param int|null $yearOfBirth */ public function setYearOfBirth(?int $yearOfBirth): void { $this->yearOfBirth = $yearOfBirth; } /** * @return string */ public function getHomeLibrary(): string { return $this->homeLibrary; } /** * @param string $homeLibrary */ public function setHomeLibrary(string $homeLibrary): void { $this->homeLibrary = $homeLibrary; } /** * @return string */ public function getCollege(): string { return $this->college; } /** * @param string $college */ public function setCollege(string $college): void { $this->college = $college; } /** * @return string|null */ public function getJobTitle(): ?string { return $this->jobTitle; } /** * @param string|null $jobTitle */ public function setJobTitle(?string $jobTitle): void { $this->jobTitle = $jobTitle; } /** * @return Address[] */ public function getAddresses(): array { return $this->addresses; } /** * @param Address[] $addresses */ public function setAddresses(array $addresses): void { $this->addresses = $addresses; foreach ($addresses as $address) { $address->setUser($this); } } /** * @return string|null */ public function getRole(): ?string { return $this->role ?? (count($this->permissions) > 0 ? array_keys($this->permissions)[0] : null); } /** * @param string|null $role */ public function setRole(?string $role): void { $this->role = $role; } /** * @return array[] */ public function getPermissions(): array { return $this->permissions; } /** * @param array[] $permissions */ public function setPermissions(array $permissions): void { $this->permissions = $permissions; if (count($permissions) > 0) { $this->setRole(array_keys($permissions)[0]); } } }