<?php
// src/AppBundle/Entity/User.php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Security\Core\User\UserInterface;
use JMS\Serializer\Annotation as Serializer;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Event\PostFlushEventArgs;
/**
* @ORM\Table(name="ba_user")
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
class User implements UserInterface
{
use \App\Traits\Timestampable;
// use \App\Traits\Blameable;
/**
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\Column(type="string", length=25, unique=true)
*/
private $username;
/**
* @ORM\Column(type="string", length=64)
*/
private $password;
/**
* @ORM\Column(type="string", length=100)
*/
private $email;
/**
* @ORM\Column(name="is_active", type="boolean")
*/
private $isActive;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Role")
*/
private $role;
/**
* @ORM\Column(type="string", length=255)
*/
private $firstname;
/**
* @ORM\Column(type="string", length=255)
*/
private $lastname;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Log", mappedBy="user_crea")
*/
private $logs;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $cellphone;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $address;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $city;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $zipcode;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $avatar;
/**
* @ORM\OneToMany(targetEntity="App\Entity\HistoriquePage", mappedBy="user")
*/
private $historiquePages;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Langue")
*/
private $langue;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $uid;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Filtre", mappedBy="user")
*/
private $filtres;
/**
* @ORM\OneToMany(targetEntity=UserFilter::class, mappedBy="user")
*/
private $userFilters;
/**
* @ORM\OneToMany(targetEntity=Dossier::class, mappedBy="chargeDossier")
*/
private $dossiers;
/**
* @ORM\OneToMany(targetEntity=Dossier::class, mappedBy="chargeDossier2")
*/
private $dossiers2;
/**
* @ORM\OneToMany(targetEntity=TableauBordRequeteUser::class, mappedBy="user")
*/
private $tableauBordRequeteUsers;
/**
* @ORM\OneToMany(targetEntity=DossierSegmentTodo::class, mappedBy="responsable")
*/
private $dossierSegmentTodos;
public function __construct()
{
$this->isActive = true;
$this->logs = new ArrayCollection();
$this->historiquePages = new ArrayCollection();
$this->filtres = new ArrayCollection();
// may not be needed, see section on salt below
// $this->salt = md5(uniqid('', true));
$this->userFilters = new ArrayCollection();
$this->dossiers = new ArrayCollection();
$this->dossiers2 = new ArrayCollection();
$this->tableauBordRequeteUsers = new ArrayCollection();
$this->dossierSegmentTodos = new ArrayCollection();
}
public function __toString()
{
return $this->firstname . " " . $this->lastname;
}
public function getUsername()
{
return $this->username;
}
public function getSalt()
{
// you *may* need a real salt depending on your encoder
// see section on salt below
return null;
}
public function getPassword()
{
return $this->password;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
return array('ROLE_USER', 'ROLE_API');
}
public function getRole(): ?Role
{
return $this->role;
}
public function setRole(?Role $role): self
{
$this->role = $role;
return $this;
}
public function eraseCredentials()
{
}
/** @see \Serializable::serialize() */
public function serialize()
{
return serialize(array(
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt,
));
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
list (
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt
) = unserialize($serialized);
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
/**
* @return Collection|Log[]
*/
public function getLogs(): Collection
{
return $this->logs;
}
public function addLog(Log $log): self
{
if (!$this->logs->contains($log)) {
$this->logs[] = $log;
$log->setUserCrea($this);
}
return $this;
}
public function removeLog(Log $log): self
{
if ($this->logs->contains($log)) {
$this->logs->removeElement($log);
// set the owning side to null (unless already changed)
if ($log->getUserCrea() === $this) {
$log->setUserCrea(null);
}
}
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getCellphone(): ?string
{
return $this->cellphone;
}
public function setCellphone(?string $cellphone): self
{
$this->cellphone = $cellphone;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getZipcode(): ?string
{
return $this->zipcode;
}
public function setZipcode(?string $zipcode): self
{
$this->zipcode = $zipcode;
return $this;
}
public function getAvatar()
{
return $this->avatar;
}
public function setAvatar( $avatar): self
{
$this->avatar = $avatar;
return $this;
}
/**
* @return Collection|HistoriquePage[]
*/
public function getHistoriquePages(): Collection
{
return $this->historiquePages;
}
public function addHistoriquePage(HistoriquePage $historiquePage): self
{
if (!$this->historiquePages->contains($historiquePage)) {
$this->historiquePages[] = $historiquePage;
$historiquePage->setUser($this);
}
return $this;
}
public function removeHistoriquePage(HistoriquePage $historiquePage): self
{
if ($this->historiquePages->contains($historiquePage)) {
$this->historiquePages->removeElement($historiquePage);
// set the owning side to null (unless already changed)
if ($historiquePage->getUser() === $this) {
$historiquePage->setUser(null);
}
}
return $this;
}
public function getLangue(): ?Langue
{
return $this->langue;
}
public function setLangue(?Langue $langue): self
{
$this->langue = $langue;
return $this;
}
public function postFlush(PostFlushEventArgs $eventArgs){
die('test');
}
public function getUid(): ?int
{
return $this->uid;
}
public function setUid(?int $uid): self
{
$this->uid = $uid;
return $this;
}
/**
* @return Collection|Filtre[]
*/
public function getFiltres(): Collection
{
return $this->filtres;
}
public function addFiltre(Filtre $filtre): self
{
if (!$this->filtres->contains($filtre)) {
$this->filtres[] = $filtre;
$filtre->setUser($this);
}
return $this;
}
public function removeFiltre(Filtre $filtre): self
{
if ($this->filtres->contains($filtre)) {
$this->filtres->removeElement($filtre);
// set the owning side to null (unless already changed)
if ($filtre->getUser() === $this) {
$filtre->setUser(null);
}
}
return $this;
}
/**
* @return Collection|UserFilters[]
*/
public function getUserFilters(): Collection
{
return $this->userFilters;
}
public function addUserFilter(UserFilter $userFilter): self
{
if (!$this->userFilters->contains($userFilter)) {
$this->userFilters[] = $userFilter;
$userFilter->setUser($this);
}
return $this;
}
public function removeUserFilter(UserFilter $userFilter): self
{
if ($this->userFilters->contains($userFilter)) {
$this->userFilters->removeElement($userFilter);
// set the owning side to null (unless already changed)
if ($userFilter->getUser() === $this) {
$userFilter->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Dossier[]
*/
public function getDossiers(): Collection
{
return $this->dossiers;
}
public function addDossier(Dossier $dossier): self
{
if (!$this->dossiers->contains($dossier)) {
$this->dossiers[] = $dossier;
$dossier->setChargeDossier($this);
}
return $this;
}
public function removeDossier(Dossier $dossier): self
{
if ($this->dossiers->contains($dossier)) {
$this->dossiers->removeElement($dossier);
// set the owning side to null (unless already changed)
if ($dossier->getChargeDossier() === $this) {
$dossier->setChargeDossier(null);
}
}
return $this;
}
/**
* @return Collection|Dossier[]
*/
public function getDossiers2(): Collection
{
return $this->dossiers2;
}
public function addDossiers2(Dossier $dossiers2): self
{
if (!$this->dossiers2->contains($dossiers2)) {
$this->dossiers2[] = $dossiers2;
$dossiers2->setChargeDossier2($this);
}
return $this;
}
public function removeDossiers2(Dossier $dossiers2): self
{
if ($this->dossiers2->contains($dossiers2)) {
$this->dossiers2->removeElement($dossiers2);
// set the owning side to null (unless already changed)
if ($dossiers2->getChargeDossier2() === $this) {
$dossiers2->setChargeDossier2(null);
}
}
return $this;
}
/**
* @return Collection|TableauBordRequeteUser[]
*/
public function getTableauBordRequeteUsers(): Collection
{
return $this->tableauBordRequeteUsers;
}
public function addTableauBordRequeteUser(TableauBordRequeteUser $tableauBordRequeteUser): self
{
if (!$this->tableauBordRequeteUsers->contains($tableauBordRequeteUser)) {
$this->tableauBordRequeteUsers[] = $tableauBordRequeteUser;
$tableauBordRequeteUser->setUser($this);
}
return $this;
}
public function removeTableauBordRequeteUser(TableauBordRequeteUser $tableauBordRequeteUser): self
{
if ($this->tableauBordRequeteUsers->contains($tableauBordRequeteUser)) {
$this->tableauBordRequeteUsers->removeElement($tableauBordRequeteUser);
// set the owning side to null (unless already changed)
if ($tableauBordRequeteUser->getUser() === $this) {
$tableauBordRequeteUser->setUser(null);
}
}
return $this;
}
/**
* @return Collection|DossierSegmentTodo[]
*/
public function getDossierSegmentTodos(): Collection
{
return $this->dossierSegmentTodos;
}
public function addDossierSegmentTodo(DossierSegmentTodo $dossierSegmentTodo): self
{
if (!$this->dossierSegmentTodos->contains($dossierSegmentTodo)) {
$this->dossierSegmentTodos[] = $dossierSegmentTodo;
$dossierSegmentTodo->setResponsable($this);
}
return $this;
}
public function removeDossierSegmentTodo(DossierSegmentTodo $dossierSegmentTodo): self
{
if ($this->dossierSegmentTodos->contains($dossierSegmentTodo)) {
$this->dossierSegmentTodos->removeElement($dossierSegmentTodo);
// set the owning side to null (unless already changed)
if ($dossierSegmentTodo->getResponsable() === $this) {
$dossierSegmentTodo->setResponsable(null);
}
}
return $this;
}
}
?>