<?php
namespace App\Entity;
use App\Repository\JuryRepository;
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: JuryRepository::class)]
class Jury implements UserInterface, PasswordAuthenticatedUserInterface, \Serializable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 128)]
private ?string $name = null;
#[ORM\Column(length: 128, unique: true)]
private ?string $login = null;
#[ORM\Column(length: 128)]
private $password;
#[ORM\Column(type: 'json')]
private $roles = [];
#[ORM\ManyToMany(targetEntity: Theme::class, inversedBy: 'juries')]
private Collection $theme;
#[ORM\ManyToMany(targetEntity: Team::class, inversedBy: 'juries')]
private Collection $team;
#[ORM\Column]
private ?bool $president = null;
#[ORM\Column]
private ?bool $enabled = null;
#[ORM\OneToMany(mappedBy: 'jury', targetEntity: Result::class, orphanRemoval: true)]
private Collection $results;
#[ORM\OneToMany(mappedBy: 'jury', targetEntity: Comment::class, orphanRemoval: true)]
private Collection $comments;
#[ORM\Column(length: 10)]
private ?string $lang = null;
public function __construct()
{
$this->theme = new ArrayCollection();
$this->team = new ArrayCollection();
$this->results = new ArrayCollection();
$this->comments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getLang(): ?string
{
return $this->lang;
}
public function setLang(string $lang): self
{
$this->lang = $lang;
return $this;
}
/**
* @return Collection<int, Theme>
*/
public function getTheme(): Collection
{
return $this->theme;
}
public function addTheme(Theme $theme): self
{
if (!$this->theme->contains($theme)) {
$this->theme->add($theme);
}
return $this;
}
public function removeTheme(Theme $theme): self
{
$this->theme->removeElement($theme);
return $this;
}
/**
* @return Collection<int, Team>
*/
public function getTeam(): Collection
{
return $this->team;
}
public function addTeam(Team $team): self
{
if (!$this->team->contains($team)) {
$this->team->add($team);
}
return $this;
}
public function removeTeam(Team $team): self
{
$this->team->removeElement($team);
return $this;
}
public function isEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled): self
{
$this->enabled = $enabled;
return $this;
}
public function isPresident(): ?bool
{
return $this->president;
}
public function setPresident(bool $president): self
{
$this->president = $president;
return $this;
}
public function getLogin(): ?string
{
return $this->login;
}
public function setLogin(string $login): self
{
$this->login = $login;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->login;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->login;
}
/**
* @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;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection<int, Result>
*/
public function getResults(): Collection
{
return $this->results;
}
public function addResult(Result $result): self
{
if (!$this->results->contains($result)) {
$this->results->add($result);
$result->setJury($this);
}
return $this;
}
public function removeResult(Result $result): self
{
if ($this->results->removeElement($result)) {
// set the owning side to null (unless already changed)
if ($result->getJury() === $this) {
$result->setJury(null);
}
}
return $this;
}
/**
* @return Collection<int, Comment>
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments->add($comment);
$comment->setJury($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if ($comment->getJury() === $this) {
$comment->setJury(null);
}
}
return $this;
}
public function serialize()
{
return serialize(array(
$this->id,
$this->login,
$this->password,
));
}
public function unserialize(string $data)
{
list (
$this->id,
$this->login,
$this->password,
) = unserialize($data);
}
}