<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\ExistsFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Core\Serializer\Filter\GroupFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use App\Annotation\SerializedNameGroups;
use App\Repository\UserRepository;
use App\Service\ToolsService;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Hslavich\OneloginSamlBundle\Security\User\SamlUserInterface;
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\Security\Core\Validator\Constraints as SecurityAssert;
use Symfony\Component\Validator\Constraints as Assert;
use App\Entity\NotificationPreference;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Table(name="`user`")
* @ApiResource(
* normalizationContext={"groups"={"user:read"}},
* denormalizationContext={"groups"={"user:write"}},
* subresourceOperations={
* "users_favorites_get_subresource"={
* "security"="is_granted('ROLE_ADMIN') or object == user"
* }
* },
* itemOperations={
* "get"={
* "security"="is_granted('ROLE_USER')",
* "security_message"="You are not allowed to access this ressource"
* },
* "patch"={
* "security"="is_granted('ROLE_ADMIN') or is_granted('ROLE_COMPANY') or user == object"
* },
* "update_password"={
* "method"="PATCH",
* "input"="App\Dto\Security\PasswordUpdate",
* "controller"="App\Controller\Api\UserController::updatePassword",
* "path"="/users/{id}/update-pwd",
* "security"="is_granted('ROLE_USER') and user.getId() === object.getId()",
* "openapi_context"={
* "description" = "Updates pwd for the current user, it needs the current password, the new one and a confirmation of the new one",
* "summary" = "Updates pwd for the current user",
* },
* },
* },
* collectionOperations={
* "get"={
* "security"="is_granted('ROLE_USER')"
* },
* "tv_export"={
* "security"="is_granted('ROLE_ADMIN')",
* "method"="GET",
* "controller"="App\Controller\Api\TvUserController::extractCsv",
* "path"="/users/export",
* "formats"={"csv"={"text/csv"}},
* "pagination_enabled"=false,
* "output"=Company::class,
* "normalization_context"={"groups"={"user:read:export_csv"}}
* },
* "post"={
* "security"="is_granted('ROLE_ADMIN')",
* "normalization_context"={"groups"={"user:write:creation"}}
* },
* "api_users_import"={
* "route_name"="api_users_import",
* "description"="Import user",
* "method"="post",
* "openapi_context"={
* "description" = "This method imports a list of users from a csv",
* "summary" = "Imports several users",
* },
* "responses"={
* "200"={
* "description":"Users correctly created"
* }
* },
* }
* }
* )
* @ApiFilter(OrderFilter::class, properties={"id", "username", "code", "active", "lastLogin", "status", "quotas"})
* @ApiFilter(SearchFilter::class, properties={"code": "partial", "status": "exact", "id": "partial", "username": "partial", "email": "partial"})
* @ApiFilter(BooleanFilter::class, properties={"active", "newsletter"})
* @ApiFilter(ExistsFilter::class, properties={"deviceToken"})
* @ApiFilter(DateFilter::class, properties={"lastLogin"})
* @ApiFilter(GroupFilter::class,
* arguments={
* "parameterName": "groups",
* "overrideDefaultGroups": true,
* "whitelist": {"user:read:tuto_only", "user:read:form"}
* }
* )
* @ApiFilter(PropertyFilter::class,
* arguments={
* "parameterName"="fields",
* "overrideDefaultProperties"=true
* }
* )
* @UniqueEntity(
* fields={"email", "category"},
* errorPath="email",
* message="The email is already in use",
* ignoreNull=false
* )
* @ORM\HasLifecycleCallbacks()
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface, SamlUserInterface
{
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 GROUP_ADMIN = 'admin';
const GROUP_COMPANY = 'company';
const GROUP_CLIENT = 'client';
const GROUP_SPECIALIST = 'specialist';
const ROLE_USER = 'ROLE_USER';
const ROLE_CLIENT = 'ROLE_CLIENT';
const ROLE_COMPANY = 'ROLE_COMPANY';
const ROLE_EXTERNAL_COMPANY = 'ROLE_EXTERNAL_COMPANY';
const ROLE_ADMIN = 'ROLE_ADMIN';
const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
const ROLE_SPECIALIST = 'ROLE_SPECIALIST';
const ROLE_TV = 'ROLE_TV';
const ROLE_LIVE = 'ROLE_LIVE';
const GROUPS = [
self::GROUP_ADMIN,
self::GROUP_COMPANY,
self::GROUP_CLIENT,
self::GROUP_SPECIALIST,
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "user_favorite:read", "user:read:id", "user:read", "company:read", "user:read:export_csv",
* "team:read", "team_user:read", "user:read:form", "notification:read", "client:read",
* "chat_message:read", "chat:read", "message:read"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=180)
* @Assert\Email
* @Assert\NotBlank
* @Groups({
* "user_favorite:read", "user:read:email", "user:read", "user:write:creation", "user:write",
* "team:read", "team_user:read", "user:read:form", "notification:read", "company:read", "company:write",
* "client:read", "client:write", "chat_message:read", "chat:read", "message:read"
* })
*/
private $email;
/**
* @ORM\Column(type="json")
* @Groups({"user:read:roles", "user:read", "user_favorite:read", "client:read"})
*/
private $roles = [];
/**
* @var string|null The hashed password
* @ORM\Column(type="string")
* @Assert\Length(min="8", max="255")
* @Assert\NotBlank
*/
private $password = null;
/**
* @var string|null
* @Assert\NotBlank(
* groups={"user:update:password"}
* )
* @SecurityAssert\UserPassword(
* message="old_password.matching",
* groups={"user:update:password"}
* )
*/
private $oldPassword = null;
/**
* @var string|null
* @Groups({"user:write:creation", "user:write", "user:read:creation"})
* @Assert\Regex("/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/",
* message="password.pattern",
* groups={"user:write:reset-password", "user:update:password"}
* )
* @Assert\NotBlank(
* groups={"user:write:reset-password", "user:update:password"}
* )
* @Assert\Length(
* min=6,
* max=4096,
* minMessage="Your password should be at least {{ limit }} characters",
* groups={"user:write:reset-password", "user:update:password"}
* )
* @SerializedNameGroups(name="Mot-de-passe", groups={"user:read:creation"})
*/
private $plainPassword = null;
/**
* @var string|null
* @Groups({"user:write:creation", "user:write"})
* @Assert\IdenticalTo(propertyPath="plainPassword",
* message="password.matching",
* groups={"user:write:reset-password", "user:update:password"}
* )
*/
private $passwordConfirm = null;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
* @Groups({"user:read:createdAt", "user:read"})
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Timestampable(on="update")
* @Groups({"user:read:updatedAt", "user:read"})
*/
private $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"user:read:lastLogin", "user:read", "user:write", "client:read"})
*/
private $lastLogin;
/**
* @ORM\Column(type="string", length=255)
* @Assert\Length(max="255", min="0")
* @Groups({"user:read:name", "user:read", "user_favorite:read", "chat_message:read", "chat:read"})
* @var string
*/
private $name = '';
/**
* @ORM\Column(type="string", length=50)
* @Assert\Choice(choices=self::GROUPS)
* @Groups({"user:read:category", "user:read", "user_favorite:read"})
*/
private $category;
/**
* @ORM\Column(type="boolean", options={"default": "1"})
* @Groups({"user_favorite:read", "user:read:active", "user:read", "company:read", "user:read:export_csv", "notification:read", "chat_message:read", "chat:read", "client:read"})
*/
private $active = true;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $banStart;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $banEnd;
/**
* @ORM\Column(type="string", length=255, nullable=true, unique=true)
*/
private $resetToken;
/**
* @ORM\OneToOne(targetEntity=Specialist::class, mappedBy="user", cascade={"persist", "remove"})
*/
private $specialist;
/**
* @ORM\OneToOne(targetEntity=Company::class, mappedBy="user", cascade={"persist", "remove"})
* @ApiProperty(security="is_granted('ROLE_ADMIN') or is_granted('ROLE_COMPANY')")
* @Groups({"user:read:company", "user:read", "message:read"})
*/
private $company;
/**
* @ORM\OneToOne(targetEntity=Client::class, mappedBy="user", cascade={"persist", "remove"})
* @Groups({"user:read:client", "user:read", "team_user:read", "chat_message:read", "chat:read", "message:read"})
*/
private $client;
/**
* @var bool
*/
private $_hashPwd = false;
/**
* @var null|string
*/
private $token = null;
/**
* @ORM\OneToMany(targetEntity=Document::class, mappedBy="owner")
*/
private $documents;
/**
* @ORM\OneToMany(targetEntity=MarketplaceReservation::class, mappedBy="user", cascade={"persist", "refresh", "remove"})
*/
private $marketplaceReservations;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"user:read:firstName", "user:read", "user_favorite:read", "company:read", "company:write", "team_user:read", "chat_message:read", "chat:read"})
*/
private $firstName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"user:read:lastName", "user:read", "user_favorite:read", "company:read", "company:write", "team_user:read", "chat_message:read", "chat:read"})
*/
private $lastName;
/**
* @ORM\OneToMany(targetEntity=UserFavorite::class, mappedBy="user", cascade={"persist", "refresh", "remove"})
* @Groups({"user:read:favorites"})
* @ApiSubresource(maxDepth=1)
*/
private $favorites;
/**
* @ORM\ManyToOne(targetEntity=Segmentation::class, inversedBy="users", cascade={"persist"})
* @Groups({"user:read:segmentation", "user:read", "user:write", "chat_message:read", "chat:read"})
*/
private $segmentation;
/**
* @ORM\Column(type="string", length=255, nullable=true, options={"default": "FR"})
* @Groups({"user:read:country"})
*/
private $country;
/**
* @ORM\Column(name="`function`", type="string", length=255, nullable=true)
* @Groups({"user:read:function", "user:read", "user:write", "company:read", "company:write", "export_csv", "manager_dashboard"})
*/
private $function;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"user:read:phone", "user:read", "user:write", "company:read", "company:write", "export_csv", "manager_dashboard"})
* @Assert\Length(min=8, max=20, minMessage="phone.min", maxMessage="phone.max")
*/
private $phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"user:read:username", "user:read", "user:write:creation", "user:write", "team:read", "team_user:read", "user:read:form", "notification:read", "chat_message:read", "chat:read"})
*/
private $username;
/**
* @ORM\Column(type="integer", options={"default": "-1"})
* @Groups({"user:read:quotas", "user:read", "user:write", "user:read:export_csv"})
*/
private $quotas = -1;
/**
* @ORM\Column(type="string", length=255, options={"default": "unset"})
* @Groups({"user:read:quotasType", "user:read", "user:write", "user:read:export_csv"})
*/
private $quotasType = self::QUOTA_NONE;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Timestampable(on="change", field="email")
*/
private $emailUpdatedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $emailValidatedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"user:read:status", "user:read", "company:read", "user:read:export_csv", "client:read"})
* @Assert\Choice(choices=self::STATUSES)
*/
private $status = self::STATUS_ACTIVE;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"user:read:deviceOs", "user:read", "user:write"})
*/
private $deviceOs;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({"user:read:deviceToken", "user:read", "user:write"})
*/
private $deviceToken;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"user:read:deviceName", "user:read", "user:write"})
*/
private $deviceName;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": 1})
* @Groups({"user:read:deviceActive", "user:read", "user:write"})
*/
private $deviceActive = true;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Timestampable(on="change", field={"deviceOs", "deviceToken", "deviceName", "deviceActive"})
* @Groups({"user:read:deviceUpdate", "user:read", "user:write"})
*/
private $deviceUpdate;
/**
* @ORM\OneToMany(targetEntity=UserDevice::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $devices;
/**
* @ORM\Column(type="boolean", options={"default": "0"})
* @Groups({"user:read:newsletter", "user:read", "company:read", "user:write", "client:read", "client:write"})
*/
private $newsletter = false;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"user:read:newsletterDate", "user:read", "company:read"})
* @Gedmo\Timestampable(on="change", field="newsletter", value=true)
*/
private $newsletterDate;
/**
* @ORM\Column(type="boolean", options={"default": "1"})
* @Groups({"user:read:firstLogin", "user:read", "company:read", "user:write", "client:read", "client:write"})
*/
private $firstLogin = true;
/**
* @ORM\Column(type="boolean", options={"default": "1"})
* @Groups({"user:read:homeSurvey", "user:read", "company:read", "user:write", "client:read", "client:write"})
*/
private $homeSurvey = true;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": "1"})
* @Groups({"user:read:displayTeamplayTuto", "user:read", "user:write", "user:read:tuto_only", "client:read", "client:write"})
*/
private $displayTeamplayTuto = true;
/**
* @ORM\OneToMany(targetEntity=Log::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $logs;
/**
* Sent messages by the user to web admins
* @ORM\OneToMany(targetEntity=Message::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $messages;
/**
* @ORM\OneToMany(targetEntity=VideoEvent::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $videoEvents;
/**
* @ORM\OneToMany(targetEntity=UserResponse::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $userResponses;
/**
* @ORM\OneToMany(targetEntity=Favorite::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
* @Groups({"user:read:tvFavorites"})
* @ApiSubresource(maxDepth=1)
*/
private $tvFavorites;
/**
* @ORM\OneToMany(targetEntity=LogEmail::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $logEmails;
/**
* @ORM\OneToMany(targetEntity=Playlist::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $playlists;
/**
* @ORM\ManyToMany(targetEntity=Objective::class, mappedBy="users")
* @Groups({"user:read", "user:write"})
*/
private $objectives;
/**
* @ORM\OneToMany(targetEntity=TeamUser::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $teamUsers;
/**
* @ORM\OneToMany(targetEntity=TeamplayLog::class, mappedBy="user", orphanRemoval=true, cascade={"refresh", "remove"})
*/
private $teamplayLogs;
/**
* @ORM\OneToMany(targetEntity=PedometerLog::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $pedometerLogs;
/**
* @ORM\OneToMany(targetEntity=UserNotification::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $userNotifications;
/**
* @ORM\OneToMany(targetEntity=AwardLog::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $awardLogs;
/**
* @ORM\OneToMany(targetEntity=UserVideoTimecode::class, mappedBy="user", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $userVideoTimecodes;
/**
* @ORM\OneToMany(targetEntity=Notation::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $notations;
/**
* @ORM\OneToMany(targetEntity=VideoLastValidate::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $videoLastValidates;
/**
* @ORM\OneToMany(targetEntity=VideoLastSeen::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $videoLastSeens;
/**
* @ORM\OneToMany(targetEntity=MoodResponse::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $moodResponses;
/**
* @ORM\OneToMany(targetEntity=ProgramEvent::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $programEvents;
/**
* @ORM\OneToMany(targetEntity=DayEvent::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $dayEvents;
/**
* @ORM\OneToOne(targetEntity=TvUser::class, mappedBy="user", cascade={"persist", "refresh","remove"})
*/
private $tvUser;
/**
* @ORM\Column(type="boolean", options={"default": "1"})
* @Groups({"user:read:live", "user:read", "user:write", "user_favorite:read", "client:read"})
*/
private $live = true;
/**
* @ORM\Column(type="boolean", options={"default": "1"})
* @Groups({"user:read:tv", "user:read", "user:write", "user_favorite:read", "client:read"})
*/
private $tv = true;
/**
*
* @ORM\ManyToMany(targetEntity=Chat::class, inversedBy="users")
*/
private $chats;
/**
* @var bool
*/
public $isPopulated = false;
/**
* @ORM\OneToMany(targetEntity=Invoice::class, mappedBy="user", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $invoices;
/**
* @ORM\OneToOne(targetEntity=NotificationPreference::class, mappedBy="user", cascade={"persist","remove"})
*/
private $notificationPreference = null;
public function __construct()
{
$this->roles[] = self::ROLE_USER;
$this->documents = new ArrayCollection();
$this->marketplaceReservations = new ArrayCollection();
$this->favorites = new ArrayCollection();
$this->devices = new ArrayCollection();
$this->logs = new ArrayCollection();
$this->messages = new ArrayCollection();
$this->videoEvents = new ArrayCollection();
$this->userResponses = new ArrayCollection();
$this->tvFavorites = new ArrayCollection();
$this->logEmails = new ArrayCollection();
$this->playlists = new ArrayCollection();
$this->objectives = new ArrayCollection();
$this->teamUsers = new ArrayCollection();
$this->teamplayLogs = new ArrayCollection();
$this->pedometerLogs = new ArrayCollection();
$this->userNotifications = 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();
$this->chats = new ArrayCollection();
$this->invoices = new ArrayCollection();
}
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 getUserIdentifier(): string
{
return (string)$this->email;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(?string $username): self
{
$this->username = $username;
return $this;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = self::ROLE_USER;
if ($this->isTv()) {
$roles[] = self::ROLE_TV;
}
if ($this->isLive()) {
$roles[] = self::ROLE_LIVE;
}
return array_unique($roles);
}
/**
* @param string $role
* @return bool
*/
public function hasRole(string $role): bool
{
return in_array($role, $this->roles);
}
/**
* @see UserInterface
*/
public function addRole(string $role): self
{
if (!in_array($role, $this->roles)) {
$this->roles[] = $role;
}
return $this;
}
/**
* @see UserInterface
*/
public function removeRole(string $role): self
{
if (in_array($role, $this->roles)) {
foreach ($this->roles as $key => $item) {
if ($item === $role) {
unset($this->roles[$key]);
}
}
$this->roles = array_values($this->roles);
}
return $this;
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): ?string
{
return $this->password;
}
/**
* This setter also checks if the password has changed it will rehash it
* @param string|null $password New password
* @param bool $hash Forces rehash of password
* @return $this
*/
public function setPassword(?string $password, bool $hash = false): self
{
if (!empty($password) && ($this->password !== $password || $hash)) {
$this->_hashPwd = true;
}
if (!empty($password)) {
$this->password = $password;
}
return $this;
}
/**
* If persisted this password will be encoded into the password field
* @param ?string $oldPassword
* @return User
*/
public function setOldPassword(?string $oldPassword): User
{
$this->oldPassword = $oldPassword;
return $this;
}
/**
* @return string
*/
public function getOldPassword(): ?string
{
return $this->oldPassword;
}
/**
* If persisted this password will be encoded into the password field
* @param string $password
* @return User
*/
public function setPlainPassword(string $password): User
{
$this->plainPassword = $password;
return $this;
}
/**
* @return string
*/
public function getPlainPassword(): ?string
{
return $this->plainPassword;
}
/**
* @return string|null
*/
public function getPasswordConfirm(): ?string
{
return $this->passwordConfirm;
}
/**
* @param string|null $passwordConfirm
* @return User
*/
public function setPasswordConfirm(?string $passwordConfirm): User
{
$this->passwordConfirm = $passwordConfirm;
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;
}
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
public function setCreatedAt(\DateTime $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTime $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getLastLogin(): ?\DateTimeInterface
{
return $this->lastLogin;
}
public function setLastLogin(?\DateTimeInterface $lastLogin): self
{
$this->lastLogin = $lastLogin;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(string $category): self
{
$this->category = $category;
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function isActive(): ?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 getBanStart(): ?\DateTimeInterface
{
return $this->banStart;
}
public function setBanStart(?\DateTimeInterface $banStart): self
{
$this->banStart = $banStart;
return $this;
}
public function getBanEnd(): ?\DateTimeInterface
{
return $this->banEnd;
}
public function setBanEnd(?\DateTimeInterface $banEnd): self
{
$this->banEnd = $banEnd;
return $this;
}
public function getResetToken(): ?string
{
return $this->resetToken;
}
public function setResetToken(?string $resetToken): self
{
$this->resetToken = $resetToken;
return $this;
}
public function getSpecialist(): ?Specialist
{
return $this->specialist;
}
public function setSpecialist(Specialist $specialist): self
{
// set the owning side of the relation if necessary
if ($specialist->getUser() !== $this) {
$specialist->setUser($this);
}
$this->specialist = $specialist;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setClient(Client $client): self
{
// set the owning side of the relation if necessary
if ($client->getUser() !== $this) {
$client->setUser($this);
}
$this->client = $client;
return $this;
}
/**
* @return bool
*/
public function isHashPwd(): bool
{
return $this->_hashPwd;
}
/**
* @return string
*/
public function __toString()
{
return $this->name;
}
/**
* @ORM\PrePersist()
*/
public function updateName()
{
if ($this->company instanceof Company) {
$this->name = $this->company->getName();
} elseif ($this->specialist instanceof Specialist) {
$this->name = (string)$this->specialist;
} elseif ($this->client instanceof Client) {
$this->name = (string)$this->client;
}
}
/**
* @param string|null $token
* @return User
*/
public function setToken(?string $token): User
{
$this->token = $token;
return $this;
}
/**
* @return string|null
*/
public function getToken(): ?string
{
return $this->token;
}
public function setSamlAttributes(array $attributes)
{
$this->token = $attributes['sessionIndex'];
$data = [];
foreach ($attributes as $key => $value) {
$data[ToolsService::toCamelCase($key)] = $value;
}
if (!empty($data['email'])) {
if (is_array($data['email'])) $this->email = $data['email'][0];
elseif (is_string($data['email'])) $this->email = $data['email'];
}
if (!empty($data['firstName'])) {
if (is_array($data['firstName'])) $this->firstName = $data['firstName'][0];
elseif (is_string($data['firstName'])) $this->firstName = $data['firstName'];
}
if (!empty($data['lastName'])) {
if (is_array($data['lastName'])) $this->lastName = $data['lastName'][0];
elseif (is_string($data['lastName'])) $this->lastName = $data['lastName'];
}
if (!empty($data['country'])) {
if (is_array($data['country'])) $this->country = $data['country'][0];
elseif (is_string($data['country'])) $this->country = $data['country'];
}
}
/**
* @return Collection<int, Document>
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setOwner($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->removeElement($document)) {
// set the owning side to null (unless already changed)
if ($document->getOwner() === $this) {
$document->setOwner(null);
}
}
return $this;
}
/**
* @return Collection<int, MarketplaceReservation>
*/
public function getMarketplaceReservations(): Collection
{
return $this->marketplaceReservations;
}
public function addMarketplaceReservation(MarketplaceReservation $marketplaceReservation): self
{
if (!$this->marketplaceReservations->contains($marketplaceReservation)) {
$this->marketplaceReservations[] = $marketplaceReservation;
$marketplaceReservation->setUser($this);
}
return $this;
}
public function removeMarketplaceReservation(MarketplaceReservation $marketplaceReservation): self
{
if ($this->marketplaceReservations->removeElement($marketplaceReservation)) {
// set the owning side to null (unless already changed)
if ($marketplaceReservation->getUser() === $this) {
$marketplaceReservation->setUser(null);
}
}
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
$name = $this->firstName;
if (!empty($this->lastName)) {
$name .= " " . $this->lastName;
}
$this->setName($name);
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
$name = $this->firstName;
if (!empty($this->lastName)) {
$name .= " " . $this->lastName;
}
$this->setName($name);
return $this;
}
/**
* @return Collection<int, UserFavorite>
*/
public function getFavorites(): Collection
{
return $this->favorites;
}
public function addFavorite(UserFavorite $favorite): self
{
if (!$this->favorites->contains($favorite)) {
$this->favorites[] = $favorite;
$favorite->setUser($this);
}
return $this;
}
public function removeFavorite(UserFavorite $favorite): self
{
if ($this->favorites->removeElement($favorite)) {
// set the owning side to null (unless already changed)
if ($favorite->getUser() === $this) {
$favorite->setUser(null);
}
}
return $this;
}
public function getSegmentation(): ?Segmentation
{
return $this->segmentation;
}
public function setSegmentation(?Segmentation $segmentation): self
{
$this->segmentation = $segmentation;
if ($this->getClient()) {
$this->getClient()->setSegmentation($segmentation);
}
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
public function getFunction(): ?string
{
return $this->function;
}
public function setFunction(?string $function): self
{
$this->function = $function;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
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;
}
/**
* Checks the quotas of a User
* @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 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);
}
/**
* Updates the Company according to the status of the order
* @return User
* @ORM\PrePersist
*/
public function updateCompany(): self
{
if ($this->company instanceof Company) {
$this->company->setClientsCount($this->company->getClientsCount() + 1);
}
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
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, UserDevice>
*/
public function getDevices(): Collection
{
return $this->devices;
}
public function addDevice(UserDevice $device): self
{
if (!$this->devices->contains($device)) {
$this->devices[] = $device;
$device->setUser($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->getUser() === $this) {
$device->setUser(null);
}
}
return $this;
}
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;
}
/**
* @param bool $firstLogin
* @return User
*/
public function setFirstLogin(bool $firstLogin): User
{
$this->firstLogin = $firstLogin;
return $this;
}
/**
* @return bool
*/
public function isFirstLogin(): bool
{
return $this->firstLogin;
}
/**
* @param bool $homeSurvey
* @return User
*/
public function setHomeSurvey(bool $homeSurvey): User
{
$this->homeSurvey = $homeSurvey;
return $this;
}
/**
* @return bool
*/
public function isHomeSurvey(): bool
{
return $this->homeSurvey;
}
public function getDisplayTeamplayTuto(): ?bool
{
return $this->displayTeamplayTuto;
}
public function setDisplayTeamplayTuto(?bool $displayTeamplayTuto): self
{
$this->displayTeamplayTuto = $displayTeamplayTuto;
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->setUser($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->getUser() === $this) {
$log->setUser(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->setUser($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->getUser() === $this) {
$message->setUser(null);
}
}
return $this;
}
/**
* @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->setUser($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->getUser() === $this) {
$videoEvent->setUser(null);
}
}
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->setUser($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->getUser() === $this) {
$userResponse->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Favorite[]
*/
public function getTvFavorites(): Collection
{
return $this->tvFavorites;
}
public function addTvFavorite(Favorite $tvFavorite): self
{
if (!$this->tvFavorites->contains($tvFavorite)) {
$this->tvFavorites[] = $tvFavorite;
}
return $this;
}
public function removeTvFavorite(Favorite $tvFavorite): self
{
$this->tvFavorites->removeElement($tvFavorite);
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->setUser($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->getUser() === $this) {
$logEmail->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Playlist[]
*/
public function getPlaylists(): Collection
{
return $this->playlists;
}
public function addPlaylist(Playlist $playlist): self
{
if (!$this->playlists->contains($playlist)) {
$this->playlists[] = $playlist;
$playlist->setUser($this);
}
return $this;
}
public function removePlaylist(Playlist $playlist): self
{
if ($this->playlists->removeElement($playlist)) {
// set the owning side to null (unless already changed)
if ($playlist->getUser() === $this) {
$playlist->setUser(null);
}
}
return $this;
}
/**
* @Groups({"user:write"})
*/
public function setAddPlaylist(Playlist $playlist): self
{
if (!$this->playlists->contains($playlist)) {
$this->playlists[] = $playlist;
$playlist->setUser($this);
}
return $this;
}
/**
* @Groups({"user:write"})
*/
public function setRemovePlaylist(Playlist $playlist): self
{
if ($this->playlists->removeElement($playlist)) {
// set the owning side to null (unless already changed)
if ($playlist->getUser() === $this) {
$playlist->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Objective[]
*/
public function getObjectives(): Collection
{
return $this->objectives;
}
/**
* @return Collection|Objective[]
*/
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->addUser($this);
}
return $this;
}
public function removeObjective(Objective $objective): self
{
if ($this->objectives->removeElement($objective)) {
$objective->removeUser($this);
}
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->setUser($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->getUser() === $this) {
$teamUser->setUser(null);
}
}
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->setUser($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->getUser() === $this) {
$teamplayLog->setUser(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->setUser($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->getUser() === $this) {
$pedometerLog->setUser(null);
}
}
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->setUser($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->getUser() === $this) {
$userNotification->setUser(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->setUser($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->getUser() === $this) {
$awardLog->setUser(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->setUser($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->getUser() === $this) {
$userVideoTimecode->setUser(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->setUser($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->getUser() === $this) {
$notation->setUser(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->setUser($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->getUser() === $this) {
$videoLastValidate->setUser(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->setUser($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->getUser() === $this) {
$videoLastSeen->setUser(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->setUser($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->getUser() === $this) {
$moodResponse->setUser(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->setUser($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->getUser() === $this) {
$programEvent->setUser(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->setUser($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->getUser() === $this) {
$dayEvent->setUser(null);
}
}
return $this;
}
public function getTvUser(): ?TvUser
{
return $this->tvUser;
}
public function setTvUser(?TvUser $tvUser): self
{
$this->tvUser = $tvUser;
return $this;
}
public function isLive(): ?bool
{
return $this->live;
}
public function setLive(bool $isLive): self
{
$this->live = $isLive;
return $this;
}
public function isTv(): ?bool
{
return $this->tv;
}
public function setTv(bool $isTv): self
{
$this->tv = $isTv;
return $this;
}
/**
* @return Collection<int, Chat>
*/
public function getChats(): Collection
{
return $this->chats;
}
public function addChat(Chat $chat): self
{
if (!$this->chats->contains($chat)) {
$this->chats[] = $chat;
}
return $this;
}
public function removeChat(Chat $chat): self
{
$this->chats->removeElement($chat);
return $this;
}
/**
* @return Collection<int, Invoice>
*/
public function getInvoices(): Collection
{
return $this->invoices;
}
public function addInvoice(Invoice $invoice): self
{
if (!$this->invoices->contains($invoice)) {
$this->invoices->add($invoice);
$invoice->setUser($this);
}
return $this;
}
public function removeInvoice(Invoice $invoice): self
{
if ($this->invoices->removeElement($invoice)) {
// set the owning side to null (unless already changed)
if ($invoice->getUser() === $this) {
$invoice->setUser(null);
}
}
return $this;
}
public function getNotificationPreference(): ?NotificationPreference
{
return $this->notificationPreference;
}
public function setNotificationPreference(NotificationPreference $notificationPreference): static
{
// set the owning side of the relation if necessary
if ($notificationPreference->getUser() !== $this) {
$notificationPreference->setUser($this);
}
$this->notificationPreference = $notificationPreference;
return $this;
}
}