<?php
namespace App\Entity;
use App\Enum\AccountType;
use App\Enum\PaymentDataEnum;
use App\Enum\PaymentType;
use App\Enum\SubscriptionStatus;
use App\Helper\MetaAttributionHelper;
use App\Helper\PaymentDataConstants;
use App\Helper\SettingConstants;
use App\Interfaces\IBasicUser;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Table(name: 'user')]
#[ORM\Index(name: 'IX_email', columns: ['email'])]
#[ORM\Index(name: 'IX_opt_in_hash', columns: ['opt_in_hash'])]
#[ORM\Index(name: 'IX_public_profile_hash', columns: ['public_profile_hash'])]
#[ORM\Index(name: 'ix_nickname', columns: ['nickname'])]
#[ORM\Index(name: 'ix_reset_hash', columns: ['reset_hash'])]
#[ORM\Index(name: 'ix_referral_code', columns: ['v_referral_code'])]
#[ORM\Index(name: 'ix_source', columns: ['v_source'], options: ["lengths" => [255]])]
#[ORM\Index(name: 'ix_mention_tag', columns: ['v_mention_tag'])]
#[ORM\Index(name: 'ix_social_login_user_id', columns: ['v_social_login_user_id'])]
#[ORM\Entity(repositoryClass: 'App\Entity\Repository\UserRepository')]
class User implements UserInterface, PasswordAuthenticatedUserInterface, IBasicUser
{
use TranslatableTrait;
public const DEFAULT_LOCALE = 'de';
// this value defines how many edits a user has to make to be asked to join the moderators
public const MODERATION_TARGET = 20;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
#[ORM\Column(type: 'string', nullable: true)]
private $email;
#[ORM\Column(type: 'string', nullable: true)]
private $password;
#[ORM\Column(type: 'string', nullable: true)]
private $salt;
#[ORM\Column(type: 'string', nullable: true)]
private $firstname;
#[ORM\Column(type: 'string', nullable: true)]
private $lastname;
#[ORM\Column(type: 'string', nullable: true)]
private $nickname;
#[ORM\Column(type: 'string', nullable: true)]
private $address_line1;
#[ORM\Column(type: 'string', nullable: true)]
private $address_line2;
#[ORM\Column(type: 'string', nullable: true)]
private $zip_code;
#[ORM\Column(type: 'string', nullable: true)]
private $city;
#[ORM\Column(type: 'string', nullable: true)]
private $country_iso;
#[ORM\Column(type: 'string', nullable: true)]
private $phone;
#[ORM\Column(type: 'string', nullable: true)]
private $mobile;
#[ORM\Column(type: 'json', nullable: true)]
private $profile;
#[ORM\Column(type: 'datetime', nullable: false)]
private $date_created;
#[ORM\Column(type: 'boolean', nullable: true)]
private $is_public;
#[ORM\Column(type: 'string', nullable: true)]
private $public_profile_hash;
#[ORM\Column(type: 'integer', nullable: true)]
private $login_count;
#[ORM\Column(type: 'text', nullable: true)]
private $about_me;
#[ORM\Column(type: 'datetime', nullable: true)]
private $date_last_login;
#[ORM\Column(type: 'datetime', nullable: true)]
private $date_disabled;
#[ORM\Column(type: 'datetime', nullable: true)]
private $date_opt_in_confirmed;
#[ORM\Column(type: 'float', nullable: true)]
private $geo_lat;
#[ORM\Column(type: 'float', nullable: true)]
private $geo_lon;
#[ORM\Column(type: 'string', nullable: true)]
private $reset_hash;
#[ORM\Column(type: 'datetime', nullable: true)]
private $date_reset_created;
#[ORM\Column(type: 'json', nullable: true)]
private $settings;
#[ORM\Column(type: 'boolean', nullable: false)]
private $is_active;
#[ORM\Column(type: 'string', nullable: true)]
private $opt_in_hash;
#[ORM\Column(type: 'string', nullable: true)]
private $account_type;
#[ORM\Column(type: 'json', nullable: true)]
private $payment_data;
#[ORM\OneToMany(targetEntity: 'App\Entity\Token', mappedBy: 'user')]
private $token;
#[ORM\OneToMany(targetEntity: 'App\Entity\Crop', mappedBy: 'user')]
private $crop;
#[ORM\OneToMany(targetEntity: 'App\Entity\SupportRequest', mappedBy: 'user')]
private $supportRequest;
#[ORM\OneToMany(targetEntity: 'App\Entity\Emaillog', mappedBy: 'user')]
private $notificationMail;
#[ORM\OneToMany(targetEntity: 'App\Entity\Patch', mappedBy: 'user')]
private $patch;
#[ORM\OneToMany(targetEntity: 'App\Entity\Cropaction', mappedBy: 'user')]
private $cropaction;
#[ORM\OneToMany(targetEntity: 'App\Entity\Todo', mappedBy: 'user')]
private $todo;
#[ORM\OneToMany(targetEntity: 'App\Entity\Shoporder', mappedBy: 'user')]
private $shoporder;
#[ORM\OneToMany(targetEntity: 'App\Entity\FavoriteCrop', mappedBy: 'user')]
private $favoriteCrop;
#[ORM\OneToMany(targetEntity: 'App\Entity\FavoriteContent', mappedBy: 'user')]
private $contentFavorite;
#[ORM\OneToMany(targetEntity: 'App\Entity\Invoice', mappedBy: 'user')]
private $invoice;
#[ORM\OneToMany(targetEntity: 'App\Entity\Payment', mappedBy: 'user')]
private $payment;
#[ORM\OneToMany(targetEntity: 'App\Entity\LoginLog', mappedBy: 'user')]
private $loginLog;
#[ORM\OneToMany(targetEntity: 'App\Entity\VoucherRedemption', mappedBy: 'user')]
private $voucherRedemption;
#[ORM\OneToMany(targetEntity: 'App\Entity\Device', mappedBy: 'user')]
private $device;
#[ORM\OneToMany(targetEntity: 'App\Entity\Survey', mappedBy: 'user')]
private $survey;
#[ORM\OneToMany(targetEntity: 'App\Entity\Post', mappedBy: 'user')]
private $post;
#[ORM\OneToMany(targetEntity: 'App\Entity\PostComment', mappedBy: 'user')]
private $postComment;
#[ORM\OneToMany(targetEntity: 'App\Entity\PostBookmark', mappedBy: 'user')]
private $postBookmark;
#[ORM\OneToMany(targetEntity: 'App\Entity\Rating', mappedBy: 'user')]
private $rating;
#[ORM\OneToMany(targetEntity: 'App\Entity\Appsurvey', mappedBy: 'user')]
private $appsurvey;
#[ORM\OneToMany(targetEntity: 'App\Entity\PushNotification', mappedBy: 'user')]
private $pushNotification;
#[ORM\OneToMany(targetEntity: 'App\Entity\Image', mappedBy: 'user')]
private $image;
#[ORM\OneToMany(targetEntity: 'App\Entity\CropEdit', mappedBy: 'user')]
private $cropEdit;
#[ORM\OneToMany(targetEntity: 'App\Entity\CropRating', mappedBy: 'user')]
private $cropRating;
#[ORM\OneToMany(targetEntity: 'App\Entity\CartItem', mappedBy: 'user')]
private $cartItem;
#[ORM\OneToMany(targetEntity: Garden::class, mappedBy: 'user')]
private $gardens;
#[ORM\OneToMany(targetEntity: PostLike::class, mappedBy: 'user')]
private $postLikes;
#[ORM\OneToMany(targetEntity: CommentLike::class, mappedBy: 'user')]
private $commentLikes;
#[ORM\OneToMany(targetEntity: Notification::class, mappedBy: 'user')]
private $notifications;
#[ORM\OneToMany(targetEntity: Nps::class, mappedBy: 'user', orphanRemoval: true)]
private $nps;
#[ORM\OneToMany(targetEntity: UserConnection::class, mappedBy: 'user')]
private $userConnections;
#[ORM\OneToMany(targetEntity: Reminder::class, mappedBy: 'user', orphanRemoval: true)]
private $reminders;
private $imageDataUri;
#[ORM\OneToMany(targetEntity: ProfitwellUser::class, mappedBy: 'user', orphanRemoval: true)]
private $profitwellUsers;
#[ORM\OneToMany(targetEntity: Template::class, mappedBy: 'created_by_user')]
private $templates;
#[ORM\OneToMany(targetEntity: FavoriteTemplate::class, mappedBy: 'user', orphanRemoval: true)]
private $favoriteTemplates;
#[ORM\OneToMany(targetEntity: TemplateUsage::class, mappedBy: 'user', orphanRemoval: true)]
private $templateUsages;
#[ORM\OneToMany(targetEntity: ObjectComment::class, mappedBy: 'user', orphanRemoval: true)]
private $objectComments;
#[ORM\OneToMany(targetEntity: PreferencesToken::class, mappedBy: 'user', orphanRemoval: true)]
private $preferencesTokens;
#[ORM\OneToMany(targetEntity: Usercontent::class, mappedBy: 'user', orphanRemoval: true)]
private $usercontents;
#[ORM\OneToMany(targetEntity: TagConnection::class, mappedBy: 'user', orphanRemoval: true)]
private $tagConnections;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Croplist::class, orphanRemoval: true)]
private Collection $cropLists;
#[ORM\Column(length: 6, nullable: true)]
private ?string $locale = null;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: CancellationSurvey::class, orphanRemoval: true)]
private Collection $cancellationSurveys;
// this virtual column is indexed via an index at the top of this file; the indexed virtual column
// helps to speed up lookups for users with a referral code which is used during register
#[ORM\Column(type: "string",
name: "v_referral_code",
columnDefinition: "VARCHAR(50) AS (JSON_VALUE(settings,'$.referralCode')) VIRTUAL",
insertable: false,
updatable: false,
nullable: true,
length: 50,
generated: "ALWAYS")]
private ?string $v_referralCode;
// this indexed virtual column helps to speed up selects to the source of users
#[ORM\Column(type: "string",
name: "v_source",
columnDefinition: "VARCHAR(4096) AS (JSON_VALUE(settings,'$.source')) VIRTUAL",
insertable: false,
updatable: false,
nullable: true,
length: 4096,
generated: "ALWAYS")]
private ?string $v_source;
// this indexed virtual column helps to speed up selects of users via mention tags
#[ORM\Column(type: "string",
name: "v_mention_tag",
columnDefinition: "VARCHAR(255) AS (JSON_VALUE(settings,'$.mentionTag')) VIRTUAL",
insertable: false,
updatable: false,
nullable: true,
length: 255,
generated: "ALWAYS")]
private ?string $v_mentionTag;
// this indexed virtual column helps to speed up selects of users via social login user id
#[ORM\Column(type: "string",
name: "v_social_login_user_id",
columnDefinition: "VARCHAR(100) AS (JSON_VALUE(settings,'$.socialLoginUserId')) VIRTUAL",
insertable: false,
updatable: false,
nullable: true,
length: 100,
generated: "ALWAYS")]
private ?string $v_socialLoginUserId;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: ModerationNotification::class)]
private Collection $moderationNotifications;
#[ORM\Column(nullable: true)]
private ?array $climate_settings = [];
#[ORM\Column(nullable: true)]
private ?array $units = [];
#[ORM\OneToMany(mappedBy: 'reported_by_user_id', targetEntity: PostReport::class, orphanRemoval: true)]
private Collection $postReports;
public function __construct()
{
$this->date_created = new \DateTime();
$this->is_active = false;
$this->token = new ArrayCollection();
$this->supportRequest = new ArrayCollection();
$this->notificationMail = new ArrayCollection();
$this->patch = new ArrayCollection();
$this->todo = new ArrayCollection();
$this->shoporder = new ArrayCollection();
$this->favoriteCrop = new ArrayCollection();
$this->contentFavorite = new ArrayCollection();
$this->invoice = new ArrayCollection();
$this->payment = new ArrayCollection();
$this->crop = new ArrayCollection();
$this->loginLog = new ArrayCollection();
$this->voucherRedemption = new ArrayCollection();
$this->device = new ArrayCollection();
$this->cropaction = new ArrayCollection();
$this->survey = new ArrayCollection();
$this->post = new ArrayCollection();
$this->postComment = new ArrayCollection();
$this->postBookmark = new ArrayCollection();
$this->rating = new ArrayCollection();
$this->appsurvey = new ArrayCollection();
$this->pushNotification = new ArrayCollection();
$this->image = new ArrayCollection();
$this->cropEdit = new ArrayCollection();
$this->cropRating = new ArrayCollection();
$this->cartItem = new ArrayCollection();
$this->gardens = new ArrayCollection();
$this->postLikes = new ArrayCollection();
$this->commentLikes = new ArrayCollection();
$this->notifications = new ArrayCollection();
$this->nps = new ArrayCollection();
$this->userConnections = new ArrayCollection();
$this->reminders = new ArrayCollection();
$this->profitwellUsers = new ArrayCollection();
$this->templates = new ArrayCollection();
$this->favoriteTemplates = new ArrayCollection();
$this->templateUsages = new ArrayCollection();
$this->objectComments = new ArrayCollection();
$this->preferencesTokens = new ArrayCollection();
$this->usercontents = new ArrayCollection();
$this->tagConnections = new ArrayCollection();
$this->cropLists = new ArrayCollection();
$this->cancellationSurveys = new ArrayCollection();
$this->moderationNotifications = new ArrayCollection();
$this->postReports = 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;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(?string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getAddressLine1(): ?string
{
return $this->address_line1;
}
public function setAddressLine1(?string $address_line1): self
{
$this->address_line1 = $address_line1;
return $this;
}
public function getAddressLine2(): ?string
{
return $this->address_line2;
}
public function setAddressLine2(?string $address_line2): self
{
$this->address_line2 = $address_line2;
return $this;
}
public function getZipCode(): ?string
{
return $this->zip_code;
}
public function setZipCode(?string $zip_code): self
{
$this->zip_code = $zip_code;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getCountryIso(): ?string
{
return $this->country_iso;
}
public function setCountryIso(?string $country_iso): self
{
$this->country_iso = $country_iso;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getMobile(): ?string
{
return $this->mobile;
}
public function setMobile(?string $mobile): self
{
$this->mobile = $mobile;
return $this;
}
public function getDateCreated(): ?\DateTimeInterface
{
return $this->date_created;
}
public function setDateCreated(\DateTimeInterface $date_created): self
{
$this->date_created = $date_created;
return $this;
}
public function getDateOptInConfirmed(): ?\DateTimeInterface
{
return $this->date_opt_in_confirmed;
}
public function setDateOptInConfirmed(?\DateTimeInterface $date_opt_in_confirmed): self
{
$this->date_opt_in_confirmed = $date_opt_in_confirmed;
return $this;
}
public function getIsActive(): ?bool
{
return $this->is_active;
}
public function setIsActive(bool $is_active): self
{
$this->is_active = $is_active;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(?string $password): self
{
$this->password = $password;
return $this;
}
/**
* @return Collection|Token[]
*/
public function getToken(): Collection
{
return $this->token;
}
public function addToken(Token $token): self
{
if (!$this->token->contains($token)) {
$this->token[] = $token;
$token->setUser($this);
}
return $this;
}
public function removeToken(Token $token): self
{
if ($this->token->contains($token)) {
$this->token->removeElement($token);
// set the owning side to null (unless already changed)
if ($token->getUser() === $this) {
$token->setUser(null);
}
}
return $this;
}
public function getOptInHash(): ?string
{
return $this->opt_in_hash;
}
public function setOptInHash(?string $opt_in_hash): self
{
$this->opt_in_hash = $opt_in_hash;
return $this;
}
public function getAccountType(): ?string
{
return $this->account_type;
}
public function setAccountType(?string $account_type): self
{
$this->account_type = $account_type;
$now = new \DateTime();
if ($account_type === AccountType::Paid->value &&
$now > new \DateTime('2024-04-14 00:00:00') &&
$now < new \DateTime('2025-04-22 23:59:59')) {
// easter activation 2025
$this->setSetting(SettingConstants::UNLOCKED_DECORATIONS,
["easterNest", "easterBunnyFront", "easterBunnyBack"]);
}
return $this;
}
public function eraseCredentials()
{
// TODO: Implement eraseCredentials() method.
}
public function getSalt(): ?string
{
return $this->salt;
}
public function getRoles()
{
return ['ROLE_USER'];
}
public function getUsername()
{
return $this->getEmail();
}
/**
* @return Collection|SupportRequest[]
*/
public function getSupportRequest(): Collection
{
return $this->supportRequest;
}
public function addSupportRequest(SupportRequest $supportRequest): self
{
if (!$this->supportRequest->contains($supportRequest)) {
$this->supportRequest[] = $supportRequest;
$supportRequest->setUser($this);
}
return $this;
}
public function removeSupportRequest(SupportRequest $supportRequest): self
{
if ($this->supportRequest->contains($supportRequest)) {
$this->supportRequest->removeElement($supportRequest);
// set the owning side to null (unless already changed)
if ($supportRequest->getUser() === $this) {
$supportRequest->setUser(null);
}
}
return $this;
}
public function setSalt(?string $salt): self
{
$this->salt = $salt;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(?string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getNickname(): ?string
{
return $this->nickname;
}
public function setNickname(?string $nickname): self
{
$this->nickname = $nickname;
return $this;
}
public function getGeoLat(): ?float
{
return $this->geo_lat;
}
public function setGeoLat(?float $geo_lat): self
{
$this->geo_lat = $geo_lat;
return $this;
}
public function getGeoLon(): ?float
{
return $this->geo_lon;
}
public function setGeoLon(?float $geo_lon): self
{
$this->geo_lon = $geo_lon;
return $this;
}
/**
* @return Collection|Patch[]
*/
public function getPatch(): Collection
{
return $this->patch;
}
public function addPatch(Patch $patch): self
{
if (!$this->patch->contains($patch)) {
$this->patch[] = $patch;
$patch->setUser($this);
}
return $this;
}
public function removePatch(Patch $patch): self
{
if ($this->patch->contains($patch)) {
$this->patch->removeElement($patch);
// set the owning side to null (unless already changed)
if ($patch->getUser() === $this) {
$patch->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Todo[]
*/
public function getTodo(): Collection
{
return $this->todo;
}
public function addTodo(Todo $todo): self
{
if (!$this->todo->contains($todo)) {
$this->todo[] = $todo;
$todo->setUser($this);
}
return $this;
}
public function removeTodo(Todo $todo): self
{
if ($this->todo->contains($todo)) {
$this->todo->removeElement($todo);
// set the owning side to null (unless already changed)
if ($todo->getUser() === $this) {
$todo->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Shoporder[]
*/
public function getShoporder(): Collection
{
return $this->shoporder;
}
public function addShoporder(Shoporder $shoporder): self
{
if (!$this->shoporder->contains($shoporder)) {
$this->shoporder[] = $shoporder;
$shoporder->setUser($this);
}
return $this;
}
public function removeShoporder(Shoporder $shoporder): self
{
if ($this->shoporder->contains($shoporder)) {
$this->shoporder->removeElement($shoporder);
// set the owning side to null (unless already changed)
if ($shoporder->getUser() === $this) {
$shoporder->setUser(null);
}
}
return $this;
}
public function getPaymentData()
{
return $this->payment_data;
}
public function setPaymentData($payment_data): self
{
$this->payment_data = $payment_data;
return $this;
}
public function getPaymentDataField(string $field): mixed
{
return $this->payment_data[$field] ?? null;
}
public function setPaymentDataField(string $field, mixed $value): self
{
$allowedFields = [
PaymentDataConstants::PAYPAL_FAILURE_EMAIL_SENT,
PaymentDataConstants::STATE,
PaymentDataConstants::VALID_UNTIL,
PaymentDataConstants::TYPE,
PaymentDataConstants::PADDLE_ID
];
if (!in_array($field, $allowedFields)) {
throw new \Exception('invalid payment data field');
}
if ($this->payment_data === null) {
$this->payment_data = [];
}
$this->payment_data[$field] = $value;
return $this;
}
/**
* @return Collection|FavoriteCrop[]
*/
public function getFavoriteCrop(): Collection
{
return $this->favoriteCrop;
}
public function addFavoriteCrop(FavoriteCrop $favoriteCrop): self
{
if (!$this->favoriteCrop->contains($favoriteCrop)) {
$this->favoriteCrop[] = $favoriteCrop;
$favoriteCrop->setUser($this);
}
return $this;
}
public function removeFavoriteCrop(FavoriteCrop $favoriteCrop): self
{
if ($this->favoriteCrop->contains($favoriteCrop)) {
$this->favoriteCrop->removeElement($favoriteCrop);
// set the owning side to null (unless already changed)
if ($favoriteCrop->getUser() === $this) {
$favoriteCrop->setUser(null);
}
}
return $this;
}
/**
* @return Collection|FavoriteContent[]
*/
public function getContentFavorite(): Collection
{
return $this->contentFavorite;
}
public function addContentFavorite(FavoriteContent $contentFavorite): self
{
if (!$this->contentFavorite->contains($contentFavorite)) {
$this->contentFavorite[] = $contentFavorite;
$contentFavorite->setUser($this);
}
return $this;
}
public function removeContentFavorite(FavoriteContent $contentFavorite): self
{
if ($this->contentFavorite->contains($contentFavorite)) {
$this->contentFavorite->removeElement($contentFavorite);
// set the owning side to null (unless already changed)
if ($contentFavorite->getUser() === $this) {
$contentFavorite->setUser(null);
}
}
return $this;
}
public function getSettings()
{
return $this->settings;
}
public function setSettings($settings): self
{
$this->settings = $settings;
return $this;
}
/**
* @return Collection|Emaillog[]
*/
public function getNotificationMail(): Collection
{
return $this->notificationMail;
}
public function addNotificationMail(Emaillog $notificationMail): self
{
if (!$this->notificationMail->contains($notificationMail)) {
$this->notificationMail[] = $notificationMail;
$notificationMail->setUser($this);
}
return $this;
}
public function removeNotificationMail(Emaillog $notificationMail): self
{
if ($this->notificationMail->contains($notificationMail)) {
$this->notificationMail->removeElement($notificationMail);
// set the owning side to null (unless already changed)
if ($notificationMail->getUser() === $this) {
$notificationMail->setUser(null);
}
}
return $this;
}
public function getResetHash(): ?string
{
return $this->reset_hash;
}
public function setResetHash(?string $reset_hash): self
{
$this->reset_hash = $reset_hash;
return $this;
}
public function getDateResetCreated(): ?\DateTimeInterface
{
return $this->date_reset_created;
}
public function setDateResetCreated(?\DateTimeInterface $date_reset_created): self
{
$this->date_reset_created = $date_reset_created;
return $this;
}
public function getDateLastLogin(): ?\DateTimeInterface
{
return $this->date_last_login;
}
public function setDateLastLogin(?\DateTimeInterface $date_last_login): self
{
$this->date_last_login = $date_last_login;
return $this;
}
/**
* @return Collection|Invoice[]
*/
public function getInvoice(): Collection
{
return $this->invoice;
}
public function addInvoice(Invoice $invoice): self
{
if (!$this->invoice->contains($invoice)) {
$this->invoice[] = $invoice;
$invoice->setUser($this);
}
return $this;
}
public function removeInvoice(Invoice $invoice): self
{
if ($this->invoice->contains($invoice)) {
$this->invoice->removeElement($invoice);
// set the owning side to null (unless already changed)
if ($invoice->getUser() === $this) {
$invoice->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Payment[]
*/
public function getPayment(): Collection
{
return $this->payment;
}
public function addPayment(Payment $payment): self
{
if (!$this->payment->contains($payment)) {
$this->payment[] = $payment;
$payment->setUser($this);
}
return $this;
}
public function removePayment(Payment $payment): self
{
if ($this->payment->contains($payment)) {
$this->payment->removeElement($payment);
// set the owning side to null (unless already changed)
if ($payment->getUser() === $this) {
$payment->setUser(null);
}
}
return $this;
}
public function getIsPublic(): ?bool
{
return $this->is_public;
}
public function setIsPublic(?bool $is_public): self
{
$this->is_public = $is_public;
return $this;
}
public function getPublicProfileHash(): ?string
{
return $this->public_profile_hash;
}
public function setPublicProfileHash(?string $public_profile_hash): self
{
$this->public_profile_hash = $public_profile_hash;
return $this;
}
public function getAboutMe(): ?string
{
return $this->about_me;
}
public function setAboutMe(?string $about_me): self
{
$this->about_me = $about_me;
return $this;
}
/**
* @return Collection|Crop[]
*/
public function getCrop(): Collection
{
return $this->crop;
}
public function addCrop(Crop $crop): self
{
if (!$this->crop->contains($crop)) {
$this->crop[] = $crop;
$crop->setUser($this);
}
return $this;
}
public function removeCrop(Crop $crop): self
{
if ($this->crop->contains($crop)) {
$this->crop->removeElement($crop);
// set the owning side to null (unless already changed)
if ($crop->getUser() === $this) {
$crop->setUser(null);
}
}
return $this;
}
/**
* @return Collection|LoginLog[]
*/
public function getLoginLog(): Collection
{
return $this->loginLog;
}
public function addLoginLog(LoginLog $loginLog): self
{
if (!$this->loginLog->contains($loginLog)) {
$this->loginLog[] = $loginLog;
$loginLog->setUser($this);
}
return $this;
}
public function removeLoginLog(LoginLog $loginLog): self
{
if ($this->loginLog->contains($loginLog)) {
$this->loginLog->removeElement($loginLog);
// set the owning side to null (unless already changed)
if ($loginLog->getUser() === $this) {
$loginLog->setUser(null);
}
}
return $this;
}
/**
* @return Collection|VoucherRedemption[]
*/
public function getVoucherRedemption(): Collection
{
return $this->voucherRedemption;
}
public function addVoucherRedemption(VoucherRedemption $voucherRedemption): self
{
if (!$this->voucherRedemption->contains($voucherRedemption)) {
$this->voucherRedemption[] = $voucherRedemption;
$voucherRedemption->setUser($this);
}
return $this;
}
public function removeVoucherRedemption(VoucherRedemption $voucherRedemption): self
{
if ($this->voucherRedemption->contains($voucherRedemption)) {
$this->voucherRedemption->removeElement($voucherRedemption);
// set the owning side to null (unless already changed)
if ($voucherRedemption->getUser() === $this) {
$voucherRedemption->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Device[]
*/
public function getDevice(): Collection
{
return $this->device;
}
public function addDevice(Device $device): self
{
if (!$this->device->contains($device)) {
$this->device[] = $device;
$device->setUser($this);
}
return $this;
}
public function removeDevice(Device $device): self
{
if ($this->device->contains($device)) {
$this->device->removeElement($device);
// set the owning side to null (unless already changed)
if ($device->getUser() === $this) {
$device->setUser(null);
}
}
return $this;
}
public function getDateDisabled(): ?\DateTimeInterface
{
return $this->date_disabled;
}
public function setDateDisabled(?\DateTimeInterface $date_disabled): self
{
$this->date_disabled = $date_disabled;
return $this;
}
/**
* @return Collection|Cropaction[]
*/
public function getCropaction(): Collection
{
return $this->cropaction;
}
public function addCropaction(Cropaction $cropaction): self
{
if (!$this->cropaction->contains($cropaction)) {
$this->cropaction[] = $cropaction;
$cropaction->setUser($this);
}
return $this;
}
public function removeCropaction(Cropaction $cropaction): self
{
if ($this->cropaction->contains($cropaction)) {
$this->cropaction->removeElement($cropaction);
// set the owning side to null (unless already changed)
if ($cropaction->getUser() === $this) {
$cropaction->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Survey[]
*/
public function getSurvey(): Collection
{
return $this->survey;
}
public function addSurvey(Survey $survey): self
{
if (!$this->survey->contains($survey)) {
$this->survey[] = $survey;
$survey->setUser($this);
}
return $this;
}
public function removeSurvey(Survey $survey): self
{
if ($this->survey->contains($survey)) {
$this->survey->removeElement($survey);
// set the owning side to null (unless already changed)
if ($survey->getUser() === $this) {
$survey->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Post[]
*/
public function getPost(): Collection
{
return $this->post;
}
public function addPost(Post $post): self
{
if (!$this->post->contains($post)) {
$this->post[] = $post;
$post->setUser($this);
}
return $this;
}
public function removePost(Post $post): self
{
if ($this->post->contains($post)) {
$this->post->removeElement($post);
// set the owning side to null (unless already changed)
if ($post->getUser() === $this) {
$post->setUser(null);
}
}
return $this;
}
/**
* @return Collection|PostComment[]
*/
public function getPostComment(): Collection
{
return $this->postComment;
}
public function addPostComment(PostComment $postComment): self
{
if (!$this->postComment->contains($postComment)) {
$this->postComment[] = $postComment;
$postComment->setUser($this);
}
return $this;
}
public function removePostComment(PostComment $postComment): self
{
if ($this->postComment->contains($postComment)) {
$this->postComment->removeElement($postComment);
// set the owning side to null (unless already changed)
if ($postComment->getUser() === $this) {
$postComment->setUser(null);
}
}
return $this;
}
/**
* @return Collection|PostBookmark[]
*/
public function getPostBookmark(): Collection
{
return $this->postBookmark;
}
public function addPostBookmark(PostBookmark $postBookmark): self
{
if (!$this->postBookmark->contains($postBookmark)) {
$this->postBookmark[] = $postBookmark;
$postBookmark->setUser($this);
}
return $this;
}
public function removePostBookmark(PostBookmark $postBookmark): self
{
if ($this->postBookmark->contains($postBookmark)) {
$this->postBookmark->removeElement($postBookmark);
// set the owning side to null (unless already changed)
if ($postBookmark->getUser() === $this) {
$postBookmark->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Rating[]
*/
public function getRating(): Collection
{
return $this->rating;
}
public function addRating(Rating $rating): self
{
if (!$this->rating->contains($rating)) {
$this->rating[] = $rating;
$rating->setUser($this);
}
return $this;
}
public function removeRating(Rating $rating): self
{
if ($this->rating->contains($rating)) {
$this->rating->removeElement($rating);
// set the owning side to null (unless already changed)
if ($rating->getUser() === $this) {
$rating->setUser(null);
}
}
return $this;
}
public function getProfile($skipTranslation = false): ?array
{
$profile = $this->profile;
if (!$skipTranslation && isset($profile['descriptionTranslation']) &&
$this->getCurrentLocale() !== $this->getDefaultLocale() &&
isset($profile['descriptionTranslation'][$this->getCurrentLocale()])) {
$profile['originalDescription'] = $profile['description'];
$profile['description'] = $profile['descriptionTranslation'][$this->getCurrentLocale()];
}
return $profile;
}
public function setProfile(?array $profile): self
{
$this->profile = $profile;
return $this;
}
public function getIsProfileTranslated(): bool
{
return isset($this->profile['descriptionTranslation']) &&
$this->getCurrentLocale() !== $this->getDefaultLocale() &&
isset($this->profile['descriptionTranslation'][$this->getCurrentLocale()]);
}
/**
* @return Collection|Appsurvey[]
*/
public function getAppsurvey(): Collection
{
return $this->appsurvey;
}
public function addAppsurvey(Appsurvey $appsurvey): self
{
if (!$this->appsurvey->contains($appsurvey)) {
$this->appsurvey[] = $appsurvey;
$appsurvey->setUser($this);
}
return $this;
}
public function removeAppsurvey(Appsurvey $appsurvey): self
{
if ($this->appsurvey->contains($appsurvey)) {
$this->appsurvey->removeElement($appsurvey);
// set the owning side to null (unless already changed)
if ($appsurvey->getUser() === $this) {
$appsurvey->setUser(null);
}
}
return $this;
}
/**
* @return Collection|PushNotification[]
*/
public function getPushNotification(): Collection
{
return $this->pushNotification;
}
public function addPushNotification(PushNotification $pushNotification): self
{
if (!$this->pushNotification->contains($pushNotification)) {
$this->pushNotification[] = $pushNotification;
$pushNotification->setUser($this);
}
return $this;
}
public function removePushNotification(PushNotification $pushNotification): self
{
if ($this->pushNotification->contains($pushNotification)) {
$this->pushNotification->removeElement($pushNotification);
// set the owning side to null (unless already changed)
if ($pushNotification->getUser() === $this) {
$pushNotification->setUser(null);
}
}
return $this;
}
public function getLoginCount(): ?int
{
return $this->login_count;
}
public function setLoginCount(?int $login_count): self
{
$this->login_count = $login_count;
return $this;
}
/**
* @return Collection|Image[]
*/
public function getImage(): Collection
{
return $this->image;
}
public function addImage(Image $image): self
{
if (!$this->image->contains($image)) {
$this->image[] = $image;
$image->setUser($this);
}
return $this;
}
public function removeImage(Image $image): self
{
if ($this->image->removeElement($image)) {
// set the owning side to null (unless already changed)
if ($image->getUser() === $this) {
$image->setUser(null);
}
}
return $this;
}
/**
* @return Collection|CropEdit[]
*/
public function getCropEdit(): Collection
{
return $this->cropEdit;
}
public function addCropEdit(CropEdit $cropEdit): self
{
if (!$this->cropEdit->contains($cropEdit)) {
$this->cropEdit[] = $cropEdit;
$cropEdit->setUser($this);
}
return $this;
}
public function removeCropEdit(CropEdit $cropEdit): self
{
if ($this->cropEdit->removeElement($cropEdit)) {
// set the owning side to null (unless already changed)
if ($cropEdit->getUser() === $this) {
$cropEdit->setUser(null);
}
}
return $this;
}
/**
* @return Collection|CropRating[]
*/
public function getCropRating(): Collection
{
return $this->cropRating;
}
public function addCropRating(CropRating $cropRating): self
{
if (!$this->cropRating->contains($cropRating)) {
$this->cropRating[] = $cropRating;
$cropRating->setUser($this);
}
return $this;
}
public function removeCropRating(CropRating $cropRating): self
{
if ($this->cropRating->removeElement($cropRating)) {
// set the owning side to null (unless already changed)
if ($cropRating->getUser() === $this) {
$cropRating->setUser(null);
}
}
return $this;
}
/**
* @return Collection|CartItem[]
*/
public function getCartItem(): Collection
{
return $this->cartItem;
}
public function addCartItem(CartItem $cartItem): self
{
if (!$this->cartItem->contains($cartItem)) {
$this->cartItem[] = $cartItem;
$cartItem->setUser($this);
}
return $this;
}
public function removeCartItem(CartItem $cartItem): self
{
if ($this->cartItem->removeElement($cartItem)) {
// set the owning side to null (unless already changed)
if ($cartItem->getUser() === $this) {
$cartItem->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Garden[]
*/
public function getGardens(): Collection
{
return $this->gardens;
}
public function addGarden(Garden $garden): self
{
if (!$this->gardens->contains($garden)) {
$this->gardens[] = $garden;
$garden->setUser($this);
}
return $this;
}
public function removeGarden(Garden $garden): self
{
if ($this->gardens->removeElement($garden)) {
// set the owning side to null (unless already changed)
if ($garden->getUser() === $this) {
$garden->setUser(null);
}
}
return $this;
}
public function isPaidAccount(): bool
{
$paidTypes = [
AccountType::Paid->value,
AccountType::Plus->value,
AccountType::Pro->value
];
return in_array($this->account_type, $paidTypes);
}
public function isValidPaidAccount(): bool
{
if (!$this->isPaidAccount()) {
return false;
}
if ($this->isLifetimePayment()) {
return true;
}
$paymentData = $this->getPaymentData();
$validUntil = (new \DateTime($paymentData[PaymentDataConstants::VALID_UNTIL]))->setTime(23, 59, 59);
$today = (new \DateTime())->setTime(0, 0, 0);
return $validUntil >= $today;
}
public function isReferralActivated(): bool
{
$type = $this->getPaymentDataField(PaymentDataConstants::TYPE);
return isset($type) && $type === PaymentType::Referral->value;
}
public function isLifetimePayment(): bool
{
$type = $this->getPaymentDataField(PaymentDataConstants::TYPE);
return isset($type) && $type === PaymentType::Lifetime->value;
}
public function isSubscriptionTrialPayment(): bool
{
$trialEnd = $this->getTrialEndDate();
if ($trialEnd === null) {
return false;
}
$today = (new \DateTime())->setTime(23, 59, 59);
return $today < $trialEnd;
}
public function isInAppPayment(): bool
{
$paymentData = $this->getPaymentData();
return isset($paymentData[PaymentDataConstants::IN_APP]);
}
public function getTrialEndDate($format = false): ?\DateTime
{
if (!$this->isPaidAccount() || $this->isLifetimePayment()) {
return null;
}
$start = $this->getPaymentStartDate();
if ($start === null) {
return null;
}
return (clone $start)->modify('+7 days')->setTime(23, 59, 59);
}
public function getPaymentStartDate(): ?\DateTime
{
$start = null;
$paymentData = $this->getPaymentData();
if (isset($paymentData[PaymentDataConstants::START_DATE])) {
$start = (new \DateTime($paymentData[PaymentDataConstants::START_DATE]))->setTime(0, 0);
} elseif (isset($paymentData[PaymentDataConstants::VALID_FROM])) {
$start = (new \DateTime($paymentData[PaymentDataConstants::VALID_FROM]))->setTime(0, 0);
}
return $start;
}
public function getSubscriptionStatus(): string
{
$paymentData = $this->getPaymentData();
if (empty($paymentData) || !isset($paymentData[PaymentDataConstants::TYPE])) {
return SubscriptionStatus::None->value;
}
if ($paymentData[PaymentDataConstants::TYPE] === 'referral' ||
$paymentData[PaymentDataConstants::TYPE] === 'voucher') {
return SubscriptionStatus::None->value;
}
if (isset($paymentData[PaymentDataConstants::IN_APP])) {
// iap status can be: Active, Cancelled, Expired -> we only map to active or cancelled
// if no iap status is set, the subscription is active too
if ((!isset($paymentData[PaymentDataConstants::IAP_STATUS]) && $this->isValidPaidAccount())
|| (isset($paymentData[PaymentDataConstants::IAP_STATUS]) &&
$paymentData[PaymentDataConstants::IAP_STATUS] === PaymentDataEnum::IapStatusActive->value)) {
return SubscriptionStatus::Active->value;
}
return SubscriptionStatus::Cancelled->value;
} else {
if (isset($paymentData[PaymentDataConstants::STATE])) {
if ($paymentData[PaymentDataConstants::STATE] === PaymentDataEnum::IapStatusActive->value) {
return SubscriptionStatus::Active->value;
}
return SubscriptionStatus::Cancelled->value;
}
}
return SubscriptionStatus::None->value;
}
public function getSubscriptionId(): ?string
{
$paymentData = $this->getPaymentData();
if (isset($paymentData[PaymentDataConstants::AGREEMENT_ID])) {
return $paymentData[PaymentDataConstants::AGREEMENT_ID];
}
return null;
}
public function getPaddleSubscriptionId(): ?string
{
$paymentData = $this->getPaymentData();
if (isset($paymentData[PaymentDataConstants::PADDLE_ID])) {
return $paymentData[PaymentDataConstants::PADDLE_ID];
}
return null;
}
public function getSubscriptionType(): ?string
{
$paymentData = $this->getPaymentData();
$locale = $this->getLocale();
$subscriptionType = '';
if (isset($paymentData[PaymentDataConstants::TYPE])) {
if ($locale === 'en') {
$subscriptionType = $paymentData[PaymentDataConstants::TYPE] === 'monthly' ? 'monthly subscription' : 'yearly subscription';
} else {
$subscriptionType = $paymentData[PaymentDataConstants::TYPE] === 'monthly' ? 'Monatsabo' : 'Jahresabo';
}
}
return $subscriptionType;
}
public function getSubscriptionTypeEnum(): ?string
{
$paymentData = $this->getPaymentData();
if (isset($paymentData[PaymentDataConstants::TYPE]) &&
isset($paymentData[PaymentDataConstants::TYPE]) !== null) {
return $paymentData[PaymentDataConstants::TYPE];
}
return 'none';
}
public function getPaymentType(): ?string
{
$paymentData = $this->getPaymentData();
if ($this->getSubscriptionTypeEnum() === 'voucher') {
return 'voucher';
}
if (isset($paymentData[PaymentDataConstants::IN_APP])) {
// todo: in-app google / apple
$payments = $this->getPayment();
if ($payments->count() === 0) {
return 'in-app';
} else {
/** @var Payment $lastPayment */
$lastPayment = $payments->last();
return 'in-app-' . $lastPayment->getProvider();
}
}
if (isset($paymentData[PaymentDataConstants::AGREEMENT_ID])) {
return 'paypal';
}
return 'none';
}
public function setSetting($settingName, $settingValue): void
{
$settings = $this->settings;
if ($settingName === SettingConstants::SOURCE) {
$originalSettingValue = $settingValue;
$settings[SettingConstants::SOURCE_RAW] = $originalSettingValue;
// todo: if setting string contains utm_content with json data, then decode and decrypt with fb key to attribute
if (str_contains($originalSettingValue, 'utm_content')) {
$result = MetaAttributionHelper::extractData($originalSettingValue);
if ($result !== null) {
$settings[SettingConstants::SOURCE_ATTRIBUTION] = $result;
}
}
// limit setting value to 255 chars
$settingValue = substr($settingValue, 0, 254);
}
$settings[$settingName] = $settingValue;
$this->setSettings($settings);
}
public function getSetting($settingName)
{
return $this->settings[$settingName] ?? null;
}
/**
* @return Collection|CommentLike[]
*/
public function getCommentLikes(): Collection
{
return $this->commentLikes;
}
public function addCommentLike(CommentLike $commentLike): self
{
if (!$this->commentLikes->contains($commentLike)) {
$this->commentLikes[] = $commentLike;
$commentLike->setUser($this);
}
return $this;
}
public function removeCommentLike(CommentLike $commentLike): self
{
if ($this->commentLikes->removeElement($commentLike)) {
// set the owning side to null (unless already changed)
if ($commentLike->getUser() === $this) {
$commentLike->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Notification[]
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setUser($this);
}
return $this;
}
public function removeNotification(Notification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getUser() === $this) {
$notification->setUser(null);
}
}
return $this;
}
public function isModerator(): bool
{
// super moderators always have moderator privileges too
if ($this->isSuperModerator()) {
return true;
}
$settings = $this->getSettings();
return isset($settings[SettingConstants::IS_MODERATOR]) && $settings[SettingConstants::IS_MODERATOR] === true;
}
public function isSuperModerator(): bool
{
$settings = $this->getSettings();
return isset($settings[SettingConstants::IS_SUPER_MODERATOR]) && $settings[SettingConstants::IS_SUPER_MODERATOR] === true;
}
/**
* @return Collection|Nps[]
*/
public function getNps(): Collection
{
return $this->nps;
}
public function addNp(Nps $np): self
{
if (!$this->nps->contains($np)) {
$this->nps[] = $np;
$np->setUser($this);
}
return $this;
}
public function removeNp(Nps $np): self
{
if ($this->nps->removeElement($np)) {
// set the owning side to null (unless already changed)
if ($np->getUser() === $this) {
$np->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, UserConnection>
*/
public function getUserConnections(): Collection
{
return $this->userConnections;
}
public function addUserConnection(UserConnection $userConnection): self
{
if (!$this->userConnections->contains($userConnection)) {
$this->userConnections[] = $userConnection;
$userConnection->setUser($this);
}
return $this;
}
public function removeUserConnection(UserConnection $userConnection): self
{
if ($this->userConnections->removeElement($userConnection)) {
// set the owning side to null (unless already changed)
if ($userConnection->getUser() === $this) {
$userConnection->setUser(null);
}
}
return $this;
}
public function getDisplayName(): string
{
if ($this->nickname !== null && trim($this->nickname) !== '') {
return $this->nickname;
}
$name = $this->firstname;
if (!empty($this->lastname)) {
$name .= ' ' . mb_substr($this->lastname, 0, 1) . '.';
}
return $name ?? '';
}
/**
* @return Collection<int, Reminder>
*/
public function getReminders(): Collection
{
return $this->reminders;
}
public function addReminder(Reminder $reminder): self
{
if (!$this->reminders->contains($reminder)) {
$this->reminders[] = $reminder;
$reminder->setUser($this);
}
return $this;
}
public function removeReminder(Reminder $reminder): self
{
if ($this->reminders->removeElement($reminder)) {
// set the owning side to null (unless already changed)
if ($reminder->getUser() === $this) {
$reminder->setUser(null);
}
}
return $this;
}
public function setImageDataUri(string $uri): self
{
$this->imageDataUri = $uri;
return $this;
}
public function getImageDataUri(): string
{
return $this->imageDataUri;
}
/**
* @return Collection<int, ProfitwellUser>
*/
public function getProfitwellUsers(): Collection
{
return $this->profitwellUsers;
}
public function addProfitwellUser(ProfitwellUser $profitwellUser): self
{
if (!$this->profitwellUsers->contains($profitwellUser)) {
$this->profitwellUsers[] = $profitwellUser;
$profitwellUser->setUser($this);
}
return $this;
}
public function removeProfitwellUser(ProfitwellUser $profitwellUser): self
{
if ($this->profitwellUsers->removeElement($profitwellUser)) {
// set the owning side to null (unless already changed)
if ($profitwellUser->getUser() === $this) {
$profitwellUser->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Template>
*/
public function getTemplates(): Collection
{
return $this->templates;
}
public function addTemplate(Template $template): self
{
if (!$this->templates->contains($template)) {
$this->templates[] = $template;
$template->setCreatedByUser($this);
}
return $this;
}
public function removeTemplate(Template $template): self
{
if ($this->templates->removeElement($template)) {
// set the owning side to null (unless already changed)
if ($template->getCreatedByUser() === $this) {
$template->setCreatedByUser(null);
}
}
return $this;
}
public function updateMentionTag(): self
{
$transformation = [" " => "_", "-" => "_", "#" => "", "@" => ""];
if (!empty($this->getNickname())) {
$sanitized = strtr($this->getNickname(), $transformation);
$this->setSetting('mentionTag', $sanitized);
}
return $this;
}
/**
* @return Collection<int, FavoriteTemplate>
*/
public function getFavoriteTemplates(): Collection
{
return $this->favoriteTemplates;
}
public function addFavoriteTemplate(FavoriteTemplate $favoriteTemplate): self
{
if (!$this->favoriteTemplates->contains($favoriteTemplate)) {
$this->favoriteTemplates[] = $favoriteTemplate;
$favoriteTemplate->setUser($this);
}
return $this;
}
public function removeFavoriteTemplate(FavoriteTemplate $favoriteTemplate): self
{
if ($this->favoriteTemplates->removeElement($favoriteTemplate)) {
// set the owning side to null (unless already changed)
if ($favoriteTemplate->getUser() === $this) {
$favoriteTemplate->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, TemplateUsage>
*/
public function getTemplateUsages(): Collection
{
return $this->templateUsages;
}
public function addTemplateUsage(TemplateUsage $templateUsage): self
{
if (!$this->templateUsages->contains($templateUsage)) {
$this->templateUsages[] = $templateUsage;
$templateUsage->setUser($this);
}
return $this;
}
public function removeTemplateUsage(TemplateUsage $templateUsage): self
{
if ($this->templateUsages->removeElement($templateUsage)) {
// set the owning side to null (unless already changed)
if ($templateUsage->getUser() === $this) {
$templateUsage->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, ObjectComment>
*/
public function getObjectComments(): Collection
{
return $this->objectComments;
}
public function addObjectComment(ObjectComment $objectComment): self
{
if (!$this->objectComments->contains($objectComment)) {
$this->objectComments[] = $objectComment;
$objectComment->setUser($this);
}
return $this;
}
public function removeObjectComment(ObjectComment $objectComment): self
{
if ($this->objectComments->removeElement($objectComment)) {
// set the owning side to null (unless already changed)
if ($objectComment->getUser() === $this) {
$objectComment->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, PreferencesToken>
*/
public function getPreferencesTokens(): Collection
{
return $this->preferencesTokens;
}
public function addPreferencesToken(PreferencesToken $preferencesToken): self
{
if (!$this->preferencesTokens->contains($preferencesToken)) {
$this->preferencesTokens[] = $preferencesToken;
$preferencesToken->setUser($this);
}
return $this;
}
public function removePreferencesToken(PreferencesToken $preferencesToken): self
{
if ($this->preferencesTokens->removeElement($preferencesToken)) {
// set the owning side to null (unless already changed)
if ($preferencesToken->getUser() === $this) {
$preferencesToken->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Usercontent>
*/
public function getUsercontents(): Collection
{
return $this->usercontents;
}
public function addUsercontent(Usercontent $usercontent): self
{
if (!$this->usercontents->contains($usercontent)) {
$this->usercontents[] = $usercontent;
$usercontent->setUser($this);
}
return $this;
}
public function removeUsercontent(Usercontent $usercontent): self
{
if ($this->usercontents->removeElement($usercontent)) {
// set the owning side to null (unless already changed)
if ($usercontent->getUser() === $this) {
$usercontent->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, TagConnection>
*/
public function getTagConnections(): Collection
{
return $this->tagConnections;
}
public function addTagConnection(TagConnection $tagConnection): self
{
if (!$this->tagConnections->contains($tagConnection)) {
$this->tagConnections[] = $tagConnection;
$tagConnection->setUser($this);
}
return $this;
}
public function removeTagConnection(TagConnection $tagConnection): self
{
if ($this->tagConnections->removeElement($tagConnection)) {
// set the owning side to null (unless already changed)
if ($tagConnection->getUser() === $this) {
$tagConnection->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Croplist>
*/
public function getCropLists(): Collection
{
return $this->cropLists;
}
public function addCropList(Croplist $cropList): self
{
if (!$this->cropLists->contains($cropList)) {
$this->cropLists->add($cropList);
$cropList->setUser($this);
}
return $this;
}
public function removeCropList(Croplist $cropList): self
{
if ($this->cropLists->removeElement($cropList)) {
// set the owning side to null (unless already changed)
if ($cropList->getUser() === $this) {
$cropList->setUser(null);
}
}
return $this;
}
public function getLocale(): ?string
{
return $this->locale;
}
public function setLocale(?string $locale): static
{
$this->locale = $locale;
return $this;
}
/**
* @return Collection<int, CancellationSurvey>
*/
public function getCancellationSurveys(): Collection
{
return $this->cancellationSurveys;
}
public function addCancellationSurvey(CancellationSurvey $cancellationSurvey): static
{
if (!$this->cancellationSurveys->contains($cancellationSurvey)) {
$this->cancellationSurveys->add($cancellationSurvey);
$cancellationSurvey->setUser($this);
}
return $this;
}
public function removeCancellationSurvey(CancellationSurvey $cancellationSurvey): static
{
if ($this->cancellationSurveys->removeElement($cancellationSurvey)) {
// set the owning side to null (unless already changed)
if ($cancellationSurvey->getUser() === $this) {
$cancellationSurvey->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, ModerationNotification>
*/
public function getModerationNotifications(): Collection
{
return $this->moderationNotifications;
}
public function addModerationNotification(ModerationNotification $moderationNotification): static
{
if (!$this->moderationNotifications->contains($moderationNotification)) {
$this->moderationNotifications->add($moderationNotification);
$moderationNotification->setUser($this);
}
return $this;
}
public function removeModerationNotification(ModerationNotification $moderationNotification): static
{
if ($this->moderationNotifications->removeElement($moderationNotification)) {
// set the owning side to null (unless already changed)
if ($moderationNotification->getUser() === $this) {
$moderationNotification->setUser(null);
}
}
return $this;
}
public function getTest(): ?string
{
return $this->test;
}
public function setTest(string $test): static
{
$this->test = $test;
return $this;
}
public function getClimateSettings(): ?array
{
return $this->climate_settings;
}
public function setClimateSettings(?array $climate_settings): static
{
$this->climate_settings = $climate_settings;
return $this;
}
public function getUnits(): ?array
{
return $this->units;
}
public function setUnits(?array $units): static
{
$this->units = $units;
return $this;
}
/**
* @return Collection<int, PostReport>
*/
public function getPostReports(): Collection
{
return $this->postReports;
}
public function addPostReport(PostReport $postReport): static
{
if (!$this->postReports->contains($postReport)) {
$this->postReports->add($postReport);
$postReport->setReportedByUserId($this);
}
return $this;
}
public function removePostReport(PostReport $postReport): static
{
if ($this->postReports->removeElement($postReport)) {
// set the owning side to null (unless already changed)
if ($postReport->getReportedByUserId() === $this) {
$postReport->setReportedByUserId(null);
}
}
return $this;
}
}