<?php
namespace App\Entity\User;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\Cart\GiftCart;
use App\Entity\Cart\OperationCart;
use App\Entity\Catalog\Order;
use App\Entity\Company\Company;
use App\Entity\Newsletter;
use App\Entity\Operation\Operation;
use App\Entity\Participation\Participation;
use App\Entity\Purse\Purse;
use App\Entity\Security\Profile;
use App\Entity\Sponsorship\SponsorshipRequest;
use App\Entity\Tas\TasDraw;
use App\Entity\Token;
use App\Entity\User\Carrier;
use App\Entity\User\Address\Delivery;
use App\Entity\User\Address\Home;
use App\Entity\User\Payment\Iban;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\OrderBy;
use App\Traits\TimestampableTrait;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\ExclusionPolicy;
use Ramsey\Uuid\Doctrine\UuidGenerator;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ExclusionPolicy("all")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ApiResource(
* attributes={
* "normalization_context"={"groups"={
* "User:output",
* "User:io",
* }},
* "denormalization_context"={"groups"={
* "User:input",
* "User:io",
* "reset_password",
* "initialize_password",
* }}
* },
* itemOperations={
* "put"={
* "access_control"="is_granted('ROLE_USER')",
* "validation_groups"={"Default", "Edit"}
* },
* }
* )
*/
//@todo add validators
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
public const ROLE_USER = 'ROLE_USER';
public const ROLE_ADMIN_SOGEC = 'ROLE_ADMIN_SOGEC';
public const IMPORT_GENDER = 'civilité';
public const IMPORT_LASTNAME = 'nom';
public const IMPORT_FIRSTNAME = 'prenom';
public const IMPORT_EMAIL = 'email';
public const MAX_CARRIERS_AUTHORIZED = 3;
/**
* @Groups({
* "User:io",
* })
*/
use TimestampableTrait;
/**
* @ORM\Id
* @ORM\Column(type="uuid", unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
* @SerializedName("id")
* @ApiProperty(identifier=true)
* @Assert\Uuid()
* @Groups({
* "User:output",
* "Token:output",
* "ParticipationStep:io",
* "get_user_operation_carts",
* "post_participation_step_ask_refund",
* "get_godfather_by_godchild_email",
* "SponsorshipRequest:output",
* })
*/
private string $id;
/**
* @ORM\OneToOne(targetEntity=Identity::class, cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
* @SerializedName("identity")
* @Assert\NotBlank()
* @Assert\Valid()
* @Groups({"User:io", "get_godfather_by_godchild_email", "SponsorshipRequest:output"})
*/
private Identity $identity;
/**
* @ORM\Column(type="string", length=180)
* @SerializedName("email")
* @Assert\NotBlank()
* @Assert\Email(normalizer="trim")
* @Groups({"User:io", "get_godfather_by_godchild_email"})
*
* @Serializer\Expose()
* @Serializer\Groups({"shannon", "get_user_facebook"})
* @Serializer\SerializedName("email")
*/
private ?string $email;
/**
* @ORM\Column(type="json")
* @SerializedName("roles")
* @Groups({"User:output"})
*/
private array $roles = ['ROLE_USER'];
/**
* @Assert\NotBlank(groups={
* "Create",
* "reset_password",
* "initialize_password",
* })
* @Assert\Length(max=4096)
* @Groups({
* "User:input",
* "reset_password",
* "initialize_password",
* })
*/
private ?string $plainPassword = null;
/**
* The below length depends on the "algorithm" you use for encoding
* the password, but this works well with bcrypt.
*
* @var string The hashed password
* @ORM\Column(type="string", length=64)
* @SerializedName("password")
* @Groups({
* "User:io",
* })
*/
private string $password;
/**
* @var bool
* @ORM\Column(type="boolean", nullable=true)
* @SerializedName("optin_brand")
* @Groups({"User:io", "get_godfather_by_godchild_email", "patch_optin_brand_phone", "patch_optin_isoskele"})
*/
private ?bool $optinBrand = null;
/**
* @var bool
* @ORM\Column(type="boolean", nullable=true)
* @SerializedName("optin_customer")
* @Groups({"User:io", "get_godfather_by_godchild_email", "patch_optin_isoskele"})
*/
private ?bool $optinCustomer = null;
/**
* @var bool
* @ORM\Column(type="boolean", nullable=true)
* @SerializedName("optin_process")
* @Groups({
* "User:io",
* "initialize_password",
* })
*/
private ?bool $optinProcess = null;
/**
* @var bool
* @ORM\Column(type="boolean", nullable=true)
* @SerializedName("optin_phone")
* @Groups({
* "User:io",
* "initialize_password",
* "patch_optin_brand_phone",
* })
*/
private ?bool $optinPhone = null;
/**
* @var bool
* @ORM\Column(type="boolean", nullable=true)
* @SerializedName("optin_sales")
* @Groups({
* "User:io",
* "initialize_password",
* })
*/
private ?bool $optinSales = null;
/**
* @var bool
* @ORM\Column(type="boolean", nullable=true)
* @SerializedName("optin_whats_app")
* @Groups({"User:io", "patch_optin_isoskele"})
*/
private ?bool $optinWhatsApp = null;
/**
* @var bool
* @ORM\Column(type="boolean", nullable=true)
* @SerializedName("optin_mobile_carriers")
* @Groups({"User:io", "patch_optin_isoskele"})
*/
private ?bool $optinMobileCarriers = null;
/**
* @var bool
* @ORM\Column(type="boolean", nullable=true)
* @SerializedName("optin_whats_app_carriers")
* @Groups({"User:io", "patch_optin_isoskele"})
*/
private ?bool $optinWhatsAppCarriers = null;
/**
* @ORM\OneToMany(targetEntity=Home::class, mappedBy="user", orphanRemoval=true, cascade={"persist"})
* @SerializedName("addresses_home")
* @Assert\Valid()
* @Groups({"User:io"})
*/
private Collection $addressesHome;
/**
* @ORM\OneToMany(targetEntity=Delivery::class, mappedBy="user", orphanRemoval=true, cascade={"persist"})
* @SerializedName("addresses_delivery")
* @Assert\Valid()
* @Groups({"User:io"})
*/
private Collection $addressesDelivery;
/**
* @ORM\OneToMany(targetEntity=Order::class, mappedBy="user", orphanRemoval=true, cascade={"persist"})
* @SerializedName("addresses_order")
* @Assert\Valid()
* @Groups({"User:io"})
*/
private Collection $addressesOrder;
/**
* @ORM\OneToMany(targetEntity=Token::class, mappedBy="user")
* @SerializedName("tokens")
*/
private Collection $tokens;
/**
* @ORM\OneToMany(targetEntity=Newsletter::class, mappedBy="user")
* @SerializedName("user")
*/
private Collection $newsletters;
/**
* @ORM\OneToMany(targetEntity=Iban::class, mappedBy="user", orphanRemoval=true)
* @SerializedName("ibans")
* @Groups({"User:io"})
*/
private Collection $ibans;
/**
* @ORM\ManyToOne(targetEntity=Company::class, inversedBy="users")
* @Assert\NotBlank()
* @Groups({"User:io"})
*/
private $company;
/**
* @ORM\OneToMany(targetEntity=Operation::class, mappedBy="owner", orphanRemoval=true, cascade={"persist"})
* @SerializedName("operations")
*/
private Collection $operations;
/**
* @ORM\OneToMany(targetEntity=Participation::class, mappedBy="user")
* @OrderBy({"createdAt" = "ASC"})
*/
private $participations;
/**
* @ORM\OneToMany(targetEntity=SponsorshipRequest::class, mappedBy="user")
*/
private Collection $sponsorshipsRequest;
/**
* @ORM\OneToMany(targetEntity=Carrier::class, mappedBy="user", orphanRemoval=true, cascade={"persist"})
* @SerializedName("carriers")
* @Groups({"User:io"})
*/
private Collection $carriers;
/**
* @ORM\OneToMany(targetEntity=OperationCart::class, mappedBy="user")
*/
private Collection $operationCarts;
/**
* @ORM\OneToMany(targetEntity=GiftCart::class, mappedBy="user")
*/
private Collection $giftCarts;
/**
* @ORM\OneToMany(targetEntity=Purse::class, mappedBy="user", orphanRemoval=true)
*/
private $purses;
/**
* @ORM\OneToMany(targetEntity=Order::class, mappedBy="user")
*/
private $orders;
/**
* @ORM\Column(type="array", nullable=true)
* @SerializedName("extra_data")
* @Groups({"User:io"})
*/
private $extraData;
/**
* @ORM\OneToMany(targetEntity=TasDraw::class, mappedBy="user")
*/
private $tas;
/**
* @var \DateTime
*
* @ORM\Column(name="deleted_at", type="datetime", nullable=true)
*/
private $deletedAt;
/**
* @var bool
*/
private $import = false;
/**
* @ORM\Column(type="string", length=180, nullable=true)
* @SerializedName("referral_code")
* @Groups({"User:io"})
*/
private ?string $referralCode;
/**
* @ORM\Column(type="string", length=180, nullable=true)
* @SerializedName("company_name")
* @Groups({"User:io"})
*/
private ?string $companyName;
/**
* @ORM\Column(type="string", length=14, nullable=true)
* @SerializedName("siret")
* @Assert\Length(max="14")
* @Groups({"User:io"})
*/
private ?string $siret;
/**
* @ORM\ManyToOne(targetEntity="Referent")
* @ORM\JoinColumn(name="referent_id", referencedColumnName="id", nullable=true)
* @Groups({"User:io"})
*/
private $referent;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User\Strate")
* @ORM\JoinColumn(name="strate_id", referencedColumnName="id", nullable=true)
* @Groups({"User:io"})
*/
private $strate;
/**
* @ORM\ManyToOne(targetEntity=Profile::class, inversedBy="users")
* @ORM\JoinColumn(nullable=true)
*/
private $profile;
/**
* @ORM\Column(type="boolean", options={"default": 0})
*/
private $active;
/**
* @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"}, nullable=true)
* @Groups({"User:io"})
*/
private ?\DateTimeInterface $lastLogin;
/**
* @ORM\Column(type="array", nullable=true)
* @SerializedName("additional_information")
* @Groups({"User:io"})
*/
private ?array $additionalInformation;
/**
* @ORM\Column(type="string", length=10, nullable=true)
* @SerializedName("phone_number")
* @Assert\Length(max="10")
* @Groups({"User:io"})
*/
private ?string $phoneNumber;
/**
* @ORM\Column(type="string", nullable=true)
* @SerializedName("other")
* @Groups({
* "User:io",
* "initialize_password",
* })
*/
private ?string $other;
/**
* @Groups({"User:io"})
* @SerializedName("knowledge_responses")
* @ORM\Column(type="json", nullable=true)
*/
private ?array $knowledgeResponses = [];
public function __construct()
{
$this->addressesDelivery = new ArrayCollection();
$this->addressesHome = new ArrayCollection();
$this->tokens = new ArrayCollection();
$this->ibans = new ArrayCollection();
$this->newsletters = new ArrayCollection();
$this->operations = new ArrayCollection();
$this->participations = new ArrayCollection();
$this->operationCarts = new ArrayCollection();
$this->giftCarts = new ArrayCollection();
$this->purses = new ArrayCollection();
$this->orders = new ArrayCollection();
$this->tas = new ArrayCollection();
$this->sponsorshipsRequest = new ArrayCollection();
$this->carriers = new ArrayCollection();
}
/**
* @Serializer\VirtualProperty
* @Serializer\Groups({"global_shannon"})
* @Serializer\SerializedName("participation_id")
* @return string
*/
public function getId(): ?string
{
return $this->id;
}
public function getIdentity(): ?Identity
{
return $this->identity;
}
public function setIdentity(Identity $identity): self
{
$this->identity = $identity;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string)$this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @return string|null
*/
public function getPlainPassword(): ?string
{
return $this->plainPassword;
}
/**
* @param string|null $plainPassword
* @return User
*/
public function setPlainPassword(?string $plainPassword): User
{
$this->plainPassword = $plainPassword;
return $this;
}
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string)$this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
$this->plainPassword = null;
}
/**
* @return Collection|Home[]
*/
public function getAddresses(): Collection
{
return $this->addressesHome;
}
/**
* @return Collection|Home[]
*/
public function getAddressesHome(): Collection
{
return $this->addressesHome;
}
public function addAddressHome(Home $addressHome): self
{
if (!$this->addressesHome->contains($addressHome)) {
$this->addressesHome[] = $addressHome;
$addressHome->setUser($this);
}
return $this;
}
public function removeAddressHome(Home $addressHome): self
{
if ($this->addressesHome->contains($addressHome)) {
$this->addressesHome->removeElement($addressHome);
// set the owning side to null (unless already changed)
if ($addressHome->getUser() === $this) {
$addressHome->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Delivery[]
*/
public function getAddressesDelivery(): Collection
{
return $this->addressesDelivery;
}
public function addAddressDelivery(Delivery $addressDelivery): self
{
if (!$this->addressesDelivery->contains($addressDelivery)) {
$this->addressesDelivery[] = $addressDelivery;
$addressDelivery->setUser($this);
}
return $this;
}
public function removeAddressDelivery(Delivery $addressDelivery): self
{
if ($this->addressesDelivery->contains($addressDelivery)) {
$this->addressesDelivery->removeElement($addressDelivery);
// set the owning side to null (unless already changed)
if ($addressDelivery->getUser() === $this) {
$addressDelivery->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Token[]
*/
public function getTokens(): Collection
{
return $this->tokens;
}
public function addToken(Token $token): self
{
if (!$this->tokens->contains($token)) {
$this->tokens[] = $token;
$token->setUser($this);
}
return $this;
}
public function removeToken(Token $token): self
{
if ($this->tokens->contains($token)) {
$this->tokens->removeElement($token);
// set the owning side to null (unless already changed)
if ($token->getUser() === $this) {
$token->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Iban[]
*/
public function getIbans(): Collection
{
return $this->ibans;
}
public function addIban(Iban $iban): self
{
if (!$this->ibans->contains($iban)) {
$this->ibans[] = $iban;
$iban->setUser($this);
}
return $this;
}
public function removeIban(Iban $iban): self
{
if ($this->ibans->removeElement($iban)) {
// set the owning side to null (unless already changed)
if ($iban->getUser() === $this) {
$iban->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Newsletter[]
*/
public function getNewsletters(): Collection
{
return $this->newsletters;
}
public function addNewsletter(Newsletter $newsletter): self
{
if (!$this->newsletters->contains($newsletter)) {
$this->newsletters[] = $newsletter;
$newsletter->setUser($this);
}
return $this;
}
public function removeNewsletter(Newsletter $newsletter): self
{
if ($this->newsletters->contains($newsletter)) {
$this->newsletters->removeElement($newsletter);
if ($newsletter->getUser() === $this) {
$newsletter->setUser(null);
}
}
return $this;
}
/**
* @return bool|null
*/
public function isOptinBrand()
{
return $this->optinBrand;
}
/**
* @param bool $optinBrand
*
* @return User
*/
public function setOptinBrand(bool $optinBrand): User
{
$this->optinBrand = $optinBrand;
return $this;
}
/**
* @return bool|null
*/
public function isOptinCustomer()
{
return $this->optinCustomer;
}
/**
* @param bool $optinCustomer
*
* @return User
*/
public function setOptinCustomer(bool $optinCustomer): User
{
$this->optinCustomer = $optinCustomer;
return $this;
}
/**
* @return bool
*/
public function isOptinProcess(): bool
{
return (bool)$this->optinProcess;
}
/**
* @param bool $optinProcess
*
* @return User
*/
public function setOptinProcess(bool $optinProcess): User
{
$this->optinProcess = $optinProcess;
return $this;
}
/**
* @return bool
*/
public function isOptinPhone(): bool
{
return (bool)$this->optinPhone;
}
/**
* @param bool $optinPhone
*
* @return User
*/
public function setOptinPhone(?bool $optinPhone): User
{
$this->optinPhone = $optinPhone;
return $this;
}
/**
* @return bool
*/
public function isOptinSales(): bool
{
return (bool)$this->optinSales;
}
/**
* @param bool $optinSales
*
* @return User
*/
public function setOptinSales(bool $optinSales): User
{
$this->optinSales = $optinSales;
return $this;
}
/**
* @return bool
*/
public function isOptinWhatsApp(): bool
{
return (bool)$this->optinWhatsApp;
}
/**
* @param bool $optinWhatsApp
*
* @return User
*/
public function setOptinWhatsApp(bool $optinWhatsApp): User
{
$this->optinWhatsApp = $optinWhatsApp;
return $this;
}
/**
* @return bool
*/
public function isOptinMobileCarriers(): bool
{
return (bool)$this->optinMobileCarriers;
}
/**
* @param bool $optinMobileCarriers
*
* @return User
*/
public function setOptinMobileCarriers(bool $optinMobileCarriers): User
{
$this->optinMobileCarriers = $optinMobileCarriers;
return $this;
}
/**
* @return bool
*/
public function isOptinWhatsAppCarriers(): bool
{
return (bool)$this->optinWhatsAppCarriers;
}
/**
* @param bool $optinWhatsAppCarriers
*
* @return User
*/
public function setOptinWhatsAppCarriers(bool $optinWhatsAppCarriers): User
{
$this->optinWhatsAppCarriers = $optinWhatsAppCarriers;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
/**
* @return ArrayCollection|Collection
*/
public function getOperations()
{
return $this->operations;
}
/**
* @param ArrayCollection|Collection $operations
*
* @return User
*/
public function setOperations($operations)
{
$this->operations = $operations;
return $this;
}
/**
* @return Collection|Participation[]
*/
public function getParticipations(): Collection
{
return $this->participations;
}
public function addParticipation(Participation $participation): self
{
if (!$this->participations->contains($participation)) {
$this->participations[] = $participation;
$participation->setUser($this);
}
return $this;
}
public function removeParticipation(Participation $participation): self
{
if ($this->participations->removeElement($participation)) {
// set the owning side to null (unless already changed)
if ($participation->getUser() === $this) {
$participation->setUser(null);
}
}
return $this;
}
/**
* @return Collection|OperationCart[]
*/
public function getOperationCarts(): Collection
{
return $this->operationCarts;
}
public function addOperationCart(OperationCart $operationCart): self
{
if (!$this->operationCarts->contains($operationCart)) {
$this->operationCarts[] = $operationCart;
$operationCart->setUser($this);
}
return $this;
}
public function removeCart(OperationCart $operationCart): self
{
if ($this->operationCarts->removeElement($operationCart)) {
// set the owning side to null (unless already changed)
if ($operationCart->getUser() === $this) {
$operationCart->setUser(null);
}
}
return $this;
}
/**
* @return Collection|GiftCart[]
*/
public function getGiftCarts(): Collection
{
return $this->giftCarts;
}
public function addGiftCart(GiftCart $giftCart): self
{
if (!$this->giftCarts->contains($giftCart)) {
$this->giftCarts[] = $giftCart;
$giftCart->setUser($this);
}
return $this;
}
public function removeGiftCart(GiftCart $giftCart): self
{
if ($this->giftCarts->removeElement($giftCart)) {
// set the owning side to null (unless already changed)
if ($giftCart->getUser() === $this) {
$giftCart->setUser(null);
}
}
return $this;
}
// Shannon serialisation
/**
* @Serializer\VirtualProperty
* @Serializer\Type("string")
* @Serializer\Groups({"shannon"})
* @Serializer\SerializedName("civility")
* @return string
*/
public function getCivility(): string
{
$civility = "1";
if ($this->getIdentity()->getGender() === Identity::GENDER_FEMALE) {
$civility = "2";
}
return $civility;
}
public function getGender(): ?string
{
return $this->getIdentity()->getGender();
}
/**
* @Serializer\VirtualProperty
* @Serializer\Groups({"shannon"})
* @Serializer\SerializedName("firstname")
* @return string
*/
public function getFirstName(): string
{
return $this->getIdentity()->getFirstName();
}
/**
* @Serializer\VirtualProperty
* @Serializer\Groups({"shannon"})
* @Serializer\SerializedName("lastname")
* @return string
*/
public function getLastName(): string
{
return $this->getIdentity()->getLastName();
}
/**
* @Serializer\VirtualProperty
* @Serializer\SerializedName("address_3")
* @return string
*/
public function getAddress3(): string
{
$addressHome = $this->getAddressesHome()->first();
if ($addressHome instanceof Home) {
return $addressHome->getStreet();
}
return '';
}
/**
* @Serializer\VirtualProperty
* @Serializer\Groups({"shannon", "shannon_refund"})
* @Serializer\SerializedName("country")
* @return string
*/
public function getCountry(): string
{
return 'FR';
}
/**
* @Serializer\VirtualProperty
* @Serializer\SerializedName("city")
* @return string
*/
public function getCity(): string
{
$addressHome = $this->getAddressesHome()->first();
if ($addressHome instanceof Home) {
return $addressHome->getCity();
}
return '';
}
/**
* @Serializer\VirtualProperty
* @Serializer\SerializedName("postal_code")
* @return string
*/
public function getPostalCode(): string
{
$addressHome = $this->getAddressesHome()->first();
if ($addressHome instanceof Home) {
return $addressHome->getPostalCode();
}
return '';
}
/**
* @return Purse|null
*/
public function getCurrentPurse(): ?Purse
{
foreach ($this->getPurses() as $purse) {
if ($purse->getDueAt() >= new \DateTime() && $purse->getStatus() === Purse::STATUS_AVAILABLE) {
return $purse;
}
}
return null;
}
/**
* @return Collection<Purse>|Purse[]
*/
public function getPurses(): Collection
{
return $this->purses;
}
public function addPurse(Purse $purse): self
{
if (!$this->purses->contains($purse)) {
$this->purses[] = $purse;
$purse->setUser($this);
}
return $this;
}
public function removePurse(Purse $purse): self
{
if ($this->purses->removeElement($purse)) {
// set the owning side to null (unless already changed)
if ($purse->getUser() === $this) {
$purse->setUser(null);
}
}
return $this;
}
public function getPursesIds(): iterable
{
foreach ($this->purses as $purse) {
yield $purse->getId();
}
}
/**
* @Serializer\VirtualProperty
* @Serializer\Groups({"global_shannon"})
* @Serializer\SerializedName("channel")
* @return string
*/
public function getChannel(): string
{
return 'FI';
}
/**
* @Serializer\VirtualProperty
* @Serializer\Groups({"global_shannon"})
* @Serializer\SerializedName("action")
* @return string
*/
public function getAction(): string
{
return 'create';
}
public function __toString(): string
{
return $this->email;
}
/**
* @Serializer\VirtualProperty
* @Serializer\Groups({"global_shannon"})
* @Serializer\SerializedName("participation_jeu")
* @return string
*/
public function getParticipationJeu(): int
{
return 1;
}
/**
* @Serializer\VirtualProperty
* @Serializer\Groups({"global_shannon"})
* @Serializer\SerializedName("date_participation")
*/
public function getDateParticipation()
{
$date = new \DateTime();
return $date->format('Y-m-d H:i:s');
}
/**
* @Serializer\VirtualProperty
* @Serializer\Groups({"shannon"})
* @Serializer\SerializedName("id")
* @return string
*/
public function getIdConso(): string
{
return $this->id;
}
/**
* @return Collection|Order[]
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setUser($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getUser() === $this) {
$order->setUser(null);
}
}
return $this;
}
public function getExtraData(): ?array
{
if (empty($this->extraData)) {
$this->extraData = null;
}
return $this->extraData;
}
public function setExtraData(?array $extraData): User
{
$this->extraData = $extraData;
return $this;
}
/**
* @return Collection|TasDraw[]
*/
public function getTas(): Collection
{
return $this->tas;
}
public function addTas(TasDraw $tas): self
{
if (!$this->tas->contains($tas)) {
$this->tas[] = $tas;
$tas->setUser($this);
}
return $this;
}
public function removeTas(TasDraw $tas): self
{
if ($this->tas->removeElement($tas)) {
// set the owning side to null (unless already changed)
if ($tas->getUser() === $this) {
$tas->setUser(null);
}
}
return $this;
}
/**
* Set deletedAt
*
* @param \DateTime $deletedAt
*
* @return User
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get deletedAt
*
* @return \DateTime
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
public function getImport()
{
return $this->import;
}
public function setImport($bool)
{
$this->import = $bool;
return $this;
}
public function getReferralCode(): ?string
{
return $this->referralCode;
}
public function setReferralCode($referralCode): User
{
$this->referralCode = $referralCode;
return $this;
}
public function createReferralCode()
{
return strtoupper(uniqid($_ENV['APP_PROJET'] . '-'));
}
public function getCompanyName(): ?string
{
return $this->companyName;
}
public function setCompanyName($companyName): User
{
$this->companyName = $companyName;
return $this;
}
public function getSiret(): ?string
{
return $this->siret;
}
public function setSiret($siret): User
{
$this->siret = $siret;
return $this;
}
public function getReferent()
{
return $this->referent;
}
public function setReferent($referent)
{
$this->referent = $referent;
return $this;
}
public function getStrate()
{
return $this->strate;
}
public function setStrate($strate)
{
$this->strate = $strate;
return $this;
}
public function getProfile(): ?Profile
{
return $this->profile;
}
public function setProfile(?Profile $profile): self
{
$this->profile = $profile;
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function getUserIdentifier(): string
{
return (string) $this->email;
}
public function getLastLogin(): ?\DateTimeInterface
{
return $this->lastLogin;
}
public function setLastLogin(?\DateTimeInterface $lastLogin): User
{
$this->lastLogin = $lastLogin;
return $this;
}
public function getAdditionalInformation(): ?array
{
return $this->additionalInformation;
}
public function setAdditionalInformation(?array $additionalInformation): void
{
$this->additionalInformation = $additionalInformation;
}
public function getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
public function setPhoneNumber(?string $phoneNumber): User
{
$this->phoneNumber = $phoneNumber;
return $this;
}
/**
* @return Collection<Carrier>|Carrier[]
*/
public function getCarriers(): Collection
{
return $this->carriers;
}
public function addCarrier(Carrier $carrier): self
{
if (!$this->carriers->contains($carrier)) {
if (count($this->carriers) < self::MAX_CARRIERS_AUTHORIZED) {
$this->carriers[] = $carrier;
$carrier->setUser($this);
} else {
throw new \Exception("You can only have up to 3 additional carriers.");
}
}
return $this;
}
public function removeCarrier(Carrier $carrier): self
{
if ($this->carriers->removeElement($carrier)) {
// set the owning side to null (unless already changed)
if ($carrier->getUser() === $this) {
$carrier->setUser(null);
}
}
return $this;
}
public function getOther(): ?string
{
return $this->other;
}
public function setOther(?string $other): self
{
$this->other = $other;
return $this;
}
public function getKnowledgeResponses(): ?array
{
return $this->knowledgeResponses;
}
public function setKnowledgeResponses(?array $knowledgeResponses): self
{
$this->knowledgeResponses = $knowledgeResponses;
return $this;
}
}