<?php
namespace App\Entity;
use App\Entity\Media\Media;
use App\Entity\Media\MediaBlockedByUser;
use App\Entity\Media\MediaTeam;
use App\Entity\Post\PostHiddenByUser;
use App\Entity\Program\ProgramBlockedByUser;
use App\Entity\Program\ProgramCrewMember;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use App\Entity\User\Wallet;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @ORM\HasLifecycleCallbacks()
*/
class User extends BaseEntity implements UserInterface
{
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="boolean", options={"default" = false})
*/
private $emailConfirmed;
/**
* @ORM\Column(type="boolean", options={"default" = false})
*/
private $hideEmail;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $emailConfirmedRecover;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $username;
/**
* @ORM\Column(type="string", length=180, nullable=true)
*/
private $firstname;
/**
* @ORM\Column(type="string", length=180, nullable=true)
*/
private $tel;
/**
* @ORM\Column(type="string", length=180, nullable=true)
*/
private $address;
/**
* @ORM\Column(type="string", length=180, nullable=true)
*/
private $website;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $following;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $participations;
/**
* @ORM\Column(type="string", length=180, nullable=true)
*/
private $lastname;
/**
* @ORM\Column(type="json", length=255, nullable=true)
*/
private $languages;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string", nullable=true)
*/
private $password;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $picture;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Program\ProgramCrewMember",mappedBy="user",cascade={"persist"})
*/
private $crews;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Media\MediaTeam", mappedBy="user",cascade={"persist"})
*/
private $mediaTeams;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Media\Media", mappedBy="createdBy")
*/
private $mediasCreated;
/**
* @ORM\Column(type="string", unique=true, nullable=true)
*/
private $apiToken;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $facebook;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $facebookId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $facebookToken;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $googleId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $googleToken;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $instagram;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $instagramId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $instagramToken;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $twitter;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $twitterId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $twitterToken;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $snapchat;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $snapchatId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $snapchatToken;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $youtube;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $youtubeId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $youtubeToken;
/**
* @ORM\Column(type="string", length=255, nullable=true))
*/
private $passwordRecover;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $lastLogin;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $dateOfBirth;
/**
* @ORM\Column(type="string", length=255, nullable=true))
*/
private $nationality;
//Postal address
/**
* @ORM\Column(type="string", length=255, nullable=true)
* pays
*/
private $country;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private $zone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $zipCode;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $address1;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $address2;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $address3;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $civility;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $city;
/**
* @ORM\OneToOne(targetEntity=Adhesion::class, mappedBy="user", cascade={"persist", "remove"})
*/
private $adhesion;
/**
* @ORM\OneToOne(targetEntity=Wallet::class, mappedBy="user", cascade={"persist", "remove"})
*/
private $wallet;
/**
* @ORM\OneToMany(targetEntity=Shortcut::class, mappedBy="user")
*/
private $shortcuts;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Media\MediaBlockedByUser", mappedBy="user")
*/
private $mediasBlockedByUser;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Program\ProgramBlockedByUser", mappedBy="user")
*/
private $programsBlockedByUser;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Post\PostHiddenByUser", mappedBy="user")
*/
private $postsHiddenByUser;
/**
* @ORM\OneToMany(targetEntity="App\Entity\UserBlockedByUser", mappedBy="madeBy")
*/
private $usersBlockedByUser;
public function __construct()
{
$this->mediaTeams = new ArrayCollection();
$this->mediasCreated = new ArrayCollection();
$this->crews = new ArrayCollection();
$this->emailConfirmed = false;
$this->shortcuts = new ArrayCollection();
$this->mediasBlockedByUser = new ArrayCollection();
$this->programsBlockedByUser = new ArrayCollection();
$this->postsHiddenByUser = new ArrayCollection();
$this->usersBlockedByUser = new ArrayCollection();
$this->hideEmail = false;
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->username;
}
/**
* Stable identifier used by Symfony's authenticator manager.
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @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 addRole(string $role): self
{
$this->roles[] = $role;
return $this;
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function hasRole(string $role): bool
{
return in_array($role, $this->roles);
}
public function removeRole(string $role): self
{
if (($key = array_search($role, $this->roles)) !== false) {
unset($this->roles[$key]);
}
return $this;
}
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}
public function setPassword(?string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function getSalt(): ?string
{
// not needed when using the "bcrypt" algorithm in security.yaml
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials(): void
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection|MediaTeam[]
*/
public function getMediaTeams(): Collection
{
return $this->mediaTeams;
}
public function addMediaTeam(MediaTeam $mediaTeam): self
{
if (!$this->mediaTeams->contains($mediaTeam)) {
$this->mediaTeams[] = $mediaTeam;
$mediaTeam->setUser($this);
}
return $this;
}
public function removeMediaTeam(MediaTeam $mediaTeam): self
{
if ($this->mediaTeams->contains($mediaTeam)) {
$this->mediaTeams->removeElement($mediaTeam);
// set the owning side to null (unless already changed)
if ($mediaTeam->getUser() === $this) {
$mediaTeam->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Media[]
*/
public function getMediasCreated(): Collection
{
return $this->mediasCreated;
}
public function addMediasCreated(Media $mediasCreated): self
{
if (!$this->mediasCreated->contains($mediasCreated)) {
$this->mediasCreated[] = $mediasCreated;
$mediasCreated->setCreatedBy($this);
}
return $this;
}
public function removeMediasCreated(Media $mediasCreated): self
{
if ($this->mediasCreated->contains($mediasCreated)) {
$this->mediasCreated->removeElement($mediasCreated);
// set the owning side to null (unless already changed)
if ($mediasCreated->getCreatedBy() === $this) {
$mediasCreated->setCreatedBy(null);
}
}
return $this;
}
public function __toString(){
return $this->username;
}
public function getApiToken(): ?string
{
return $this->apiToken;
}
public function setApiToken(?string $apiToken): self
{
$this->apiToken = $apiToken;
return $this;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
public function getLanguages(): ?array
{
return $this->languages;
}
public function setLanguages(?array $languages): self
{
$this->languages = $languages;
return $this;
}
public function getFacebook(): ?string
{
return $this->facebook;
}
public function setFacebook(?string $facebook): self
{
$this->facebook = $facebook;
return $this;
}
public function getInstagram(): ?string
{
return $this->instagram;
}
public function setInstagram(?string $instagram): self
{
$this->instagram = $instagram;
return $this;
}
public function getTwitter(): ?string
{
return $this->twitter;
}
public function setTwitter(?string $twitter): self
{
$this->twitter = $twitter;
return $this;
}
public function getSnapchat(): ?string
{
return $this->snapchat;
}
public function setSnapchat(?string $snapchat): self
{
$this->snapchat = $snapchat;
return $this;
}
public function getYoutube(): ?string
{
return $this->youtube;
}
public function setYoutube(?string $youtube): self
{
$this->youtube = $youtube;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getTel(): ?string
{
return $this->tel;
}
public function setTel(string $tel): self
{
$this->tel = $tel;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getWebsite(): ?string
{
return $this->website;
}
public function setWebsite(string $website): self
{
$this->website = $website;
return $this;
}
public function getFollowing(): ?int
{
return $this->following;
}
public function setFollowing(int $following): self
{
$this->following = $following;
return $this;
}
public function getParticipations(): ?int
{
return $this->participations;
}
public function setParticipations(int $participations): self
{
$this->participations = $participations;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getFacebookId(): ?string
{
return $this->facebookId;
}
public function setFacebookId(?string $facebookId): self
{
$this->facebookId = $facebookId;
return $this;
}
public function getFacebookToken(): ?string
{
return $this->facebookToken;
}
public function setFacebookToken(?string $facebookToken): self
{
$this->facebookToken = $facebookToken;
return $this;
}
public function getInstagramId(): ?string
{
return $this->instagramId;
}
public function setInstagramId(?string $instagramId): self
{
$this->instagramId = $instagramId;
return $this;
}
public function getInstagramToken(): ?string
{
return $this->instagramToken;
}
public function setInstagramToken(?string $instagramToken): self
{
$this->instagramToken = $instagramToken;
return $this;
}
public function getTwitterId(): ?string
{
return $this->twitterId;
}
public function setTwitterId(?string $twitterId): self
{
$this->twitterId = $twitterId;
return $this;
}
public function getTwitterToken(): ?string
{
return $this->twitterToken;
}
public function setTwitterToken(?string $twitterToken): self
{
$this->twitterToken = $twitterToken;
return $this;
}
public function getSnapchatId(): ?string
{
return $this->snapchatId;
}
public function setSnapchatId(?string $snapchatId): self
{
$this->snapchatId = $snapchatId;
return $this;
}
public function getSnapchatToken(): ?string
{
return $this->snapchatToken;
}
public function setSnapchatToken(?string $snapchatToken): self
{
$this->snapchatToken = $snapchatToken;
return $this;
}
public function getYoutubeId(): ?string
{
return $this->youtubeId;
}
public function setYoutubeId(?string $youtubeId): self
{
$this->youtubeId = $youtubeId;
return $this;
}
public function getYoutubeToken(): ?string
{
return $this->youtubeToken;
}
public function setYoutubeToken(?string $youtubeToken): self
{
$this->youtubeToken = $youtubeToken;
return $this;
}
/**
* @return Collection|ProgramCrewMember[]
*/
public function getCrews(): Collection
{
return $this->crews;
}
public function addCrew(ProgramCrewMember $crew): self
{
if (!$this->crews->contains($crew)) {
$this->crews[] = $crew;
$crew->setUser($this);
}
return $this;
}
public function removeCrew(ProgramCrewMember $crew): self
{
if ($this->crews->contains($crew)) {
$this->crews->removeElement($crew);
// set the owning side to null (unless already changed)
if ($crew->getUser() === $this) {
$crew->setUser(null);
}
}
return $this;
}
public function getGoogleId(): ?string
{
return $this->googleId;
}
public function setGoogleId(?string $googleId): self
{
$this->googleId = $googleId;
return $this;
}
public function getGoogleToken(): ?string
{
return $this->googleToken;
}
public function setGoogleToken(?string $googleToken): self
{
$this->googleToken = $googleToken;
return $this;
}
public function getPasswordRecover(): ?string
{
return $this->passwordRecover;
}
public function setPasswordRecover(?string $passwordRecover): self
{
$this->passwordRecover = $passwordRecover;
return $this;
}
public function getEmailConfirmed(): ?bool
{
return $this->emailConfirmed;
}
public function setEmailConfirmed(bool $emailConfirmed): self
{
$this->emailConfirmed = $emailConfirmed;
return $this;
}
public function getEmailConfirmedRecover(): ?int
{
return $this->emailConfirmedRecover;
}
public function setEmailConfirmedRecover(?int $emailConfirmedRecover): self
{
$this->emailConfirmedRecover = $emailConfirmedRecover;
return $this;
}
public function getLastLogin(): ?\DateTimeInterface
{
return $this->lastLogin;
}
public function setLastLogin(?\DateTimeInterface $lastLogin): self
{
$this->lastLogin = $lastLogin;
return $this;
}
public function getDateOfBirth(): ?\DateTimeInterface
{
return $this->dateOfBirth;
}
public function setDateOfBirth(?\DateTimeInterface $dateOfBirth): self
{
$this->dateOfBirth = $dateOfBirth;
return $this;
}
public function getNationality(): ?string
{
return $this->nationality;
}
public function setNationality(?string $nationality): self
{
$this->nationality = $nationality;
return $this;
}
public function getZipCode(): ?string
{
return $this->zipCode;
}
public function setZipCode(?string $zipCode): self
{
$this->zipCode = $zipCode;
return $this;
}
public function getAddress1(): ?string
{
return $this->address1;
}
public function setAddress1(?string $address1): self
{
$this->address1 = $address1;
return $this;
}
public function getAddress2(): ?string
{
return $this->address2;
}
public function setAddress2(?string $address2): self
{
$this->address2 = $address2;
return $this;
}
public function getAddress3(): ?string
{
return $this->address3;
}
public function setAddress3(?string $address3): self
{
$this->address3 = $address3;
return $this;
}
public function getCivility(): ?int
{
return $this->civility;
}
public function setCivility(?int $civility): self
{
$this->civility = $civility;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getPicture(): ?string
{
return $this->picture;
}
public function setPicture(?string $picture): self
{
$this->picture = $picture;
return $this;
}
public function getAdhesion(): ?Adhesion
{
return $this->adhesion;
}
public function setAdhesion(Adhesion $adhesion): self
{
// set the owning side of the relation if necessary
if ($adhesion->getUser() !== $this) {
$adhesion->setUser($this);
}
$this->adhesion = $adhesion;
return $this;
}
/**
* @return Collection|Shortcut[]
*/
public function getShortcuts(): Collection
{
return $this->shortcuts;
}
public function addShortcut(Shortcut $shortcut): self
{
if (!$this->shortcuts->contains($shortcut)) {
$this->shortcuts[] = $shortcut;
$shortcut->setUser($this);
}
return $this;
}
public function removeShortcut(Shortcut $shortcut): self
{
if ($this->shortcuts->removeElement($shortcut)) {
// set the owning side to null (unless already changed)
if ($shortcut->getUser() === $this) {
$shortcut->setUser(null);
}
}
return $this;
}
public function getZone(): ?string
{
return $this->zone;
}
public function setZone(string $zone): self
{
$this->zone = $zone;
return $this;
}
/**
* @return Collection|MediaBlockedByUser[]
*/
public function getMediasBlockedByUser(): Collection
{
return $this->mediasBlockedByUser;
}
public function addMediasBlockedByUser(MediaBlockedByUser $mediasBlockedByUser): self
{
if (!$this->mediasBlockedByUser->contains($mediasBlockedByUser)) {
$this->mediasBlockedByUser[] = $mediasBlockedByUser;
$mediasBlockedByUser->setUser($this);
}
return $this;
}
public function removeMediasBlockedByUser(MediaBlockedByUser $mediasBlockedByUser): self
{
if ($this->mediasBlockedByUser->removeElement($mediasBlockedByUser)) {
// set the owning side to null (unless already changed)
if ($mediasBlockedByUser->getUser() === $this) {
$mediasBlockedByUser->setUser(null);
}
}
return $this;
}
/**
* @return Collection|ProgramBlockedByUser[]
*/
public function getProgramsBlockedByUser(): Collection
{
return $this->programsBlockedByUser;
}
public function addProgramsBlockedByUser(ProgramBlockedByUser $programsBlockedByUser): self
{
if (!$this->programsBlockedByUser->contains($programsBlockedByUser)) {
$this->programsBlockedByUser[] = $programsBlockedByUser;
$programsBlockedByUser->setUser($this);
}
return $this;
}
public function removeProgramsBlockedByUser(ProgramBlockedByUser $programsBlockedByUser): self
{
if ($this->programsBlockedByUser->removeElement($programsBlockedByUser)) {
// set the owning side to null (unless already changed)
if ($programsBlockedByUser->getUser() === $this) {
$programsBlockedByUser->setUser(null);
}
}
return $this;
}
/**
* @return Collection|PostHiddenByUser[]
*/
public function getPostsHiddenByUser(): Collection
{
return $this->postsHiddenByUser;
}
public function addPostsHiddenByUser(PostHiddenByUser $postsHiddenByUser): self
{
if (!$this->postsHiddenByUser->contains($postsHiddenByUser)) {
$this->postsHiddenByUser[] = $postsHiddenByUser;
$postsHiddenByUser->setUser($this);
}
return $this;
}
public function removePostsHiddenByUser(PostHiddenByUser $postsHiddenByUser): self
{
if ($this->postsHiddenByUser->removeElement($postsHiddenByUser)) {
// set the owning side to null (unless already changed)
if ($postsHiddenByUser->getUser() === $this) {
$postsHiddenByUser->setUser(null);
}
}
return $this;
}
/**
* @return Collection|User[]
*/
public function getUsersBlockedByUser(): Collection
{
return $this->usersBlockedByUser;
}
public function addUsersBlockedByUser(User $usersBlockedByUser): self
{
if (!$this->usersBlockedByUser->contains($usersBlockedByUser)) {
$this->usersBlockedByUser[] = $usersBlockedByUser;
$usersBlockedByUser->setUser($this);
}
return $this;
}
public function removeUsersBlockedByUser(User $usersBlockedByUser): self
{
if ($this->usersBlockedByUser->removeElement($usersBlockedByUser)) {
// set the owning side to null (unless already changed)
if ($usersBlockedByUser->getUser() === $this) {
$usersBlockedByUser->setUser(null);
}
}
return $this;
}
public function getHideEmail(): ?bool
{
return $this->hideEmail;
}
public function setHideEmail(bool $hideEmail): self
{
$this->hideEmail = $hideEmail;
return $this;
}
public function getWallet(): ?Wallet
{
return $this->wallet;
}
public function setWallet(?Wallet $wallet): self
{
// unset the owning side of the relation if necessary
if ($wallet === null && $this->wallet !== null) {
$this->wallet->setUser(null);
}
// set the owning side of the relation if necessary
if ($wallet !== null && $wallet->getUser() !== $this) {
$wallet->setUser($this);
}
$this->wallet = $wallet;
return $this;
}
}