src/Entity/PortalAdministrator.php line 13
<?phpnamespace App\Entity;use App\Repository\PortalAdministratorRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;use Symfony\Component\Security\Core\User\UserInterface;#[ORM\Entity(repositoryClass: PortalAdministratorRepository::class)]class PortalAdministrator implements UserInterface, PasswordAuthenticatedUserInterface{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 180, unique: true)]private ?string $username = null;#[ORM\Column]private array $roles = [];/*** @var string The hashed password*/#[ORM\Column]private ?string $password = null;#[ORM\ManyToOne(inversedBy: 'portalAdministrators')]private ?Corporation $corporation = null;#[ORM\Column]private ?bool $mainUser = null;#[ORM\ManyToOne(inversedBy: 'portalAdministrators', cascade: ['persist'])]private ?Department $department = null;#[ORM\ManyToOne(inversedBy: 'portalAdministrators')]private ?Portal $portal = null;#[ORM\Embedded(class: UserInformation::class)]private UserInformation $userInformation;#[ORM\ManyToMany(targetEntity: PortalAdministratorGroup::class, mappedBy: 'portalAdministrators')]private Collection $portalAdministratorGroups;#[ORM\OneToMany(mappedBy: 'portalAdmin', targetEntity: Course::class)]private Collection $courses;#[ORM\OneToMany(mappedBy: 'adminSender', targetEntity: Message::class)]private Collection $messages;public function __construct(){$this->userInformation = new UserInformation();$this->userInformation->setCreatedAt(new \DateTimeImmutable());$this->portalAdministratorGroups = new ArrayCollection();$this->courses = new ArrayCollection();$this->messages = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function __toString(): string{return $this->getUserInformation()->getFirstName().' '.$this->getUserInformation()->getLastName();}public function getUsername(): ?string{return $this->username;}public function setUsername(string $username): self{$this->username = $username;return $this;}/*** A visual identifier that represents this user.** @see UserInterface*/public function getUserIdentifier(): string{return (string)$this->username;}/*** @see UserInterface*/public function getRoles(): array{$roles = $this->roles;// guarantee every user at least has ROLE_USER$roles[] = 'ROLE_USER';return array_unique($roles);}public function setRoles(array $roles): self{$this->roles = $roles;return $this;}/*** @see PasswordAuthenticatedUserInterface*/public function getPassword(): string{return $this->password;}public function setPassword(string $password): self{$this->password = $password;return $this;}/*** @see UserInterface*/public function eraseCredentials(){// If you store any temporary, sensitive data on the user, clear it here// $this->plainPassword = null;}public function getCorporation(): ?Corporation{return $this->corporation;}public function setCorporation(?Corporation $corporation): self{$this->corporation = $corporation;return $this;}public function isMainUser(): ?bool{return $this->mainUser;}public function setMainUser(bool $mainUser): self{$this->mainUser = $mainUser;return $this;}public function getDepartment(): ?Department{return $this->department;}public function setDepartment(?Department $department): self{$this->department = $department;return $this;}public function getPortal(): ?Portal{return $this->portal;}public function setPortal(?Portal $portal): self{$this->portal = $portal;return $this;}public function getUserInformation(): UserInformation{return $this->userInformation;}/*** @return Collection<int, PortalAdministratorGroup>*/public function getPortalAdministratorGroups(): Collection{return $this->portalAdministratorGroups;}public function addPortalAdministratorGroup(PortalAdministratorGroup $portalAdministratorGroup): self{if (!$this->portalAdministratorGroups->contains($portalAdministratorGroup)) {$this->portalAdministratorGroups->add($portalAdministratorGroup);$portalAdministratorGroup->addPortalAdministrator($this);}return $this;}public function removePortalAdministratorGroup(PortalAdministratorGroup $portalAdministratorGroup): self{if ($this->portalAdministratorGroups->removeElement($portalAdministratorGroup)) {$portalAdministratorGroup->removePortalAdministrator($this);}return $this;}/*** @return Collection<int, Course>*/public function getCourses(): Collection{return $this->courses;}public function addCourse(Course $course): self{if (!$this->courses->contains($course)) {$this->courses->add($course);$course->setPortalAdmin($this);}return $this;}public function removeCourse(Course $course): self{if ($this->courses->removeElement($course)) {// set the owning side to null (unless already changed)if ($course->getPortalAdmin() === $this) {$course->setPortalAdmin(null);}}return $this;}/*** @return Collection<int, Message>*/public function getMessages(): Collection{return $this->messages;}public function addMessage(Message $message): self{if (!$this->messages->contains($message)) {$this->messages->add($message);$message->setAdminSender($this);}return $this;}public function removeMessage(Message $message): self{if ($this->messages->removeElement($message)) {// set the owning side to null (unless already changed)if ($message->getAdminSender() === $this) {$message->setAdminSender(null);}}return $this;}}