<?php
namespace App\Model\User;
use App\Model\Strate;
use App\Model\User\Address\Delivery;
use App\Model\User\Address\Home;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\SerializedName;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @var string
* @Serializer\Type("string")
* @Serializer\Groups({
* "get_token",
* "get_user",
* "get_user_operation_carts",
* "get_user_gift_carts",
* })
*/
protected $id;
/**
* @var string
* @Serializer\Type("string")
* @Serializer\Groups({
* "get_user",
* "post_email",
* "put_user_general",
* })
* @Assert\NotBlank(groups={"post_user_register"})
* @Assert\Email(groups={"post_user_register"})
*/
private $email;
/**
* @var Identity
* @Serializer\Type(Identity::class)
* @Serializer\Groups({
* "get_user",
* "put_user_general",
* "get_godfather_by_godchild_email",
* })
* @Assert\NotBlank(groups={"post_user_register"})
* @Assert\Valid(groups={"post_user_register"})
*/
private Identity $identity;
/**
* @var array
* @Serializer\Type("array")
* @Serializer\Groups({"get_user"})
*/
private $roles = [];
/**
* @var string The hashed password
* @Serializer\Groups({
* "post_email",
* "put_user_password",
* "get_user"
* })
* @Assert\NotBlank(groups={
* "put_user_password",
* })
* @Serializer\Type("string")
*/
private $password;
/**
* @SerializedName("plainPassword")
* @Assert\NotBlank(groups={
* "post_user_register",
* "put_user_password",
* })
* @Serializer\Groups({
* "put_user_password",
* })
*/
private $plainPassword;
/**
* @var array
* @Serializer\Type("array<App\Model\User\Address\Home>")
* @Serializer\Groups({
* "get_user",
* "post_user_general",
* "put_user_general",
* })
*/
private array $addressesHome = [];
// /**
// * @var array
// * @Serializer\Type("array<App\Model\User\Address\Delivery>")
// * @Serializer\Groups({
// * "get_user",
// * "post_user_delivery",
// * "put_user_delivery",
// * })
// */
// private array $addressesDelivery = [];
/**
* @Serializer\Type("array<App\Model\User\Address\Delivery>")
* @Serializer\Groups({
* "get_user",
* "post_user_register_delivery",
* })
* @Assert\Valid(groups={
* "post_user_register_delivery",
* })
*/
private array $addressesDelivery = [];
/**
* @var bool|null
* @Serializer\Type("boolean")
* @Serializer\Groups({
* "get_user",
* "put_optin_brand",
* })
*/
private $optinBrand;
/**
* @var bool|null
* @Serializer\Type("boolean")
*/
private $optinProcess;
/**
* @var bool|null
* @Serializer\Type("boolean")
* @Serializer\Groups({
* "get_user",
* "put_optin_phone",
* })
*/
private $optinPhone;
/**
* @var bool|null
* @Serializer\Type("boolean")
* @Serializer\Groups({
* "get_user",
* })
*/
private $optinSales;
/**
* @var bool|null
* @Serializer\Type("boolean")
*/
private ?bool $hasAdditionalInformation;
/**
* @var string|null
* @Serializer\Type("string")
* @Serializer\Groups({
* "get_user",
* "post_user_register",
* "put_user_general",
* })
* @Assert\NotBlank(groups={"post_user_register"})
*/
private $companyName;
/**
* @var string|null
* @Serializer\Type("string")
* @Serializer\Groups({
* "get_user",
* "post_user_register",
* "put_user_general",
* })
* @Assert\NotBlank(groups={"post_user_register"})
*/
private $siret;
/**
* @var string|null
* @Serializer\Type("string")
* @Serializer\Groups({
* "get_user",
* "post_user_register",
* })
*/
private $referralCode;
/**
* @var string|null
* @Serializer\Type("string")
*/
private $token;
/**
* @var array
* @Serializer\Type("array<App\Model\User\Iban>")
* @Serializer\Groups({
* "get_user",
* })
*/
private array $ibans = [];
/**
* @var Referent|null
* @Serializer\Type(Referent::class)
* @Serializer\Groups({
* "get_user",
* "get_godfather_by_godchild_email",
* "put_user_referent",
* })
*/
private ?Referent $referent;
/**
* @var Strate|null
* @Serializer\Type(Strate::class)
* @Serializer\Groups({
* "get_user",
* })
*/
private ?Strate $strate;
/**
* @var array
* @Serializer\Type("array")
* @Serializer\Groups({
* "get_user",
* "put_user_wholesaler",
* "post_user_register",
* })
*/
private array $additionalInformation = [];
/**
* @var string|null
* @Serializer\Type("string")
* @Serializer\Groups({
* "get_user",
* "put_user_general",
* })
*/
private $phoneNumber;
public function getId(): ?string
{
return $this->id;
}
/**
* @return array
*/
public function getIbans(): array
{
return $this->ibans;
}
/**
* @param array $ibans
* @return User
*/
public function setIbans(array $ibans): User
{
$this->ibans = $ibans;
return $this;
}
/**
* @return string
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* @param string $email
* @return User
*/
public function setEmail(string $email): User
{
$this->email = $email;
return $this;
}
/**
* @return Identity
*/
public function getIdentity(): Identity
{
return $this->identity;
}
/**
* @param Identity $identity
* @return User
*/
public function setIdentity(Identity $identity): User
{
$this->identity = $identity;
return $this;
}
/**
* @param mixed $addressHome
*/
public function addAddressHome($addressHome)
{
$this->addressesHome[] = $addressHome;
}
/**
* @param mixed $addressHome
*/
public function removeAddressHome(Home $addressHome)
{
if (false !== $key = array_search($addressHome, $this->addressesHome, true)) {
array_splice($this->addressesHome, $key, 1);
}
}
public function getFavAddressHome(): ?array
{
foreach( $this->addressesHome as $key => $addressHome) {
if($key === 'favorite'){
if( $addressHome === true ) {
return $this->addressesHome;
}
}
}
return null;
}
public function setFavAddressHome(Home $addressHome)
{
$this->addAddressHome($addressHome);
}
/**
* @return array
*/
public function getAddressesHome(): array
{
return $this->addressesHome;
}
/**
* @param array $addressesHome
* @return User
*/
public function setAddressesHome(array $addressesHome): User
{
$this->addressesHome = $addressesHome;
return $this;
}
/**
* @see UserInterface
*/
public function getRoles(): ?array
{
$roles = $this->roles;
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
/**
* @param array $roles
*
* @return User
*/
public function setRoles(array $roles): User
{
$this->roles = $roles;
return $this;
}
/**
* @return string
*/
public function getPassword(): ?string
{
return $this->password;
}
/**
* @param string $password
*
* @return User
*/
public function setPassword(string $password): User
{
$this->password = $password;
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;
}
/**
* @return string
*/
public function getToken(): ?string
{
return $this->token;
}
/**
* @param string|null $token
*
* @return User
*/
public function setToken(?string $token): User
{
$this->token = $token;
return $this;
}
public function getSalt(): ?string
{
return null;
}
public function getUsername(): string
{
return $this->email;
}
public function eraseCredentials()
{
return $this->password = null;
}
/**
* @return bool
*/
public function isOptinBrand() : ?bool
{
return $this->optinBrand;
}
/**
* @param bool $optinBrand
*
* @return User
*/
public function setOptinBrand(bool $optinBrand) : User
{
$this->optinBrand = $optinBrand;
return $this;
}
/**
* @return bool
*/
public function isOptinProcess() : ?bool
{
return $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 $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 $this->optinSales;
}
/**
* @param bool $optinSales
*
* @return User
*/
public function setOptinSales(?bool $optinSales) : User
{
$this->optinSales = $optinSales;
return $this;
}
/**
* @param mixed $addressDelivery
*/
public function addAddressDelivery($addressDelivery)
{
$this->addressesDelivery[] = $addressDelivery;
}
/**
* @param mixed $addressDelivery
*/
public function removeAddressDelivery(Delivery $addressDelivery)
{
if (false !== $key = array_search($addressDelivery, $this->addressesDelivery, true)) {
array_splice($this->addressesDelivery, $key, 1);
}
}
public function getFavAddressDelivery(): ?array
{
foreach( $this->addressesDelivery as $key => $addressDelivery) {
if($key === 'favorite'){
if( $addressDelivery === true ) {
return $this->addressesDelivery;
}
}
}
return null;
}
public function setFavAddressDelivery(Delivery $addressDelivery)
{
$this->addAddressDelivery($addressDelivery);
}
public function getAddressesDelivery(): array
{
return $this->addressesDelivery;
}
/**
* @param array $addressesDelivery
* @return User
*/
public function setAddressesDelivery(array $addressesDelivery): User
{
$this->addressesDelivery = $addressesDelivery;
return $this;
}
/**
* @return string
*/
public function getCompanyName(): ?string
{
return $this->companyName;
}
/**
* @param string $companyName
*
* @return User
*/
public function setCompanyName(string $companyName): User
{
$this->companyName = $companyName;
return $this;
}
/**
* @return string
*/
public function getSiret(): ?string
{
return $this->siret;
}
/**
* @param string $siret
*
* @return User
*/
public function setSiret(string $siret): User
{
$this->siret = $siret;
return $this;
}
public function getReferralCode(): ?string
{
return $this->referralCode;
}
/**
* @param string $referralCode
*
* @return User
*/
public function setReferralCode(string $referralCode): User
{
$this->referralCode = $referralCode;
return $this;
}
/**
* @return Referent|null
*/
public function getReferent(): ?Referent
{
return $this->referent;
}
/**
* @param Referent|null $referent
* @return User
*/
public function setReferent(?Referent $referent): User
{
$this->referent = $referent;
return $this;
}
/**
* @return Strate
*/
public function getStrate(): ?Strate
{
return $this->strate;
}
/**
* @param Strate|null $strate
*/
public function setStrate(?Strate $strate): void
{
$this->strate = $strate;
}
public function getHasAdditionalInformation(): ?bool
{
return $this->hasAdditionalInformation;
}
public function setHasAdditionalInformation(?bool $hasAdditionalInformation): void
{
$this->hasAdditionalInformation = $hasAdditionalInformation;
}
public function getAdditionalInformation(): ?array
{
return $this->additionalInformation;
}
public function setAdditionalInformation(?array $additionalInformation): void
{
$this->additionalInformation = $additionalInformation;
}
/**
* The public representation of the user (e.g. a username, an email address, etc.)
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return $this->email;
}
/**
* @return string
*/
public function getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
/**
* @param string $phoneNumber
* @return User
*/
public function setPhoneNumber(string $phoneNumber): User
{
$this->phoneNumber = $phoneNumber;
return $this;
}
}