src/RegisterBundle/Entity/Registration.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\RegisterBundle\Entity;
  3. use App\Classes\Hasher;
  4. use App\Entity\Invoice;
  5. use App\RegisterBundle\Model;
  6. use App\RegisterBundle\Validator\Constraints as AppAssert;
  7. use DateTime;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Exception;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * Class Registration
  15.  * @package App\RegisterBundle\Entity
  16.  * @ORM\Entity(repositoryClass="App\RegisterBundle\Repository\RegistrationRepository")
  17.  * @ORM\Table(name="malys_registration")
  18.  * @ORM\HasLifecycleCallbacks()
  19.  * @UniqueEntity("hashedId")
  20.  */
  21. class Registration
  22. {
  23.     /**
  24.      * @var integer
  25.      *
  26.      * @ORM\Column(name="id", type="integer")
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue(strategy="AUTO")
  29.      */
  30.     protected $id;
  31.     /**
  32.      * @ORM\Column(name="hashed_id", type="string", nullable=false)
  33.      */
  34.     protected $hashedId;
  35.     /**
  36.      * @var DateTime
  37.      *
  38.      * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  39.      */
  40.     protected $createdAt;
  41.     /**
  42.      * @var DateTime
  43.      *
  44.      * @ORM\Column(name="updatedAt", type="datetime", nullable=true)
  45.      */
  46.     protected $updatedAt;
  47.     /**
  48.      * @var DateTime
  49.      *
  50.      * @ORM\Column(name="completedAt", type="datetime", nullable=true)
  51.      */
  52.     protected $completedAt;
  53.     /**
  54.      * @var string
  55.      *
  56.      * @ORM\Column(name="current_step", type="string", nullable=false)
  57.      * @Assert\Choice (callback={"RegisterBundle\Model\Registration", "getAvailableSteps"})
  58.      * @Assert\NotBlank(groups={"finish"})
  59.      */
  60.     protected $currentStep;
  61.     /**
  62.      * @var string
  63.      *
  64.      * @ORM\Column(name="user_email", type="string", nullable=true)
  65.      * @Assert\Email (groups={"user", "finish"})
  66.      * @Assert\NotBlank (groups={"user", "finish"})
  67.      * @AppAssert\EmailAlreadyUsed(groups={"user", "finish"})
  68.      */
  69.     protected $userEmail;
  70.     /**
  71.      * @var string
  72.      *
  73.      * @ORM\Column(name="user_hashed_password", type="string", nullable=true)
  74.      */
  75.     protected $userHashedPassword;
  76.     /**
  77.      * @Assert\NotBlank (groups={"user"})
  78.      * @Assert\Length (min=8, minMessage="Votre mot de passe doit contenir au moins {{ limit }} caractères", groups={"user"})
  79.      */
  80.     protected $userPlainPassword;
  81.     /**
  82.      * @var string
  83.      *
  84.      * @ORM\Column(name="user_first_name", type="string", nullable=true)
  85.      * @Assert\NotBlank (groups={"user", "finish"})
  86.      */
  87.     protected $userFirstName;
  88.     /**
  89.      * @var string
  90.      *
  91.      * @ORM\Column(name="user_last_name", type="string", nullable=true)
  92.      * @Assert\NotBlank (groups={"user", "finish"})
  93.      */
  94.     protected $userLastName;
  95.     /**
  96.      * @var string
  97.      *
  98.      * @ORM\Column(name="shop_brand_name", type="string", nullable=true)
  99.      * @Assert\NotBlank (groups={"shop", "finish"})
  100.      */
  101.     protected $shopBrandName;
  102.     /**
  103.      * @var string
  104.      *
  105.      * @ORM\Column(name="shop_company_name", type="string", nullable=true)
  106.      * @Assert\NotBlank (groups={"shop", "finish"})
  107.      */
  108.     protected $shopCompanyName;
  109.     /**
  110.      * @var string
  111.      *
  112.      * @ORM\Column(name="shop_address", type="string", nullable=true)
  113.      * @Assert\NotBlank (groups={"shop", "finish"})
  114.      */
  115.     protected $shopAddress;
  116.     /**
  117.      * @var string
  118.      *
  119.      * @ORM\Column(name="shop_zipcode", type="string", nullable=true)
  120.      * @Assert\NotBlank (groups={"shop", "finish"})
  121.      */
  122.     protected $shopZipcode;
  123.     /**
  124.      * @var string
  125.      *
  126.      * @ORM\Column(name="shop_city", type="string", nullable=true)
  127.      * @Assert\NotBlank (groups={"shop", "finish"})
  128.      */
  129.     protected $shopCity;
  130.     /**
  131.      * @var string
  132.      *
  133.      * @ORM\Column(name="shop_country", type="string", nullable=true)
  134.      * @Assert\NotBlank (groups={"shop", "finish"})
  135.      */
  136.     protected $shopCountry;
  137.     /**
  138.      * @var string
  139.      *
  140.      * @ORM\Column(name="shop_suppliers", type="json", nullable=true)
  141.      * @AppAssert\RegistrationSuppliers(groups={"suppliers", "finish"})
  142.      */
  143.     protected $shopSuppliers;
  144.     /**
  145.      * @ORM\ManyToMany (targetEntity="App\Entity\Invoice", cascade={"persist"})
  146.      * @ORM\JoinTable (name="malys_registration_invoice")
  147.      * @Assert\Valid (groups={"invoices", "finish"})
  148.      */
  149.     protected $invoices;
  150.     /**
  151.      * @var string
  152.      *
  153.      * @ORM\Column(name="fcm_device_id", type="string", nullable=true)
  154.      */
  155.     protected $fcmDeviceId;
  156.     /**
  157.      * @var integer
  158.      *
  159.      * @ORM\Column(name="validation_code", type="string", nullable=false)
  160.      */
  161.     protected $validationCode;
  162.     /**
  163.      * @var string
  164.      *
  165.      * @ORM\Column(name="verified_email", type="string", nullable=true)
  166.      */
  167.     protected $verifiedEmail;
  168.     /**
  169.      * @var DateTime
  170.      *
  171.      * @ORM\Column(name="lastEmailSentAt", type="datetime", nullable=true)
  172.      */
  173.     protected $lastEmailSentAt;
  174.     public function __toString()
  175.     {
  176.         return $this->shopBrandName $this->shopBrandName '';
  177.     }
  178.     public function __construct()
  179.     {
  180.         $this->currentStep Model\Registration::getDefaultStep();
  181.         $this->invoices    = new ArrayCollection();
  182.     }
  183.     /**
  184.      * @return int
  185.      */
  186.     public function getId(): int
  187.     {
  188.         return $this->id;
  189.     }
  190.     /**
  191.      * @return DateTime
  192.      */
  193.     public function getCreatedAt(): DateTime
  194.     {
  195.         return $this->createdAt;
  196.     }
  197.     /**
  198.      * @param DateTime $createdAt
  199.      *
  200.      * @ORM\PrePersist
  201.      */
  202.     public function setCreatedAt(): void
  203.     {
  204.         $this->createdAt = new DateTime();
  205.         $this->updatedAt = new DateTime();
  206.     }
  207.     /**
  208.      * @return DateTime
  209.      */
  210.     public function getUpdatedAt(): DateTime
  211.     {
  212.         return $this->updatedAt;
  213.     }
  214.     /**
  215.      * Set updatedAt
  216.      *
  217.      * @ORM\PreUpdate
  218.      * @throws Exception
  219.      */
  220.     public function setUpdatedAt()
  221.     {
  222.         $this->updatedAt = new DateTime();
  223.     }
  224.     /**
  225.      * @return DateTime
  226.      */
  227.     public function getCompletedAt(): ?DateTime
  228.     {
  229.         return $this->completedAt;
  230.     }
  231.     /**
  232.      * @param DateTime $completedAt
  233.      */
  234.     public function setCompletedAt(DateTime $completedAt): void
  235.     {
  236.         $this->completedAt $completedAt;
  237.     }
  238.     /**
  239.      * @return string
  240.      */
  241.     public function getCurrentStep(): string
  242.     {
  243.         return $this->currentStep;
  244.     }
  245.     /**
  246.      * @param string $currentStep
  247.      */
  248.     public function setCurrentStep(string $currentStep): void
  249.     {
  250.         $this->currentStep $currentStep;
  251.     }
  252.     /**
  253.      * @return string
  254.      */
  255.     public function getUserEmail(): ?string
  256.     {
  257.         return $this->userEmail;
  258.     }
  259.     /**
  260.      * @param string $userEmail
  261.      */
  262.     public function setUserEmail(?string $userEmail): void
  263.     {
  264.         $this->userEmail $userEmail;
  265.     }
  266.     /**
  267.      * @return string
  268.      */
  269.     public function getUserHashedPassword(): ?string
  270.     {
  271.         return $this->userHashedPassword;
  272.     }
  273.     /**
  274.      * @param string $userHashedPassword
  275.      */
  276.     public function setUserHashedPassword(string $userHashedPassword): void
  277.     {
  278.         $this->userHashedPassword $userHashedPassword;
  279.     }
  280.     /**
  281.      * @return string
  282.      */
  283.     public function getUserFirstName(): ?string
  284.     {
  285.         return $this->userFirstName;
  286.     }
  287.     /**
  288.      * @param string $userFirstName
  289.      */
  290.     public function setUserFirstName(?string $userFirstName): void
  291.     {
  292.         $this->userFirstName $userFirstName;
  293.     }
  294.     /**
  295.      * @return string
  296.      */
  297.     public function getUserLastName(): ?string
  298.     {
  299.         return $this->userLastName;
  300.     }
  301.     /**
  302.      * @param string $userLastName
  303.      */
  304.     public function setUserLastName(?string $userLastName): void
  305.     {
  306.         $this->userLastName $userLastName;
  307.     }
  308.     /**
  309.      * @return string
  310.      */
  311.     public function getShopBrandName(): ?string
  312.     {
  313.         return $this->shopBrandName;
  314.     }
  315.     /**
  316.      * @param string $shopBrandName
  317.      */
  318.     public function setShopBrandName(string $shopBrandName): void
  319.     {
  320.         $this->shopBrandName $shopBrandName;
  321.     }
  322.     /**
  323.      * @return string
  324.      */
  325.     public function getShopCompanyName(): ?string
  326.     {
  327.         return $this->shopCompanyName;
  328.     }
  329.     /**
  330.      * @param string $shopCompanyName
  331.      */
  332.     public function setShopCompanyName(string $shopCompanyName): void
  333.     {
  334.         $this->shopCompanyName $shopCompanyName;
  335.     }
  336.     /**
  337.      * @return string
  338.      */
  339.     public function getShopAddress(): ?string
  340.     {
  341.         return $this->shopAddress;
  342.     }
  343.     /**
  344.      * @param string $shopAddress
  345.      */
  346.     public function setShopAddress(string $shopAddress): void
  347.     {
  348.         $this->shopAddress $shopAddress;
  349.     }
  350.     /**
  351.      * @return string
  352.      */
  353.     public function getShopZipcode(): ?string
  354.     {
  355.         return $this->shopZipcode;
  356.     }
  357.     /**
  358.      * @param string $shopZipcode
  359.      */
  360.     public function setShopZipcode(string $shopZipcode): void
  361.     {
  362.         $this->shopZipcode $shopZipcode;
  363.     }
  364.     /**
  365.      * @return string
  366.      */
  367.     public function getShopCity(): ?string
  368.     {
  369.         return $this->shopCity;
  370.     }
  371.     /**
  372.      * @param string $shopCity
  373.      */
  374.     public function setShopCity(string $shopCity): void
  375.     {
  376.         $this->shopCity $shopCity;
  377.     }
  378.     /**
  379.      * @return string
  380.      */
  381.     public function getShopCountry(): ?string
  382.     {
  383.         return $this->shopCountry;
  384.     }
  385.     /**
  386.      * @param string $shopCountry
  387.      */
  388.     public function setShopCountry(string $shopCountry): void
  389.     {
  390.         $this->shopCountry $shopCountry;
  391.     }
  392.     /**
  393.      * @return string
  394.      */
  395.     public function getShopSuppliers()
  396.     {
  397.         return $this->shopSuppliers;
  398.     }
  399.     /**
  400.      * @param string $shopSuppliers
  401.      */
  402.     public function setShopSuppliers(array $shopSuppliers): void
  403.     {
  404.         $this->shopSuppliers $shopSuppliers;
  405.     }
  406.     /**
  407.      * @ORM\PrePersist
  408.      */
  409.     public function installHashedId()
  410.     {
  411.         if (is_null($this->hashedId)) {
  412.             $this->hashedId Hasher::generateHash(self::class);
  413.         }
  414.     }
  415.     /**
  416.      * @return mixed
  417.      */
  418.     public function getHashedId(): string
  419.     {
  420.         return $this->hashedId;
  421.     }
  422.     /**
  423.      * @param mixed $hashedId
  424.      */
  425.     public function setHashedId($hashedId): void
  426.     {
  427.         $this->hashedId $hashedId;
  428.     }
  429.     /**
  430.      * @return mixed
  431.      */
  432.     public function getUserPlainPassword(): ?string
  433.     {
  434.         return $this->userPlainPassword;
  435.     }
  436.     /**
  437.      * @param mixed $userPlainPassword
  438.      */
  439.     public function setUserPlainPassword(?string $userPlainPassword): void
  440.     {
  441.         $this->userPlainPassword $userPlainPassword;
  442.     }
  443.     /**
  444.      * @return ArrayCollection
  445.      */
  446.     public function getInvoices()
  447.     {
  448.         return $this->invoices;
  449.     }
  450.     /**
  451.      * @param ArrayCollection $invoices
  452.      */
  453.     public function setInvoices(ArrayCollection $invoices): void
  454.     {
  455.         $this->invoices $invoices;
  456.     }
  457.     public function addInvoice(Invoice $invoice)
  458.     {
  459.         if (! $this->invoices->contains($invoice)) {
  460.             $this->invoices->add($invoice);
  461.         }
  462.     }
  463.     public function removeInvoice(Invoice $invoice)
  464.     {
  465.         if ($this->invoices->contains($invoice)) {
  466.             $this->invoices->removeElement($invoice);
  467.         }
  468.     }
  469.     /**
  470.      * @return string
  471.      */
  472.     public function getFcmDeviceId(): ?string
  473.     {
  474.         return $this->fcmDeviceId;
  475.     }
  476.     /**
  477.      * @param string|null $fcmDeviceId
  478.      */
  479.     public function setFcmDeviceId(?string $fcmDeviceId): void
  480.     {
  481.         $this->fcmDeviceId $fcmDeviceId;
  482.     }
  483.     /**
  484.      * @return int
  485.      */
  486.     public function getValidationCode(): int
  487.     {
  488.         return $this->validationCode;
  489.     }
  490.     /**
  491.      * @param string|null $validationCode
  492.      */
  493.     public function setValidationCode(?string $validationCode null)
  494.     {
  495.         $this->validationCode $validationCode;
  496.     }
  497.     /**
  498.      * @return string
  499.      */
  500.     public function getVerifiedEmail(): ?string
  501.     {
  502.         return $this->verifiedEmail;
  503.     }
  504.     /**
  505.      * @param $verifiedEmail
  506.      */
  507.     public function setVerifiedEmail($verifiedEmail)
  508.     {
  509.         $this->verifiedEmail $verifiedEmail;
  510.     }
  511.     /**
  512.      * @return DateTime
  513.      */
  514.     public function getLastEmailSentAt(): ?DateTime
  515.     {
  516.         return $this->lastEmailSentAt;
  517.     }
  518.     /**
  519.      * @param $lastEmailSentAt
  520.      */
  521.     public function setLastEmailSentAt($lastEmailSentAt)
  522.     {
  523.         $this->lastEmailSentAt $lastEmailSentAt;
  524.     }
  525. }