<?php
namespace App\Entity;
use App\Annotation\SerializedNameGroups;
use App\Repository\TvUserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Index;
use Doctrine\ORM\Mapping\Table;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=TvUserRepository::class)
* @ORM\HasLifecycleCallbacks
* @Table(indexes={@Index(name="search_idx", columns={"id", "code"})})
* @UniqueEntity("username", message="user.username_unique")
*/
class TvUser implements UserInterface, PasswordAuthenticatedUserInterface
{
const QUOTA_DAY = 'daily';
const QUOTA_WEEK = 'weekly';
const QUOTA_MONTH = 'monthly';
const QUOTA_NONE = 'unset';
const STATUS_ACTIVE = 'active';
const STATUS_SUSPENDED = 'suspended';
const STATUSES = [
self::STATUS_ACTIVE,
self::STATUS_SUSPENDED,
];
const QUOTAS = [
self::QUOTA_DAY,
self::QUOTA_WEEK,
self::QUOTA_MONTH,
];
/**
* Associative array, keys are the quotas types (none excluded)
* values are the string to pass to a datetime object
*/
const QUOTAS_VAlUES = [
self::QUOTA_DAY => '1 day',
self::QUOTA_WEEK => '1 week',
self::QUOTA_MONTH => '1 month',
];
const ROLE_USER = 'ROLE_USER';
const ROLE_ADMIN = 'ROLE_ADMIN';
const ROLE_GOD = 'ROLE_GOD';
const ROLE_MANAGER = 'ROLE_MANAGER';
const ROLE_COMPANY_MANAGER = 'ROLE_COMPANY_MANAGER';
const ROLES = [
self::ROLE_ADMIN,
self::ROLE_GOD,
self::ROLE_USER,
self::ROLE_MANAGER,
self::ROLE_COMPANY_MANAGER,
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"tv_user_read", "tv_company_read", "export_tv_user_csv", "team_read", "team_user_read", "tv_user:read:form", "notification_read"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=false, unique=true)
* @Groups({"tv_user_read", "tv_company_read", "tv_user_creation", "export_tv_user_csv", "message_read", "tv_user_read_creation"})
* @SerializedNameGroups(name="Identifiant", groups={"tv_user_read_creation"})
*/
private $code;
/**
* @ORM\Column(type="string", length=180, unique=true)
* @Groups({"tv_user_read", "tv_user_creation", "tv_user_write", "team_read", "team_user_read", "tv_user:read:form", "notification_read"})
*/
private $username;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"tv_user_read", "tv_user_write", "team_read", "team_user_read"})
* @Assert\Email(message="user.email")
*/
private $email;
/**
* @ORM\Column(type="integer")
* @Groups({"tv_user_read", "tv_user_write", "export_tv_user_csv"})
*/
private $quotas = 0;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_user_read", "tv_user_write", "export_tv_user_csv"})
*/
private $quotasType = self::QUOTA_NONE;
/**
* @ORM\Column(type="boolean", options={"default": 1})
* @Groups({"tv_user_read", "tv_company_read", "export_tv_user_csv", "notification_read"})
*/
private $active = true;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
* @Groups({"tv_user_read"})
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
* @Groups({"tv_user_read"})
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $recoveryToken;
/**
* Property rendered public to use in security precept
* @var TvCompany
* @ORM\ManyToOne(targetEntity=TvCompany::class, inversedBy="tvUsers")
* @Groups({"tv_user_read", "tv_user_creation", "message_read", "tv_user_read_creation", "team_user_read"})
* @SerializedNameGroups(name="Entreprise", groups={"tv_user_read_creation"})
*/
public $tvCompany;
/**
* @ORM\OneToMany(targetEntity=Log::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $logs;
/**
* Sent messages by the tvUser to web admins
* @ORM\OneToMany(targetEntity=Message::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $messages;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"tv_user_read", "tv_company_read"})
*/
private $lastLogin;
/**
* @var string|null
* @Groups({"tv_user_creation", "tv_user_write", "tv_user_read_creation"})
* @Assert\Regex("/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/", message="user.password")
* @SerializedNameGroups(name="Mot-de-passe", groups={"tv_user_read_creation"})
*/
private $plainPassword = null;
/**
* @var string|null
* @Groups({"tv_user_creation", "tv_user_write"})
* @Assert\IdenticalTo(propertyPath="plainPassword", message="user.repeat_password")
*/
private $passwordConfirm = null;
/**
* @var bool
*/
public $isPopulated = false;
/**
* @ORM\OneToMany(targetEntity=VideoEvent::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $videoEvents;
/**
* @ORM\Column(type="boolean", options={"default": 0})
* @Groups({"tv_user_read", "tv_company_read", "tv_user_write"})
*/
private $newsletter = false;
/**
* @ORM\Column(type="boolean", options={"default": 1})
* @Groups({"tv_user_read", "tv_company_read", "tv_user_write"})
*/
private $firstLogin = true;
/**
* @ORM\Column(type="boolean", options={"default": 1})
* @Groups({"tv_user_read", "tv_company_read", "tv_user_write"})
*/
private $homeSurvey = true;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"tv_user_read", "tv_company_read"})
* @Gedmo\Timestampable(on="change", field="newsletter", value=true)
*/
private $newsletterDate;
/**
* @ORM\OneToMany(targetEntity=UserResponse::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $userResponses;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Timestampable(on="change", field="email")
*/
private $emailUpdatedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $emailValidatedAt;
/**
* @ORM\OneToMany(targetEntity=Favorite::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $favorites;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_user_read", "tv_company_read", "export_tv_user_csv"})
* @Assert\Choice(choices=self::STATUSES)
*/
private $status;
/**
* @ORM\ManyToOne(targetEntity=Department::class, inversedBy="tvUsers")
* @Groups({"tv_user_read", "tv_user_write"})
*/
private $department;
/**
* @ORM\OneToMany(targetEntity=LogEmail::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $logEmails;
/**
* @ORM\OneToMany(targetEntity=Channel::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $channels;
/**
* @ORM\ManyToMany(targetEntity=Objective::class, mappedBy="tvUsers")
*/
private $objectives;
/**
* @ORM\ManyToOne(targetEntity=Association::class, inversedBy="tvUsers")
* @Groups({"tv_user_read", "tv_user_write", "tv_company_read"})
*/
private $association;
/**
* @ORM\OneToMany(targetEntity=TeamUser::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $teamUsers;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": "1"})
* @Groups({"tv_user_read", "tv_user_write", "tuto_only"})
*/
private $displayTeamplayTuto = true;
/**
* @ORM\OneToMany(targetEntity=TeamplayLog::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $teamplayLogs;
/**
* @ORM\OneToMany(targetEntity=PedometerLog::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $pedometerLogs;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"tv_user_read", "tv_user_write"})
*/
private $deviceOs;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({"tv_user_read", "tv_user_write"})
*/
private $deviceToken;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"tv_user_read", "tv_user_write"})
*/
private $deviceName;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": 1})
* @Groups({"tv_user_read", "tv_user_write"})
*/
private $deviceActive = true;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Timestampable(on="change", field={"deviceOs", "deviceToken", "deviceName", "deviceActive"})
* @Groups({"tv_user_read", "tv_user_write"})
*/
private $deviceUpdate;
/**
* @ORM\OneToMany(targetEntity=UserNotification::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $userNotifications;
/**
* @ORM\OneToMany(targetEntity=UserDevice::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $devices;
/**
* @ORM\OneToMany(targetEntity=AwardLog::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $awardLogs;
/**
* @ORM\OneToMany(targetEntity=UserVideoTimecode::class, mappedBy="tvUser", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $userVideoTimecodes;
/**
* @ORM\OneToMany(targetEntity=Notation::class, mappedBy="tvUser", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $notations;
/**
* @ORM\OneToMany(targetEntity=VideoLastValidate::class, mappedBy="tvUser", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $videoLastValidates;
/**
* @ORM\OneToMany(targetEntity=VideoLastSeen::class, mappedBy="tvUser", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $videoLastSeens;
/**
* @ORM\OneToMany(targetEntity=MoodResponse::class, mappedBy="tvUser", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $moodResponses;
/**
* @ORM\OneToMany(targetEntity=ProgramEvent::class, mappedBy="tvUser", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $programEvents;
/**
* @ORM\OneToMany(targetEntity=DayEvent::class, mappedBy="tvUser", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $dayEvents;
/**
* @ORM\OneToOne(targetEntity=User::class, inversedBy="tvUser")
*/
private $user;
public function __construct()
{
$this->logs = new ArrayCollection();
$this->messages = new ArrayCollection();
$this->videoEvents = new ArrayCollection();
$this->roles = [self::ROLE_USER];
$this->userResponses = new ArrayCollection();
$this->favorites = new ArrayCollection();
$this->logEmails = new ArrayCollection();
$this->channels = new ArrayCollection();
$this->objectives = new ArrayCollection();
$this->teamUsers = new ArrayCollection();
$this->teams = new ArrayCollection();
$this->teamplayLogs = new ArrayCollection();
$this->pedometerLogs = new ArrayCollection();
$this->userNotifications = new ArrayCollection();
$this->devices = new ArrayCollection();
$this->awardLogs = new ArrayCollection();
$this->userVideoTimecodes = new ArrayCollection();
$this->notations = new ArrayCollection();
$this->videoLastValidates = new ArrayCollection();
$this->videoLastSeens = new ArrayCollection();
$this->moodResponses = new ArrayCollection();
$this->programEvents = new ArrayCollection();
$this->dayEvents = new ArrayCollection();
}
public function __toString(): string
{
return "#{$this->getId()} - {$this->getUsername()}";
}
public function getId(): ?int
{
return $this->id;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string)$this->getUsername();
}
/**
* A visual identifier that represents this tvUser.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string)$this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every tvUser at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
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()
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the tvUser, clear it here
$this->plainPassword = null;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getQuotas(): ?int
{
return $this->quotas;
}
public function setQuotas(int $quotas): self
{
$this->quotas = $quotas;
return $this;
}
public function getQuotasType(): ?string
{
return $this->quotasType;
}
public function setQuotasType(string $quotasType): self
{
$this->quotasType = $quotasType;
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
if ($this->active){
$this->status = self::STATUS_ACTIVE;
}else{
$this->status = self::STATUS_SUSPENDED;
}
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getRecoveryToken(): ?string
{
return $this->recoveryToken;
}
public function setRecoveryToken(?string $recoveryToken): self
{
$this->recoveryToken = $recoveryToken;
return $this;
}
public function getTvCompany(): ?TvCompany
{
return $this->tvCompany;
}
public function setTvCompany(?TvCompany $tvCompany): self
{
$this->tvCompany = $tvCompany;
return $this;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps(): void
{
$this->setUpdatedAt(new \DateTime('now'));
if ($this->getCreatedAt() === null) {
$this->setCreatedAt(new \DateTime('now'));
}
}
/**
* @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->setTvUser($this);
}
return $this;
}
public function removeLog(Log $log): self
{
if ($this->logs->removeElement($log)) {
// set the owning side to null (unless already changed)
if ($log->getTvUser() === $this) {
$log->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|Message[]
*/
public function getMessages(): Collection
{
return $this->messages;
}
public function addMessage(Message $message): self
{
if (!$this->messages->contains($message)) {
$this->messages[] = $message;
$message->setTvUser($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->getTvUser() === $this) {
$message->setTvUser(null);
}
}
return $this;
}
/**
* @return \DateTime|null
*/
public function getLastLogin(): ?\DateTime
{
return $this->lastLogin;
}
/**
* @param string|null $code
* @return TvUser
*/
public function setCode(?string $code): TvUser
{
$this->code = $code;
return $this;
}
/**
* @return string|null
*/
public function getCode(): ?string
{
return $this->code;
}
/**
* @param string $role
* @return bool
*/
public function hasRole(string $role)
{
return in_array($role, $this->roles);
}
/**
* Updates the tvCompany according to the status of the order
* @return TvUser
* @ORM\PrePersist
*/
public function updateTvCompany(): self
{
if ($this->tvCompany instanceof TvCompany) {
$this->tvCompany->setTvUsersCount($this->tvCompany->getTvUsersCount() + 1);
}
return $this;
}
public function setLastLogin(?\DateTimeInterface $lastLogin): self
{
$this->lastLogin = $lastLogin;
return $this;
}
/**
* If persisted this password will be encoded into the password field
* @param string $password
* @return $this
*/
public function setPlainPassword(string $password): TvUser
{
$this->plainPassword = $password;
return $this;
}
/**
* @return string
*/
public function getPlainPassword(): ?string
{
return $this->plainPassword;
}
/**
* @return Collection|VideoEvent[]
*/
public function getVideoEvents(): Collection
{
return $this->videoEvents;
}
public function addVideoEvent(VideoEvent $videoEvent): self
{
if (!$this->videoEvents->contains($videoEvent)) {
$this->videoEvents[] = $videoEvent;
$videoEvent->setTvUser($this);
}
return $this;
}
public function removeVideoEvent(VideoEvent $videoEvent): self
{
if ($this->videoEvents->removeElement($videoEvent)) {
// set the owning side to null (unless already changed)
if ($videoEvent->getTvUser() === $this) {
$videoEvent->setTvUser(null);
}
}
return $this;
}
/**
* Checks the quotas of a tvUser
* @return bool true if ok, false if not ok
*/
public function checkQuotas(): bool
{
$result = true;
if ($this->getQuotasType() != self::QUOTA_NONE){
$span = self::QUOTAS_VAlUES[$this->getQuotasType()];
$limit = new \DateTime("-$span");
$count = 0;
foreach ($this->getVideoEvents() as $videoEvent) {
if ($limit->diff($videoEvent->getCreatedAt())->invert == 0){
$count += $videoEvent->getValue();
}
}
if ($count > $this->getQuotas()){
$result = false;
}
}
return $result;
}
public function getNewsletter(): ?bool
{
return $this->newsletter;
}
public function setNewsletter(bool $newsletter): self
{
$this->newsletter = $newsletter;
return $this;
}
public function getNewsletterDate(): ?\DateTimeInterface
{
return $this->newsletterDate;
}
public function setNewsletterDate(?\DateTimeInterface $newsletterDate): self
{
$this->newsletterDate = $newsletterDate;
return $this;
}
/**
* @return Collection|UserResponse[]
*/
public function getUserResponses(): Collection
{
return $this->userResponses;
}
public function addUserResponse(UserResponse $userResponse): self
{
if (!$this->userResponses->contains($userResponse)) {
$this->userResponses[] = $userResponse;
$userResponse->setTvUser($this);
}
return $this;
}
public function removeUserResponse(UserResponse $userResponse): self
{
if ($this->userResponses->removeElement($userResponse)) {
// set the owning side to null (unless already changed)
if ($userResponse->getTvUser() === $this) {
$userResponse->setTvUser(null);
}
}
return $this;
}
public function getEmailUpdatedAt(): ?\DateTimeInterface
{
return $this->emailUpdatedAt;
}
public function setEmailUpdatedAt(?\DateTimeInterface $emailUpdatedAt): self
{
$this->emailUpdatedAt = $emailUpdatedAt;
return $this;
}
public function getEmailValidatedAt(): ?\DateTimeInterface
{
return $this->emailValidatedAt;
}
public function setEmailValidatedAt(?\DateTimeInterface $emailValidatedAt): self
{
$this->emailValidatedAt = $emailValidatedAt;
return $this;
}
/**
* Checks if the email is validated
* @return bool
*/
public function isEmailValidated(): bool
{
return ($this->emailValidatedAt !== null);
}
/**
* @param bool $firstLogin
* @return TvUser
*/
public function setFirstLogin(bool $firstLogin): TvUser
{
$this->firstLogin = $firstLogin;
return $this;
}
/**
* @return bool
*/
public function isFirstLogin(): bool
{
return $this->firstLogin;
}
/**
* @param bool $homeSurvey
* @return TvUser
*/
public function setHomeSurvey(bool $homeSurvey): TvUser
{
$this->homeSurvey = $homeSurvey;
return $this;
}
/**
* @return bool
*/
public function isHomeSurvey(): bool
{
return $this->homeSurvey;
}
/**
* @return Collection|Favorite[]
*/
public function getFavorites(): Collection
{
return $this->favorites;
}
public function addFavorite(Favorite $favorite): self
{
if (!$this->favorites->contains($favorite)) {
$this->favorites[] = $favorite;
}
return $this;
}
public function removeFavorite(Favorite $favorite): self
{
$this->favorites->removeElement($favorite);
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
/**
* @return string|null
*/
public function getPasswordConfirm(): ?string
{
return $this->passwordConfirm;
}
/**
* @param string|null $passwordConfirm
* @return TvUser
*/
public function setPasswordConfirm(?string $passwordConfirm): TvUser
{
$this->passwordConfirm = $passwordConfirm;
return $this;
}
public function getDepartment(): ?Department
{
return $this->department;
}
public function setDepartment(?Department $department): self
{
$this->department = $department;
return $this;
}
/**
* @return Collection|LogEmail[]
*/
public function getLogEmails(): Collection
{
return $this->logEmails;
}
public function addLogEmail(LogEmail $logEmail): self
{
if (!$this->logEmails->contains($logEmail)) {
$this->logEmails[] = $logEmail;
$logEmail->setTvUser($this);
}
return $this;
}
public function removeLogEmail(LogEmail $logEmail): self
{
if ($this->logEmails->removeElement($logEmail)) {
// set the owning side to null (unless already changed)
if ($logEmail->getTvUser() === $this) {
$logEmail->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|Channel[]
*/
public function getChannels(): Collection
{
return $this->channels;
}
public function addChannel(Channel $channel): self
{
if (!$this->channels->contains($channel)) {
$this->channels[] = $channel;
$channel->setTvUser($this);
}
return $this;
}
public function removeChannel(Channel $channel): self
{
if ($this->channels->removeElement($channel)) {
// set the owning side to null (unless already changed)
if ($channel->getTvUser() === $this) {
$channel->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|Objective[]
*/
public function getObjectives(): Collection
{
return $this->objectives;
}
/**
* @return Collection|Objective[]
* @Groups({"tv_user_write"})
*/
public function setObjectives(Collection $objectives): self
{
$this->objectives = $objectives;
return $this;
}
public function addObjective(Objective $objective): self
{
if (!$this->objectives->contains($objective)) {
$this->objectives[] = $objective;
$objective->addTvUser($this);
}
return $this;
}
public function removeObjective(Objective $objective): self
{
if ($this->objectives->removeElement($objective)) {
$objective->removeTvUser($this);
}
return $this;
}
public function getAssociation(): ?Association
{
return $this->association;
}
public function setAssociation(?Association $association): self
{
$this->association = $association;
return $this;
}
/**
* @return Collection|TeamUser[]
*/
public function getTeamUsers(): Collection
{
return $this->teamUsers;
}
public function addTeamUser(TeamUser $teamUser): self
{
if (!$this->teamUsers->contains($teamUser)) {
$this->teamUsers[] = $teamUser;
$teamUser->setTvUser($this);
}
return $this;
}
public function removeTeamUser(TeamUser $teamUser): self
{
if ($this->teamUsers->removeElement($teamUser)) {
// set the owning side to null (unless already changed)
if ($teamUser->getTvUser() === $this) {
$teamUser->setTvUser(null);
}
}
return $this;
}
/**
* Récupére un tableau de Team
* @return Collection|Team[]|null
*/
public function getTeams(): ?Collection
{
$teams = null;
if(!$this->teamUsers->isEmpty()) {
$teams = new ArrayCollection([]);
foreach ($this->teamUsers->toArray() as $teamUser) {
if($teamUser->getTeam() instanceof Team) {
$teams->add($teamUser->getTeam());
}
}
}
return $teams;
}
public function getDisplayTeamplayTuto(): ?bool
{
return $this->displayTeamplayTuto;
}
public function setDisplayTeamplayTuto(?bool $displayTeamplayTuto): self
{
$this->displayTeamplayTuto = $displayTeamplayTuto;
return $this;
}
/**
* @return Collection|TeamplayLog[]
*/
public function getTeamplayLogs(): Collection
{
return $this->teamplayLogs;
}
public function addTeamplayLog(TeamplayLog $teamplayLog): self
{
if (!$this->teamplayLogs->contains($teamplayLog)) {
$this->teamplayLogs[] = $teamplayLog;
$teamplayLog->setTvUser($this);
}
return $this;
}
public function removeTeamplayLog(TeamplayLog $teamplayLog): self
{
if ($this->teamplayLogs->removeElement($teamplayLog)) {
// set the owning side to null (unless already changed)
if ($teamplayLog->getTvUser() === $this) {
$teamplayLog->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|PedometerLog[]
*/
public function getPedometerLogs(): Collection
{
return $this->pedometerLogs;
}
public function addPedometerLog(PedometerLog $pedometerLog): self
{
if (!$this->pedometerLogs->contains($pedometerLog)) {
$this->pedometerLogs[] = $pedometerLog;
$pedometerLog->setTvUser($this);
}
return $this;
}
public function removePedometerLog(PedometerLog $pedometerLog): self
{
if ($this->pedometerLogs->removeElement($pedometerLog)) {
// set the owning side to null (unless already changed)
if ($pedometerLog->getTvUser() === $this) {
$pedometerLog->setTvUser(null);
}
}
return $this;
}
public function getDeviceOs(): ?string
{
return $this->deviceOs;
}
public function setDeviceOs(?string $deviceOs): self
{
$this->deviceOs = $deviceOs;
return $this;
}
public function getDeviceToken(): ?string
{
return $this->deviceToken;
}
public function setDeviceToken(?string $deviceToken): self
{
$this->deviceToken = $deviceToken;
return $this;
}
public function getDeviceName(): ?string
{
return $this->deviceName;
}
public function setDeviceName(?string $deviceName): self
{
$this->deviceName = $deviceName;
return $this;
}
public function isDeviceActive(): ?bool
{
return $this->deviceActive;
}
public function setDeviceActive(?bool $deviceActive): self
{
$this->deviceActive = $deviceActive;
return $this;
}
public function getDeviceUpdate(): ?\DateTimeInterface
{
return $this->deviceUpdate;
}
public function setDeviceUpdate(?\DateTimeInterface $deviceUpdate): self
{
$this->deviceUpdate = $deviceUpdate;
return $this;
}
/**
* @return Collection<int, UserNotification>
*/
public function getUserNotifications(): Collection
{
return $this->userNotifications;
}
public function addUserNotification(UserNotification $userNotification): self
{
if (!$this->userNotifications->contains($userNotification)) {
$this->userNotifications[] = $userNotification;
$userNotification->setTvUser($this);
}
return $this;
}
public function removeUserNotification(UserNotification $userNotification): self
{
if ($this->userNotifications->removeElement($userNotification)) {
// set the owning side to null (unless already changed)
if ($userNotification->getTvUser() === $this) {
$userNotification->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection<int, UserDevice>
*/
public function getDevices(): Collection
{
return $this->devices;
}
public function addDevice(UserDevice $device): self
{
if (!$this->devices->contains($device)) {
$this->devices[] = $device;
$device->setTvUser($this);
}
return $this;
}
public function removeDevice(UserDevice $device): self
{
if ($this->devices->removeElement($device)) {
// set the owning side to null (unless already changed)
if ($device->getTvUser() === $this) {
$device->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|AwardLog[]
*/
public function getAwardLogs(): Collection
{
return $this->awardLogs;
}
public function addAwardLog(AwardLog $awardLog): self
{
if (!$this->awardLogs->contains($awardLog)) {
$this->awardLogs[] = $awardLog;
$awardLog->setTvUser($this);
}
return $this;
}
public function removeAwardLog(AwardLog $awardLog): self
{
if ($this->awardLogs->removeElement($awardLog)) {
// set the owning side to null (unless already changed)
if ($awardLog->getTvUser() === $this) {
$awardLog->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|UserVideoTimecode[]
*/
public function getUserVideoTimecodes(): Collection
{
return $this->userVideoTimecodes;
}
public function addUserVideoTimecode(UserVideoTimecode $userVideoTimecode): self
{
if (!$this->userVideoTimecodes->contains($userVideoTimecode)) {
$this->userVideoTimecodes[] = $userVideoTimecode;
$userVideoTimecode->setTvUser($this);
}
return $this;
}
public function removeUserVideoTimecode(UserVideoTimecode $userVideoTimecode): self
{
if ($this->userVideoTimecodes->removeElement($userVideoTimecode)) {
// set the owning side to null (unless already changed)
if ($userVideoTimecode->getTvUser() === $this) {
$userVideoTimecode->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|Notation[]
*/
public function getNotations(): Collection
{
return $this->notations;
}
public function addNotation(Notation $notation): self
{
if (!$this->notations->contains($notation)) {
$this->notations[] = $notation;
$notation->setTvUser($this);
}
return $this;
}
public function removeNotation(Notation $notation): self
{
if ($this->notations->removeElement($notation)) {
// set the owning side to null (unless already changed)
if ($notation->getTvUser() === $this) {
$notation->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|VideoLastValidate[]
*/
public function getVideoLastValidates(): Collection
{
return $this->videoLastValidates;
}
public function addVideoLastValidate(VideoLastValidate $videoLastValidate): self
{
if (!$this->videoLastValidates->contains($videoLastValidate)) {
$this->videoLastValidates[] = $videoLastValidate;
$videoLastValidate->setTvUser($this);
}
return $this;
}
public function removeVideoLastValidate(VideoLastValidate $videoLastValidate): self
{
if ($this->videoLastValidates->removeElement($videoLastValidate)) {
// set the owning side to null (unless already changed)
if ($videoLastValidate->getTvUser() === $this) {
$videoLastValidate->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|VideoLastSeen[]
*/
public function getVideoLastSeens(): Collection
{
return $this->videoLastSeens;
}
public function addVideoLastSeen(VideoLastSeen $videoLastSeen): self
{
if (!$this->videoLastSeens->contains($videoLastSeen)) {
$this->videoLastSeens[] = $videoLastSeen;
$videoLastSeen->setTvUser($this);
}
return $this;
}
public function removeVideoLastSeen(VideoLastSeen $videoLastSeen): self
{
if ($this->videoLastSeens->removeElement($videoLastSeen)) {
// set the owning side to null (unless already changed)
if ($videoLastSeen->getTvUser() === $this) {
$videoLastSeen->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|MoodResponse[]
*/
public function getMoodResponses(): Collection
{
return $this->moodResponses;
}
public function addMoodResponse(MoodResponse $moodResponse): self
{
if (!$this->moodResponses->contains($moodResponse)) {
$this->moodResponses[] = $moodResponse;
$moodResponse->setTvUser($this);
}
return $this;
}
public function removeMoodResponse(MoodResponse $moodResponse): self
{
if ($this->moodResponses->removeElement($moodResponse)) {
// set the owning side to null (unless already changed)
if ($moodResponse->getTvUser() === $this) {
$moodResponse->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|ProgramEvent[]
*/
public function getProgramEvents(): Collection
{
return $this->programEvents;
}
public function addProgramEvent(ProgramEvent $programEvent): self
{
if (!$this->programEvents->contains($programEvent)) {
$this->programEvents[] = $programEvent;
$programEvent->setTvUser($this);
}
return $this;
}
public function removeProgramEvent(ProgramEvent $programEvent): self
{
if ($this->programEvents->removeElement($programEvent)) {
// set the owning side to null (unless already changed)
if ($programEvent->getTvUser() === $this) {
$programEvent->setTvUser(null);
}
}
return $this;
}
/**
* @return Collection|DayEvent[]
*/
public function getDayEvents(): Collection
{
return $this->dayEvents;
}
public function addDayEvent(DayEvent $dayEvent): self
{
if (!$this->dayEvents->contains($dayEvent)) {
$this->dayEvents[] = $dayEvent;
$dayEvent->setTvUser($this);
}
return $this;
}
public function removeDayEvent(DayEvent $dayEvent): self
{
if ($this->dayEvents->removeElement($dayEvent)) {
// set the owning side to null (unless already changed)
if ($dayEvent->getTvUser() === $this) {
$dayEvent->setTvUser(null);
}
}
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
}