src/V4/Model/Customer/Customer.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\V4\Model\Customer;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Enum\LanguageEnum;
  6. use App\Model\CustomerFile\CustomerFile;
  7. use App\Model\IriNormalizableInterface;
  8. use App\Model\Module\Module;
  9. use App\Model\NormalizeAsIRITrait;
  10. use App\Model\Security\UserInfo;
  11. use App\Model\Traits\ImportableObjectTrait;
  12. use App\V4\Model\CustomerFileAwareInterface;
  13. use App\V4\Model\OutlookSubscriptionConfiguration\OutlookSubscriptionConfiguration;
  14. use DateTime;
  15. use Doctrine\Common\Collections\ArrayCollection;
  16. use Doctrine\Common\Collections\Collection;
  17. use Symfony\Component\Serializer\Annotation\Groups;
  18. use Symfony\Component\Validator\Constraints as Assert;
  19. /**
  20.  * @ApiResource(
  21.  *     shortName="V4/Customer",
  22.  *     collectionOperations={
  23.  *         "get_deleted": {
  24.  *             "method": "GET",
  25.  *             "path": "/V4/customers/deleted-customers",
  26.  *             "controller": "App\V4\Action\Customer\GetDeletedCustomersAction",
  27.  *         }
  28.  *     },
  29.  *     itemOperations={
  30.  *         "restore": {
  31.  *             "input": false,
  32.  *             "method": "POST",
  33.  *             "path": "/V4/customers/{id}/restore",
  34.  *             "controller": "App\V4\Action\Customer\RestoreCustomerAction",
  35.  *         }
  36.  *     }
  37.  * )
  38.  */
  39. class Customer implements IriNormalizableInterfaceCustomerFileAwareInterface
  40. {
  41.     public const AIRNOV_CUSTOMER_ID 'customer_124';
  42.     public const ECORING_CUSTOMER_ID '37f0fc4421cf42aead0a654e3b6e7f1d';
  43.     public const JHOOD_CUSTOMER_ID '0662705af65c48908b017d8fb0724bac';
  44.     public const PLENETUDE_CUSTOMER_ID 'e8919dbc01f34f79ab22b9c434f114eb';
  45.     use ImportableObjectTrait;
  46.     use NormalizeAsIRITrait;
  47.     /**
  48.      * @ApiProperty(identifier=true)
  49.      *
  50.      * @var string|null
  51.      * @Groups({
  52.      *     "read", "list", "write", "section:list", "section:read",
  53.      *     "outlook_subscription_configuration:list", "outlook_subscription_configuration:read", "outlook_subscription_configuration:write", "outlook_subscription_configuration:update"
  54.      * })
  55.      */
  56.     private $id;
  57.     /**
  58.      * @var string|null
  59.      * @Assert\NotBlank(message="Le nom de l'entreprise est obligatoire")
  60.      * @Groups({
  61.      *
  62.      *     "read", "list", "write"
  63.      * })
  64.      */
  65.     private $name;
  66.     /**
  67.      * @var DateTime|null
  68.      * @Groups({"read", "list", "write"})
  69.      */
  70.     private $expiredAt;
  71.     /**
  72.      * @var bool|null
  73.      * @Groups({"read", "list", "write"})
  74.      */
  75.     private $isActive true;
  76.     /**
  77.      * @var bool|null
  78.      * @Groups({"read", "list", "write"})
  79.      */
  80.     private $isLiveo false;
  81.     /**
  82.      * @var bool|null
  83.      * @Groups({"read", "list", "write"})
  84.      */
  85.     private $hasIntranet false;
  86.     /**
  87.      * @var string|null
  88.      * @Groups({"read", "list", "write"})
  89.      */
  90.     private $phone;
  91.     /**
  92.      * @var string|null
  93.      * @Groups({"read", "list", "write"})
  94.      */
  95.     private $fax;
  96.     /**
  97.      * @var int|null
  98.      * @Groups({"read"})
  99.      */
  100.     private $activeUsersNumber;
  101.     /**
  102.      * @var string|null
  103.      * @Groups({"read", "list", "write"})
  104.      */
  105.     private $email;
  106.     /**
  107.      * @var string|null
  108.      * @Groups({"read", "list", "write"})
  109.      */
  110.     private $website;
  111.     /**
  112.      * @var string|null
  113.      * @Groups({"read", "list", "write"})
  114.      */
  115.     private $address;
  116.     /**
  117.      * @var string|null
  118.      * @Groups({"read", "list", "write"})
  119.      */
  120.     private $postalCode;
  121.     /**
  122.      * @var string|null
  123.      * @Groups({"read", "list", "write"})
  124.      */
  125.     private $city;
  126.     /**
  127.      * @var float|null
  128.      */
  129.     private $lat;
  130.     /**
  131.      * @var float|null
  132.      */
  133.     private $lng;
  134.     /**
  135.      * @var bool|null
  136.      */
  137.     private $isGeolocated false;
  138.     /**
  139.      * @var string|null
  140.      * @Groups({"read", "list", "write"})
  141.      */
  142.     private $externalId;
  143.     /**
  144.      * @var string|null
  145.      * @Groups({"read", "list", "write"})
  146.      */
  147.     private $mailingId;
  148.     /**
  149.      * @var string|null
  150.      * @Groups({"read", "list"})
  151.      */
  152.     private $logoUrl;
  153.     /**
  154.      * @var int|null
  155.      * @Groups({"read", "list", "write"})
  156.      */
  157.     private $licenseNumber;
  158.     /**
  159.      * @var DateTime|null
  160.      * @Groups({"read", "list", "write"})
  161.      */
  162.     private $buyingAt;
  163.     /**
  164.      * @var UserInfo[]|Collection
  165.      * @Groups({"read", "list"})
  166.      */
  167.     private $users;
  168.     /**
  169.      * @var CustomerFile[]|Collection
  170.      * @Groups({"read", "list"})
  171.      */
  172.     private $customerFiles;
  173.     /**
  174.      * @var string
  175.      * @Groups({"read", "list", "write"})
  176.      */
  177.     private $language LanguageEnum::LANGUAGE_FRENCH;
  178.     /**
  179.      * @var Module[]|Collection
  180.      * @Groups({"customer:write:modules"})
  181.      */
  182.     private $modules;
  183.     /**
  184.      * @var string
  185.      * @Groups({"read", "list", "write"})
  186.      */
  187.     private $alternativeTranslations;
  188.     /**
  189.      * @var string|null
  190.      * @Groups({"read", "list", "write"})
  191.      */
  192.     private $tenantId;
  193.     /**
  194.      * @var string|null
  195.      * @Groups({"read", "list", "write"})
  196.      */
  197.     private $mailingHost;
  198.     /**
  199.      * @var DateTime|null
  200.      * @Groups({"read", "list", "write"})
  201.      */
  202.     private $deletedAt;
  203.     /**
  204.      * @var Collection|OutlookSubscriptionConfiguration[]
  205.      */
  206.     private $outlookSubscriptionConfigurations;
  207.     public function __construct()
  208.     {
  209.         $this->users = new ArrayCollection();
  210.         $this->customerFiles = new ArrayCollection();
  211.         $this->modules = new ArrayCollection();
  212.         $this->outlookSubscriptionConfigurations = new ArrayCollection();
  213.     }
  214.     public function __toString()
  215.     {
  216.         return $this->id;
  217.     }
  218.     /**
  219.      * @param string $moduleRole
  220.      *
  221.      * @return bool
  222.      */
  223.     public function hasCustomerModule(string $moduleRole): bool
  224.     {
  225.         foreach ($this->getModules() as $module) {
  226.             if ($module->getRole() === $moduleRole) {
  227.                 return true;
  228.             }
  229.         }
  230.         return false;
  231.     }
  232.     /**
  233.      * @return string|null
  234.      */
  235.     public function getId(): ?string
  236.     {
  237.         return $this->id;
  238.     }
  239.     /**
  240.      * @param string|null $id
  241.      *
  242.      * @return Customer
  243.      */
  244.     public function setId(?string $id): Customer
  245.     {
  246.         $this->id $id;
  247.         return $this;
  248.     }
  249.     /**
  250.      * @return string|null
  251.      */
  252.     public function getName(): ?string
  253.     {
  254.         return $this->name;
  255.     }
  256.     /**
  257.      * @param string|null $name
  258.      *
  259.      * @return Customer
  260.      */
  261.     public function setName(?string $name): Customer
  262.     {
  263.         $this->name $name;
  264.         return $this;
  265.     }
  266.     /**
  267.      * @return DateTime|null
  268.      */
  269.     public function getExpiredAt(): ?DateTime
  270.     {
  271.         return $this->expiredAt;
  272.     }
  273.     /**
  274.      * @param DateTime|null $expiredAt
  275.      *
  276.      * @return Customer
  277.      */
  278.     public function setExpiredAt(?DateTime $expiredAt): Customer
  279.     {
  280.         $this->expiredAt $expiredAt;
  281.         return $this;
  282.     }
  283.     /**
  284.      * @return bool|null
  285.      */
  286.     public function getIsActive(): ?bool
  287.     {
  288.         return $this->isActive;
  289.     }
  290.     /**
  291.      * @param bool|null $isActive
  292.      *
  293.      * @return Customer
  294.      */
  295.     public function setIsActive(?bool $isActive): Customer
  296.     {
  297.         $this->isActive $isActive;
  298.         return $this;
  299.     }
  300.     /**
  301.      * @return string|null
  302.      */
  303.     public function getPhone(): ?string
  304.     {
  305.         return $this->phone;
  306.     }
  307.     /**
  308.      * @param string|null $phone
  309.      *
  310.      * @return Customer
  311.      */
  312.     public function setPhone(?string $phone): Customer
  313.     {
  314.         $this->phone $phone;
  315.         return $this;
  316.     }
  317.     /**
  318.      * @return string|null
  319.      */
  320.     public function getFax(): ?string
  321.     {
  322.         return $this->fax;
  323.     }
  324.     /**
  325.      * @param string|null $fax
  326.      *
  327.      * @return Customer
  328.      */
  329.     public function setFax(?string $fax): Customer
  330.     {
  331.         $this->fax $fax;
  332.         return $this;
  333.     }
  334.     /**
  335.      * @return string|null
  336.      */
  337.     public function getEmail(): ?string
  338.     {
  339.         return $this->email;
  340.     }
  341.     /**
  342.      * @param string|null $email
  343.      *
  344.      * @return Customer
  345.      */
  346.     public function setEmail(?string $email): Customer
  347.     {
  348.         $this->email $email;
  349.         return $this;
  350.     }
  351.     /**
  352.      * @return string|null
  353.      */
  354.     public function getWebsite(): ?string
  355.     {
  356.         return $this->website;
  357.     }
  358.     /**
  359.      * @param string|null $website
  360.      *
  361.      * @return Customer
  362.      */
  363.     public function setWebsite(?string $website): Customer
  364.     {
  365.         $this->website $website;
  366.         return $this;
  367.     }
  368.     /**
  369.      * @return string|null
  370.      */
  371.     public function getAddress(): ?string
  372.     {
  373.         return $this->address;
  374.     }
  375.     /**
  376.      * @param string|null $address
  377.      *
  378.      * @return Customer
  379.      */
  380.     public function setAddress(?string $address): Customer
  381.     {
  382.         $this->address $address;
  383.         return $this;
  384.     }
  385.     /**
  386.      * @return string|null
  387.      */
  388.     public function getPostalCode(): ?string
  389.     {
  390.         return $this->postalCode;
  391.     }
  392.     /**
  393.      * @param string|null $postalCode
  394.      *
  395.      * @return Customer
  396.      */
  397.     public function setPostalCode(?string $postalCode): Customer
  398.     {
  399.         $this->postalCode $postalCode;
  400.         return $this;
  401.     }
  402.     /**
  403.      * @return string|null
  404.      */
  405.     public function getCity(): ?string
  406.     {
  407.         return $this->city;
  408.     }
  409.     /**
  410.      * @param string|null $city
  411.      *
  412.      * @return Customer
  413.      */
  414.     public function setCity(?string $city): Customer
  415.     {
  416.         $this->city $city;
  417.         return $this;
  418.     }
  419.     /**
  420.      * @return float|null
  421.      */
  422.     public function getLat(): ?float
  423.     {
  424.         return $this->lat;
  425.     }
  426.     /**
  427.      * @param float|null $lat
  428.      *
  429.      * @return Customer
  430.      */
  431.     public function setLat(?float $lat): Customer
  432.     {
  433.         $this->lat $lat;
  434.         return $this;
  435.     }
  436.     /**
  437.      * @return float|null
  438.      */
  439.     public function getLng(): ?float
  440.     {
  441.         return $this->lng;
  442.     }
  443.     /**
  444.      * @param float|null $lng
  445.      *
  446.      * @return Customer
  447.      */
  448.     public function setLng(?float $lng): Customer
  449.     {
  450.         $this->lng $lng;
  451.         return $this;
  452.     }
  453.     /**
  454.      * @return bool|null
  455.      */
  456.     public function getIsGeolocated(): ?bool
  457.     {
  458.         return $this->isGeolocated;
  459.     }
  460.     /**
  461.      * @param bool|null $isGeolocated
  462.      *
  463.      * @return Customer
  464.      */
  465.     public function setIsGeolocated(?bool $isGeolocated): Customer
  466.     {
  467.         $this->isGeolocated $isGeolocated;
  468.         return $this;
  469.     }
  470.     /**
  471.      * @return string|null
  472.      */
  473.     public function getExternalId(): ?string
  474.     {
  475.         return $this->externalId;
  476.     }
  477.     /**
  478.      * @param string|null $externalId
  479.      *
  480.      * @return Customer
  481.      */
  482.     public function setExternalId(?string $externalId): Customer
  483.     {
  484.         $this->externalId $externalId;
  485.         return $this;
  486.     }
  487.     /**
  488.      * @return int|null
  489.      */
  490.     public function getLicenseNumber(): ?int
  491.     {
  492.         return $this->licenseNumber;
  493.     }
  494.     /**
  495.      * @param int|null $licenseNumber
  496.      *
  497.      * @return Customer
  498.      */
  499.     public function setLicenseNumber(?int $licenseNumber): Customer
  500.     {
  501.         $this->licenseNumber $licenseNumber;
  502.         return $this;
  503.     }
  504.     /**
  505.      * @return DateTime|null
  506.      */
  507.     public function getBuyingAt(): ?DateTime
  508.     {
  509.         return $this->buyingAt;
  510.     }
  511.     /**
  512.      * @param DateTime|null $buyingAt
  513.      *
  514.      * @return Customer
  515.      */
  516.     public function setBuyingAt(?DateTime $buyingAt): Customer
  517.     {
  518.         $this->buyingAt $buyingAt;
  519.         return $this;
  520.     }
  521.     /**
  522.      * @return UserInfo[]|Collection
  523.      */
  524.     public function getUsers(): Collection
  525.     {
  526.         return $this->users;
  527.     }
  528.     /**
  529.      * @param Collection $users
  530.      *
  531.      * @return Customer
  532.      */
  533.     public function setUsersFromForm(Collection $users): self
  534.     {
  535.         $this->users $users;
  536.         return $this;
  537.     }
  538.     /**
  539.      * @param UserInfo $userInfo
  540.      *
  541.      * @return $this
  542.      */
  543.     public function addUser(UserInfo $userInfo): self
  544.     {
  545.         if (!$this->users->contains($userInfo)) {
  546.             $userInfo->setCustomer($this);
  547.             $this->users->add($userInfo);
  548.         }
  549.         return $this;
  550.     }
  551.     /**
  552.      * @param UserInfo $userInfo
  553.      *
  554.      * @return $this
  555.      */
  556.     public function removeUser(UserInfo $userInfo): self
  557.     {
  558.         if ($this->users->contains($userInfo)) {
  559.             $userInfo->setCustomer(null);
  560.             $this->users->removeElement($userInfo);
  561.         }
  562.         return $this;
  563.     }
  564.     /**
  565.      * @return int|null
  566.      */
  567.     public function getActiveUsersNumber(): ?int
  568.     {
  569.         return $this->activeUsersNumber;
  570.     }
  571.     /**
  572.      * @param int|null $activeUsersNumber
  573.      *
  574.      * @return Customer
  575.      */
  576.     public function setActiveUsersNumber(?int $activeUsersNumber): Customer
  577.     {
  578.         $this->activeUsersNumber $activeUsersNumber;
  579.         return $this;
  580.     }
  581.     /**
  582.      * @return CustomerFile[]|Collection
  583.      */
  584.     public function getCustomerFiles(): Collection
  585.     {
  586.         return $this->customerFiles;
  587.     }
  588.     /**
  589.      * @param CustomerFile[]|Collection $customerFiles
  590.      *
  591.      * @return Customer
  592.      */
  593.     public function setCustomerFiles($customerFiles): Customer
  594.     {
  595.         $this->customerFiles $customerFiles;
  596.         return $this;
  597.     }
  598.     /**
  599.      * @return string|null
  600.      */
  601.     public function getLogoUrl(): ?string
  602.     {
  603.         return $this->logoUrl;
  604.     }
  605.     /**
  606.      * @param string|null $logoUrl
  607.      *
  608.      * @return Customer
  609.      */
  610.     public function setLogoUrl(?string $logoUrl): Customer
  611.     {
  612.         $this->logoUrl $logoUrl;
  613.         return $this;
  614.     }
  615.     /**
  616.      * @return bool|null
  617.      */
  618.     public function getIsLiveo(): ?bool
  619.     {
  620.         return $this->isLiveo;
  621.     }
  622.     /**
  623.      * @param bool|null $isLiveo
  624.      *
  625.      * @return Customer
  626.      */
  627.     public function setIsLiveo(?bool $isLiveo): Customer
  628.     {
  629.         $this->isLiveo $isLiveo;
  630.         return $this;
  631.     }
  632.     /**
  633.      * @return string|null
  634.      */
  635.     public function getMailingId(): ?string
  636.     {
  637.         return $this->mailingId;
  638.     }
  639.     /**
  640.      * @param string|null $mailingId
  641.      *
  642.      * @return Customer
  643.      */
  644.     public function setMailingId(?string $mailingId): Customer
  645.     {
  646.         $this->mailingId $mailingId;
  647.         return $this;
  648.     }
  649.     /**
  650.      * @return bool|null
  651.      */
  652.     public function getHasIntranet(): ?bool
  653.     {
  654.         return $this->hasIntranet;
  655.     }
  656.     /**
  657.      * @param bool|null $hasIntranet
  658.      *
  659.      * @return Customer
  660.      */
  661.     public function setHasIntranet(?bool $hasIntranet): Customer
  662.     {
  663.         $this->hasIntranet $hasIntranet;
  664.         return $this;
  665.     }
  666.     /**
  667.      * @return string
  668.      */
  669.     public function getLanguage(): string
  670.     {
  671.         return $this->language;
  672.     }
  673.     /**
  674.      * @param string $language
  675.      *
  676.      * @return Customer
  677.      */
  678.     public function setLanguage(string $language): self
  679.     {
  680.         $this->language $language;
  681.         return $this;
  682.     }
  683.     /**
  684.      * @return Module[]|Collection
  685.      */
  686.     public function getModules(): Collection
  687.     {
  688.         return $this->modules;
  689.     }
  690.     /**
  691.      * @param Module[]|Collection $modules
  692.      *
  693.      * @return Customer
  694.      */
  695.     public function setModules(Collection $modules): self
  696.     {
  697.         $this->modules $modules;
  698.         return $this;
  699.     }
  700.     /**
  701.      * @param Module|null $module
  702.      *
  703.      * @return $this
  704.      */
  705.     public function addModule(?Module $module): self
  706.     {
  707.         if ($module && !$this->modules->contains($module)) {
  708.             $this->modules->add($module);
  709.         }
  710.         return $this;
  711.     }
  712.     /**
  713.      * @param Module|null $module
  714.      *
  715.      * @return $this
  716.      */
  717.     public function removeModule(?Module $module): self
  718.     {
  719.         if ($module && $this->modules->contains($module)) {
  720.             $this->modules->removeElement($module);
  721.             return $this;
  722.         }
  723.         if ($module) {
  724.             foreach ($this->getModules() as $customerModule) {
  725.                 if ($customerModule->getRole() === $module->getRole()) {
  726.                     $this->modules->removeElement($customerModule);
  727.                 }
  728.             }
  729.         }
  730.         return $this;
  731.     }
  732.     public function getAlternativeTranslations(): ?string
  733.     {
  734.         return $this->alternativeTranslations;
  735.     }
  736.     public function setAlternativeTranslations(?string $alternativeTranslations): Customer
  737.     {
  738.         $this->alternativeTranslations $alternativeTranslations;
  739.         return $this;
  740.     }
  741.     /**
  742.      * @return string|null
  743.      */
  744.     public function getTenantId(): ?string
  745.     {
  746.         return $this->tenantId;
  747.     }
  748.     /**
  749.      * @param string|null $tenantId
  750.      *
  751.      * @return Customer
  752.      */
  753.     public function setTenantId(?string $tenantId): self
  754.     {
  755.         $this->tenantId $tenantId;
  756.         return $this;
  757.     }
  758.     /**
  759.      * @return Collection|OutlookSubscriptionConfiguration[]
  760.      */
  761.     public function getOutlookSubscriptionConfigurations(): Collection
  762.     {
  763.         return $this->outlookSubscriptionConfigurations;
  764.     }
  765.     /**
  766.      * @param OutlookSubscriptionConfiguration $outlookSubscriptionConfiguration
  767.      *
  768.      * @return $this
  769.      */
  770.     public function addOutlookSubscriptionConfiguration(OutlookSubscriptionConfiguration $outlookSubscriptionConfiguration): self
  771.     {
  772.         if (!$this->outlookSubscriptionConfigurations->contains($outlookSubscriptionConfiguration)) {
  773.             $this->outlookSubscriptionConfigurations[] = $outlookSubscriptionConfiguration;
  774.             $outlookSubscriptionConfiguration->setCustomer($this);
  775.         }
  776.         return $this;
  777.     }
  778.     /**
  779.      * @param OutlookSubscriptionConfiguration $outlookSubscriptionConfiguration
  780.      *
  781.      * @return Customer
  782.      */
  783.     public function removeOutlookSubscriptionConfiguration(OutlookSubscriptionConfiguration $outlookSubscriptionConfiguration): self
  784.     {
  785.         if ($this->outlookSubscriptionConfigurations->contains($outlookSubscriptionConfiguration)) {
  786.             $this->outlookSubscriptionConfigurations->removeElement($outlookSubscriptionConfiguration);
  787.         }
  788.         return $this;
  789.     }
  790.     /**
  791.      * @param Collection $outlookSubscriptionConfigurations
  792.      *
  793.      * @return Customer
  794.      */
  795.     public function setOutlookSubscriptionConfigurations(Collection $outlookSubscriptionConfigurations): Customer
  796.     {
  797.         $this->outlookSubscriptionConfigurations $outlookSubscriptionConfigurations;
  798.         return $this;
  799.     }
  800.     public function getMailingHost(): ?string
  801.     {
  802.         return $this->mailingHost;
  803.     }
  804.     public function setMailingHost(?string $mailingHost): self
  805.     {
  806.         $this->mailingHost $mailingHost;
  807.         return $this;
  808.     }
  809.     public function getDeletedAt(): ?DateTime
  810.     {
  811.         return $this->deletedAt;
  812.     }
  813.     public function setDeletedAt(?DateTime $deletedAt): self
  814.     {
  815.         $this->deletedAt $deletedAt;
  816.         return $this;
  817.     }
  818. }