src/Model/User/User.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Model\User;
  3. use App\Model\Strate;
  4. use App\Model\User\Address\Delivery;
  5. use App\Model\User\Address\Home;
  6. use JMS\Serializer\Annotation as Serializer;
  7. use JMS\Serializer\Annotation\SerializedName;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. class User implements UserInterfacePasswordAuthenticatedUserInterface
  12. {
  13.     /**
  14.      * @var string
  15.      * @Serializer\Type("string")
  16.      * @Serializer\Groups({
  17.      *     "get_token",
  18.      *     "get_user",
  19.      *     "get_user_operation_carts",
  20.      *     "get_user_gift_carts",
  21.      * })
  22.      */
  23.     protected $id;
  24.     /**
  25.      * @var string
  26.      * @Serializer\Type("string")
  27.      * @Serializer\Groups({
  28.      *     "get_user",
  29.      *     "post_email",
  30.      *     "put_user_general",
  31.      * })
  32.      * @Assert\NotBlank(groups={"post_user_register"})
  33.      * @Assert\Email(groups={"post_user_register"})
  34.      */
  35.     private $email;
  36.     /**
  37.      * @var Identity
  38.      * @Serializer\Type(Identity::class)
  39.      * @Serializer\Groups({
  40.      *     "get_user",
  41.      *     "put_user_general",
  42.      *     "get_godfather_by_godchild_email",
  43.      * })
  44.      * @Assert\NotBlank(groups={"post_user_register"})
  45.      * @Assert\Valid(groups={"post_user_register"})
  46.      */
  47.     private Identity $identity;
  48.     /**
  49.      * @var array
  50.      * @Serializer\Type("array")
  51.      * @Serializer\Groups({"get_user"})
  52.      */
  53.     private $roles = [];
  54.     /**
  55.      * @var string The hashed password
  56.      * @Serializer\Groups({
  57.      *     "post_email",
  58.      *     "put_user_password",
  59.      *     "get_user"
  60.      * })
  61.      * @Assert\NotBlank(groups={
  62.      *     "put_user_password",
  63.      * })
  64.      * @Serializer\Type("string")
  65.      */
  66.     private $password;
  67.     /**
  68.      * @SerializedName("plainPassword")
  69.      * @Assert\NotBlank(groups={
  70.      *     "post_user_register",
  71.      *     "put_user_password",
  72.      * })
  73.      * @Serializer\Groups({
  74.      *     "put_user_password",
  75.      * })
  76.      */
  77.     private $plainPassword;
  78.     /**
  79.      * @var array
  80.      * @Serializer\Type("array<App\Model\User\Address\Home>")
  81.      * @Serializer\Groups({
  82.      *     "get_user",
  83.      *     "post_user_general",
  84.      *     "put_user_general",
  85.      * })
  86.      */
  87.     private array $addressesHome = [];
  88. //    /**
  89. //     * @var array
  90. //     * @Serializer\Type("array<App\Model\User\Address\Delivery>")
  91. //     * @Serializer\Groups({
  92. //     *     "get_user",
  93. //     *     "post_user_delivery",
  94. //     *     "put_user_delivery",
  95. //     * })
  96. //     */
  97. //    private array $addressesDelivery = [];
  98.     /**
  99.      * @Serializer\Type("array<App\Model\User\Address\Delivery>")
  100.      * @Serializer\Groups({
  101.      *     "get_user",
  102.      *     "post_user_register_delivery",
  103.      * })
  104.      * @Assert\Valid(groups={
  105.      *     "post_user_register_delivery",
  106.      * })
  107.      */
  108.     private array $addressesDelivery = [];
  109.     /**
  110.      * @var bool|null
  111.      * @Serializer\Type("boolean")
  112.      * @Serializer\Groups({
  113.      *     "get_user",
  114.      *     "put_optin_brand",
  115.      * })
  116.      */
  117.     private $optinBrand;
  118.     /**
  119.      * @var bool|null
  120.      * @Serializer\Type("boolean")
  121.      */
  122.     private $optinProcess;
  123.     /**
  124.      * @var bool|null
  125.      * @Serializer\Type("boolean")
  126.      * @Serializer\Groups({
  127.      *     "get_user",
  128.      *     "put_optin_phone",
  129.      * })
  130.      */
  131.     private $optinPhone;
  132.     /**
  133.      * @var bool|null
  134.      * @Serializer\Type("boolean")
  135.      * @Serializer\Groups({
  136.      *     "get_user",
  137.      * })
  138.      */
  139.     private $optinSales;
  140.     /**
  141.      * @var bool|null
  142.      * @Serializer\Type("boolean")
  143.      */
  144.     private ?bool $hasAdditionalInformation;
  145.     /**
  146.      * @var string|null
  147.      * @Serializer\Type("string")
  148.      * @Serializer\Groups({
  149.      *     "get_user",
  150.      *     "post_user_register",
  151.      *     "put_user_general",
  152.      * })
  153.      * @Assert\NotBlank(groups={"post_user_register"})
  154.      */
  155.     private $companyName;
  156.     /**
  157.      * @var string|null
  158.      * @Serializer\Type("string")
  159.      * @Serializer\Groups({
  160.      *     "get_user",
  161.      *     "post_user_register",
  162.      *     "put_user_general",
  163.      * })
  164.      * @Assert\NotBlank(groups={"post_user_register"})
  165.      */
  166.     private $siret;
  167.     /**
  168.      * @var string|null
  169.      * @Serializer\Type("string")
  170.      * @Serializer\Groups({
  171.      *     "get_user",
  172.      *     "post_user_register",
  173.      * })
  174.      */
  175.     private $referralCode;
  176.     /**
  177.      * @var string|null
  178.      * @Serializer\Type("string")
  179.      */
  180.     private $token;
  181.     /**
  182.      * @var array
  183.      * @Serializer\Type("array<App\Model\User\Iban>")
  184.      * @Serializer\Groups({
  185.      *     "get_user",
  186.      * })
  187.      */
  188.     private array $ibans = [];
  189.     /**
  190.      * @var Referent|null
  191.      * @Serializer\Type(Referent::class)
  192.      * @Serializer\Groups({
  193.      *     "get_user",
  194.      *     "get_godfather_by_godchild_email",
  195.      *     "put_user_referent",
  196.      * })
  197.      */
  198.     private ?Referent $referent;
  199.     /**
  200.      * @var Strate|null
  201.      * @Serializer\Type(Strate::class)
  202.      * @Serializer\Groups({
  203.      *     "get_user",
  204.      * })
  205.      */
  206.     private ?Strate $strate;
  207.     /**
  208.      * @var array
  209.      * @Serializer\Type("array")
  210.      * @Serializer\Groups({
  211.      *     "get_user",
  212.      *     "put_user_wholesaler",
  213.      *     "post_user_register",
  214.      * })
  215.      */
  216.     private array $additionalInformation = [];
  217.     /**
  218.      * @var string|null
  219.      * @Serializer\Type("string")
  220.      * @Serializer\Groups({
  221.      *     "get_user",
  222.      *     "put_user_general",
  223.      * })
  224.      */
  225.     private $phoneNumber;
  226.     /**
  227.      * @SerializedName("createdAt")
  228.      * @Serializer\Groups({"get_user"})
  229.      * @Serializer\Type("DateTime<'Y-m-d\TH:i:sP'>")
  230.      */
  231.     private ?\DateTimeInterface $createdAt null;
  232.     public function getId(): ?string
  233.     {
  234.         return $this->id;
  235.     }
  236.     /**
  237.      * @return array
  238.      */
  239.     public function getIbans(): array
  240.     {
  241.         return $this->ibans;
  242.     }
  243.     /**
  244.      * @param array $ibans
  245.      * @return User
  246.      */
  247.     public function setIbans(array $ibans): User
  248.     {
  249.         $this->ibans $ibans;
  250.         return $this;
  251.     }
  252.     /**
  253.      * @return string
  254.      */
  255.     public function getEmail(): ?string
  256.     {
  257.         return $this->email;
  258.     }
  259.     /**
  260.      * @param string $email
  261.      * @return User
  262.      */
  263.     public function setEmail(string $email): User
  264.     {
  265.         $this->email $email;
  266.         return $this;
  267.     }
  268.     /**
  269.      * @return Identity
  270.      */
  271.     public function getIdentity(): Identity
  272.     {
  273.         return $this->identity;
  274.     }
  275.     /**
  276.      * @param Identity $identity
  277.      * @return User
  278.      */
  279.     public function setIdentity(Identity $identity): User
  280.     {
  281.         $this->identity $identity;
  282.         return $this;
  283.     }
  284.     /**
  285.      * @param mixed $addressHome
  286.      */
  287.     public function addAddressHome($addressHome)
  288.     {
  289.         $this->addressesHome[] = $addressHome;
  290.     }
  291.     /**
  292.      * @param mixed $addressHome
  293.      */
  294.     public function removeAddressHome(Home $addressHome)
  295.     {
  296.         if (false !== $key array_search($addressHome$this->addressesHometrue)) {
  297.             array_splice($this->addressesHome$key1);
  298.         }
  299.     }
  300.     public function getFavAddressHome(): ?array
  301.     {
  302.         foreach( $this->addressesHome as $key => $addressHome) {
  303.             if($key === 'favorite'){
  304.                 if( $addressHome === true ) {
  305.                     return $this->addressesHome;
  306.                 }
  307.             }
  308.         }
  309.         return null;
  310.     }
  311.     public function setFavAddressHome(Home $addressHome)
  312.     {
  313.         $this->addAddressHome($addressHome);
  314.     }
  315.     /**
  316.      * @return array
  317.      */
  318.     public function getAddressesHome(): array
  319.     {
  320.         return $this->addressesHome;
  321.     }
  322.     /**
  323.      * @param array $addressesHome
  324.      * @return User
  325.      */
  326.     public function setAddressesHome(array $addressesHome): User
  327.     {
  328.         $this->addressesHome $addressesHome;
  329.         return $this;
  330.     }
  331.     /**
  332.      * @see UserInterface
  333.      */
  334.     public function getRoles(): ?array
  335.     {
  336.         $roles $this->roles;
  337.         $roles[] = 'ROLE_USER';
  338.         return array_unique($roles);
  339.     }
  340.     /**
  341.      * @param array $roles
  342.      *
  343.      * @return User
  344.      */
  345.     public function setRoles(array $roles): User
  346.     {
  347.         $this->roles $roles;
  348.         return $this;
  349.     }
  350.     /**
  351.      * @return string
  352.      */
  353.     public function getPassword(): ?string
  354.     {
  355.         return $this->password;
  356.     }
  357.     /**
  358.      * @param string $password
  359.      *
  360.      * @return User
  361.      */
  362.     public function setPassword(string $password): User
  363.     {
  364.         $this->password $password;
  365.         return $this;
  366.     }
  367.     /**
  368.      * @return string|null
  369.      */
  370.     public function getPlainPassword(): ?string
  371.     {
  372.         return $this->plainPassword;
  373.     }
  374.     /**
  375.      * @param string|null $plainPassword
  376.      * @return User
  377.      */
  378.     public function setPlainPassword(?string $plainPassword): User
  379.     {
  380.         $this->plainPassword $plainPassword;
  381.         return $this;
  382.     }
  383.     /**
  384.      * @return string
  385.      */
  386.     public function getToken(): ?string
  387.     {
  388.         return $this->token;
  389.     }
  390.     /**
  391.      * @param string|null $token
  392.      *
  393.      * @return User
  394.      */
  395.     public function setToken(?string $token): User
  396.     {
  397.         $this->token $token;
  398.         return $this;
  399.     }
  400.     public function getSalt(): ?string
  401.     {
  402.         return null;
  403.     }
  404.     public function getUsername(): string
  405.     {
  406.         return $this->email;
  407.     }
  408.     public function eraseCredentials()
  409.     {
  410.         return $this->password null;
  411.     }
  412.     /**
  413.      * @return bool
  414.      */
  415.     public function isOptinBrand() : ?bool
  416.     {
  417.         return $this->optinBrand;
  418.     }
  419.     /**
  420.      * @param bool $optinBrand
  421.      *
  422.      * @return User
  423.      */
  424.     public function setOptinBrand(bool $optinBrand) : User
  425.     {
  426.         $this->optinBrand $optinBrand;
  427.         return $this;
  428.     }
  429.     /**
  430.      * @return bool
  431.      */
  432.     public function isOptinProcess() : ?bool
  433.     {
  434.         return $this->optinProcess;
  435.     }
  436.     /**
  437.      * @param bool $optinProcess
  438.      *
  439.      * @return User
  440.      */
  441.     public function setOptinProcess(bool $optinProcess) : User
  442.     {
  443.         $this->optinProcess $optinProcess;
  444.         return $this;
  445.     }
  446.     /**
  447.      * @return bool
  448.      */
  449.     public function isOptinPhone() : ?bool
  450.     {
  451.         return $this->optinPhone;
  452.     }
  453.     /**
  454.      * @param bool $optinPhone
  455.      *
  456.      * @return User
  457.      */
  458.     public function setOptinPhone(bool $optinPhone) : User
  459.     {
  460.         $this->optinPhone $optinPhone;
  461.         return $this;
  462.     }
  463.     /**
  464.      * @return bool
  465.      */
  466.     public function isOptinSales() : ?bool
  467.     {
  468.         return $this->optinSales;
  469.     }
  470.     /**
  471.      * @param bool $optinSales
  472.      *
  473.      * @return User
  474.      */
  475.     public function setOptinSales(?bool $optinSales) : User
  476.     {
  477.         $this->optinSales $optinSales;
  478.         return $this;
  479.     }
  480.     /**
  481.      * @param mixed $addressDelivery
  482.      */
  483.     public function addAddressDelivery($addressDelivery)
  484.     {
  485.         $this->addressesDelivery[] = $addressDelivery;
  486.     }
  487.     /**
  488.      * @param mixed $addressDelivery
  489.      */
  490.     public function removeAddressDelivery(Delivery $addressDelivery)
  491.     {
  492.         if (false !== $key array_search($addressDelivery$this->addressesDeliverytrue)) {
  493.             array_splice($this->addressesDelivery$key1);
  494.         }
  495.     }
  496.     public function getFavAddressDelivery(): ?array
  497.     {
  498.         foreach( $this->addressesDelivery as $key => $addressDelivery) {
  499.             if($key === 'favorite'){
  500.                 if( $addressDelivery === true ) {
  501.                     return $this->addressesDelivery;
  502.                 }
  503.             }
  504.         }
  505.         return null;
  506.     }
  507.     public function setFavAddressDelivery(Delivery $addressDelivery)
  508.     {
  509.         $this->addAddressDelivery($addressDelivery);
  510.     }
  511.     public function getAddressesDelivery(): array
  512.     {
  513.         return $this->addressesDelivery;
  514.     }
  515.     /**
  516.      * @param array $addressesDelivery
  517.      * @return User
  518.      */
  519.     public function setAddressesDelivery(array $addressesDelivery): User
  520.     {
  521.         $this->addressesDelivery $addressesDelivery;
  522.         return $this;
  523.     }
  524.     /**
  525.      * @return string
  526.      */
  527.     public function getCompanyName(): ?string
  528.     {
  529.         return $this->companyName;
  530.     }
  531.     /**
  532.      * @param string $companyName
  533.      *
  534.      * @return User
  535.      */
  536.     public function setCompanyName(string $companyName): User
  537.     {
  538.         $this->companyName $companyName;
  539.         return $this;
  540.     }
  541.     /**
  542.      * @return string
  543.      */
  544.     public function getSiret(): ?string
  545.     {
  546.         return $this->siret;
  547.     }
  548.     /**
  549.      * @param string $siret
  550.      *
  551.      * @return User
  552.      */
  553.     public function setSiret(string $siret): User
  554.     {
  555.         $this->siret $siret;
  556.         return $this;
  557.     }
  558.     public function getReferralCode(): ?string
  559.     {
  560.         return $this->referralCode;
  561.     }
  562.     /**
  563.      * @param string $referralCode
  564.      *
  565.      * @return User
  566.      */
  567.     public function setReferralCode(string $referralCode): User
  568.     {
  569.         $this->referralCode $referralCode;
  570.         return $this;
  571.     }
  572.     /**
  573.      * @return Referent|null
  574.      */
  575.     public function getReferent(): ?Referent
  576.     {
  577.         return $this->referent;
  578.     }
  579.     /**
  580.      * @param Referent|null $referent
  581.      * @return User
  582.      */
  583.     public function setReferent(?Referent $referent): User
  584.     {
  585.         $this->referent $referent;
  586.         return $this;
  587.     }
  588.     /**
  589.      * @return Strate
  590.      */
  591.     public function getStrate(): ?Strate
  592.     {
  593.         return $this->strate;
  594.     }
  595.     /**
  596.      * @param Strate|null $strate
  597.      */
  598.     public function setStrate(?Strate $strate): void
  599.     {
  600.         $this->strate $strate;
  601.     }
  602.     public function getHasAdditionalInformation(): ?bool
  603.     {
  604.         return $this->hasAdditionalInformation;
  605.     }
  606.     public function setHasAdditionalInformation(?bool $hasAdditionalInformation): void
  607.     {
  608.         $this->hasAdditionalInformation $hasAdditionalInformation;
  609.     }
  610.     public function getAdditionalInformation(): ?array
  611.     {
  612.         return $this->additionalInformation;
  613.     }
  614.     public function setAdditionalInformation(?array $additionalInformation): void
  615.     {
  616.         $this->additionalInformation $additionalInformation;
  617.     }
  618.     /**
  619.      * The public representation of the user (e.g. a username, an email address, etc.)
  620.      *
  621.      * @see UserInterface
  622.      */
  623.     public function getUserIdentifier(): string
  624.     {
  625.         return $this->email;
  626.     }
  627.     /**
  628.      * @return string
  629.      */
  630.     public function getPhoneNumber(): ?string
  631.     {
  632.         return $this->phoneNumber;
  633.     }
  634.     /**
  635.      * @param string $phoneNumber
  636.      * @return User
  637.      */
  638.     public function setPhoneNumber(string $phoneNumber): User
  639.     {
  640.         $this->phoneNumber $phoneNumber;
  641.         return $this;
  642.     }
  643.     public function getCreatedAt(): ?\DateTimeInterface
  644.     {
  645.         return $this->createdAt;
  646.     }
  647.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  648.     {
  649.         $this->createdAt $createdAt;
  650.         return $this;
  651.     }
  652. }