src/V4/Model/Contact/Contact.php line 221

Open in your IDE?
  1. <?php
  2. namespace App\V4\Model\Contact;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use App\Model\IriNormalizableInterface;
  7. use App\Model\NormalizeAsIRITrait;
  8. use App\Model\SpecificFieldsAwareInterface;
  9. use App\Model\Traits\BlamableTrait;
  10. use App\Model\Traits\ImportableObjectTrait;
  11. use App\Model\Traits\TimestampableTrait;
  12. use App\V4\Entity\ActionableEntityInterface;
  13. use App\V4\Model\Address\Address;
  14. use App\V4\Model\Civility\Civility;
  15. use App\V4\Model\ContactSpecificField\ContactSpecificField;
  16. use App\V4\Model\Params\Params;
  17. use App\V4\Model\Prospect\Prospect;
  18. use App\V4\Model\RGPDInfo\RGPDInfo;
  19. use App\V4\Model\Service\Service;
  20. use App\V4\Model\SpecificField\SpecificField;
  21. use App\V4\Model\Task\Task;
  22. use DateTime;
  23. use Doctrine\Common\Collections\ArrayCollection;
  24. use Doctrine\Common\Collections\Collection;
  25. use Symfony\Component\Serializer\Annotation\Groups;
  26. use Symfony\Component\Serializer\Annotation\MaxDepth;
  27. use Symfony\Component\Validator\Constraints as Assert;
  28. /**
  29.  * @ApiResource(
  30.  *     attributes={
  31.  *         "api_allow_update": true
  32.  *     },
  33.  *     collectionOperations={
  34.  *         "get": {
  35.  *             "normalization_context": {
  36.  *                  "groups": {"contact:list"}
  37.  *             },
  38.  *             "security": "is_granted(constant('App\\V4\\Voters\\ContactVoter::CONTACT_SHOW_LIST'), 'App\V4\Voters\ContactVoter')"
  39.  *         },
  40.  *         "post_contact": {
  41.  *             "method": "POST",
  42.  *             "deserialize": false,
  43.  *             "write": false,
  44.  *             "controller": "App\V4\Controller\Contact\ContactDataPersisterAction",
  45.  *             "path": "/V4/contacts",
  46.  *             "input_formats": {
  47.  *                 "multipart": {"multipart/form-data"}
  48.  *             },
  49.  *             "normalization_context": {
  50.  *                  "groups": {"contact:read"}
  51.  *             },
  52.  *             "denormalization_context": {
  53.  *                  "groups": {}
  54.  *             }
  55.  *         },
  56.  *         "get_form": {
  57.  *             "method": "GET",
  58.  *             "path": "/V4/contacts/form",
  59.  *             "controller": App\V4\Controller\Contact\GetContactFormAction::class
  60.  *         },
  61.  *         "get_search": {
  62.  *             "method": "GET",
  63.  *             "path": "/V4/contacts/search/form",
  64.  *             "controller": App\V4\Controller\Contact\GetContactSearchFormAction::class,
  65.  *         },
  66.  *         "post_search": {
  67.  *             "method": "POST",
  68.  *             "deserialize": false,
  69.  *             "path": "/V4/contacts/search/form",
  70.  *             "normalization_context": {
  71.  *                  "groups": {"contact:list"}
  72.  *             },
  73.  *             "controller": App\V4\Controller\Contact\PostContactSearchFormAction::class,
  74.  *         },
  75.  *         "post_export_request": {
  76.  *             "method": "POST",
  77.  *             "path": "/v4/export/contact",
  78.  *             "controller": App\V4\Action\Export\EntityExportRequestAction::class,
  79.  *             "swagger_context": {
  80.  *                 "summary": "Demande de création d'export de contacts",
  81.  *                 "description": "Demande de création d'export de contacts où 'ids' sont les ids des contacts et 'fields' les champs souhaités",
  82.  *                 "parameters": {
  83.  *                     {
  84.  *                         "in": "body",
  85.  *                         "name": "body",
  86.  *                         "schema": {
  87.  *                             "type": "object",
  88.  *                             "properties": {
  89.  *                                 "ids": {
  90.  *                                     "type": "array",
  91.  *                                     "items": {"type": "string"}
  92.  *                                 },
  93.  *                                 "fields": {
  94.  *                                      "type": "array",
  95.  *                                      "items": {"type": "string"}
  96.  *                                 }
  97.  *                             }
  98.  *                         }
  99.  *                     }
  100.  *                 },
  101.  *                 "responses": {
  102.  *                     "201": {
  103.  *                         "description": "Création de l'export avec succès",
  104.  *                         "schema": {
  105.  *                             "type": "object",
  106.  *                             "properties": {
  107.  *                                 "message": {"type": "string", "example": "export_request_created"},
  108.  *                             }
  109.  *                         }
  110.  *                     },
  111.  *                     "400": {
  112.  *                         "description": "Utilisateur non trouvé ou champs 'fields' ou 'ids' manquant dans le body request",
  113.  *                         "schema": {
  114.  *                             "type": "object",
  115.  *                             "properties": {
  116.  *                                 "message": {"type": "string", "example": "user_not_found or missing_fields_or_ids"},
  117.  *                             }
  118.  *                         }
  119.  *                     },
  120.  *                     "422": {
  121.  *                         "description": "Les champs 'fields' ou 'ids' du body request sont vides ou l'entité demandée est invalide",
  122.  *                         "schema": {
  123.  *                             "type": "object",
  124.  *                             "properties": {
  125.  *                                 "message": {"type": "string", "example": "empty_fields_or_ids or entity_not_valid"},
  126.  *                             }
  127.  *                         }
  128.  *                     },
  129.  *                 },
  130.  *             }
  131.  *         },
  132.  *         "post_export_download": {
  133.  *             "method": "POST",
  134.  *             "path": "/v4/export/download/contact/{id}",
  135.  *             "controller": App\V4\Action\Export\EntityExportDownloadAction::class,
  136.  *             "swagger_context": {
  137.  *                 "summary": "Demande de téléchargement d'un export contacts",
  138.  *                 "description": "Demande de téléchargement d'un export contacts ou 'id' est le nom du fichier d'export",
  139.  *                 "requestBody": {},
  140.  *                 "parameters": {
  141.  *                     {
  142.  *                         "in": "path",
  143.  *                         "name": "id",
  144.  *                         "type": "string",
  145.  *                         "required": "true"
  146.  *                     }
  147.  *                 },
  148.  *                 "responses": {
  149.  *                     "200": {
  150.  *                         "description": "Téléchargement de l'export réalisé avec succès"
  151.  *                     },
  152.  *                     "401": {
  153.  *                         "description": "Utilisateur non trouvé ou non connecté",
  154.  *                         "schema": {
  155.  *                             "type": "object",
  156.  *                             "properties": {
  157.  *                                 "message": {"type": "string", "example": "need_authenticated"},
  158.  *                             }
  159.  *                         }
  160.  *                     },
  161.  *                     "404": {
  162.  *                         "description": "Fichier introuvable",
  163.  *                         "schema": {
  164.  *                             "type": "object",
  165.  *                             "properties": {
  166.  *                                 "message": {"type": "string", "example": "export_not_found"},
  167.  *                             }
  168.  *                         }
  169.  *                     },
  170.  *                 },
  171.  *             }
  172.  *         }
  173.  *     },
  174.  *     itemOperations={
  175.  *         "get_form": {
  176.  *             "method": "GET",
  177.  *             "path": "/V4/contacts/{id}/form",
  178.  *             "controller": App\V4\Controller\Contact\GetContactFormAction::class
  179.  *         },
  180.  *         "put_contact": {
  181.  *             "method": "POST",
  182.  *             "deserialize": false,
  183.  *             "write": false,
  184.  *             "controller": "App\V4\Controller\Contact\ContactDataPersisterAction",
  185.  *             "path": "/V4/contacts/{id}",
  186.  *             "input_formats": {
  187.  *                 "multipart": {"multipart/form-data"}
  188.  *             },
  189.  *             "normalization_context": {
  190.  *                  "groups": {"contact:read"}
  191.  *             },
  192.  *             "denormalization_context": {
  193.  *                  "groups": {}
  194.  *             }
  195.  *         },
  196.  *         "get_form_move_contact": {
  197.  *             "method": "GET",
  198.  *             "path": "/V4/contacts/{id}/form_move_contact",
  199.  *             "controller": App\V4\Controller\Contact\GetMoveContactFormAction::class
  200.  *         },
  201.  *         "post_move_contact": {
  202.  *             "method": "POST",
  203.  *             "path": "/V4/contacts/{id}/form_move_contact",
  204.  *             "controller": App\V4\Controller\Contact\PostMoveContactFormAction::class
  205.  *         },
  206.  *         "delete_contact": {
  207.  *             "method": "DELETE",
  208.  *             "deserialize": false,
  209.  *             "write": false,
  210.  *             "controller": "App\V4\Controller\Contact\ContactDataPersisterAction",
  211.  *             "path": "/V4/contacts/{id}"
  212.  *         }
  213.  *     }
  214.  * )
  215.  *
  216.  * @ApiFilter(App\Filters\PagingFilter::class)
  217.  */
  218. class Contact implements IriNormalizableInterfaceSpecificFieldsAwareInterfaceActionableEntityInterface
  219. {
  220.     public const SPECIFIC_FIELD_CLASS_NAME ContactSpecificField::class;
  221.     use TimestampableTrait;
  222.     use BlamableTrait;
  223.     use ImportableObjectTrait;
  224.     use NormalizeAsIRITrait;
  225.     /**
  226.      * @ApiProperty(identifier=true)
  227.      *
  228.      * @var string|null
  229.      *
  230.      * @Groups({
  231.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  232.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update"
  233.      * })
  234.      */
  235.     private $id;
  236.     /**
  237.      * @var Civility|null
  238.      *
  239.      * @Groups({
  240.      *     "list", "contact:list", "contact:read", "contact:write", "contact:update",
  241.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"
  242.      * })
  243.      */
  244.     private $civility;
  245.     /**
  246.      * @var string|null
  247.      *
  248.      * @Groups({
  249.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  250.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"
  251.      * })
  252.      */
  253.     private $firstname;
  254.     /**
  255.      * @var string|null
  256.      *
  257.      * @Assert\NotBlank(groups={"individual", "contact_form"})
  258.      *
  259.      * @Groups({
  260.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  261.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"
  262.      * })
  263.      */
  264.     private $lastname;
  265.     /**
  266.      * @var string|null
  267.      *
  268.      * @Groups({
  269.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  270.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"
  271.      * })
  272.      */
  273.     private $job;
  274.     /**
  275.      * @var string|null
  276.      *
  277.      * @Assert\Email()
  278.      *
  279.      * @Groups({
  280.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  281.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update"
  282.      * })
  283.      */
  284.     private $email;
  285.     /**
  286.      * @Assert\Email()
  287.      *
  288.      * @var string|null
  289.      *
  290.      * @Groups({
  291.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  292.      *     "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"
  293.      * })
  294.      */
  295.     private $emailSecond;
  296.     /**
  297.      * @var string|null
  298.      *
  299.      * @Groups({
  300.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  301.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update"
  302.      * })
  303.      */
  304.     private $phone;
  305.     /**
  306.      * @var string|null
  307.      *
  308.      * @Groups({
  309.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  310.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"
  311.      * })
  312.      */
  313.     private $mobile;
  314.     /**
  315.      * @var string|null
  316.      *
  317.      * @Groups({
  318.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  319.      *     "prospect:read", "prospect:write", "prospect:update"
  320.      * })
  321.      */
  322.     private $fax;
  323.     /**
  324.      * @var Prospect|null
  325.      *
  326.      * @Groups({
  327.      *     "contact:list", "contact:read", "contact:write", "contact:update", "task:read", "task:list"
  328.      * })
  329.      * @MaxDepth(1)
  330.      */
  331.     private $prospect;
  332.     /**
  333.      * @var RGPDInfo|null
  334.      *
  335.      * @Groups({
  336.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  337.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"
  338.      * })
  339.      */
  340.     private $RGPDInfo;
  341.     /**
  342.      * @var string|null
  343.      */
  344.     private $customerId;
  345.     /**
  346.      * @var Service|null
  347.      *
  348.      * @Groups({
  349.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  350.      * })
  351.      */
  352.     private $service;
  353.     /**
  354.      * @var string|null
  355.      *
  356.      * @Groups({
  357.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  358.      * })
  359.      */
  360.     private $externalId;
  361.     /**
  362.      * @var string|null
  363.      *
  364.      * @Groups({
  365.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  366.      *     "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"
  367.      * })
  368.      */
  369.     private $assistantFullName;
  370.     /**
  371.      * @var string|null
  372.      *
  373.      * @Groups({
  374.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  375.      *     "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"
  376.      * })
  377.      */
  378.     private $assistantPhone;
  379.     /**
  380.      * @Assert\Email()
  381.      *
  382.      * @var string|null
  383.      *
  384.      * @Groups({
  385.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  386.      *     "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"
  387.      * })
  388.      */
  389.     private $assistantEmail;
  390.     /**
  391.      * @var DateTime|null
  392.      * @Groups({"contact:list", "contact:read", "contact:write", "contact:update"})
  393.      */
  394.     private $emailRgpdSentAt;
  395.     /**
  396.      * @var string|null
  397.      * @Groups({
  398.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  399.      * })
  400.      */
  401.     private $memo;
  402.     /**
  403.      * @var bool
  404.      * @Groups({
  405.      *     "contact:list", "contact:read", "contact:write", "contact:update"
  406.      * })
  407.      */
  408.     private $unSubscribedOfMailing false;
  409.     /**
  410.      * @var Task[]|Collection
  411.      * @Groups({"contact:list", "contact:read"})
  412.      */
  413.     private $tasks;
  414.     /**
  415.      * @var Address[]|Collection
  416.      * @Groups({
  417.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  418.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update"
  419.      * })
  420.      */
  421.     private $addresses;
  422.     /**
  423.      * @var Address|null
  424.      * @Groups({
  425.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  426.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update"
  427.      * })
  428.      */
  429.     private $mainAddress;
  430.     /**
  431.      * @var Address|null
  432.      * @Groups({
  433.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  434.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update"
  435.      * })
  436.      */
  437.     private $deliveryAddress;
  438.     /**
  439.      * @var bool|null
  440.      * @Groups({
  441.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  442.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update"
  443.      * })
  444.      */
  445.     private $isProspectContact;
  446.     /**
  447.      * @var SpecificField[]|Collection
  448.      *
  449.      * @Groups({
  450.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  451.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update"
  452.      * })
  453.      */
  454.     private $specificFields;
  455.     /**
  456.      * Champ destiné au formulaire de recherche.
  457.      *
  458.      * @Groups({"contact:list", "contact:read"})
  459.      *
  460.      * @var string|null
  461.      */
  462.     private $name;
  463.     public function __construct()
  464.     {
  465.         $this->tasks = new ArrayCollection();
  466.         $this->addresses = new ArrayCollection();
  467.         $this->specificFields = new ArrayCollection();
  468.     }
  469.     /**
  470.      * @return string|null
  471.      *
  472.      * @Groups({
  473.      *     "contact:list", "contact:read",
  474.      *     "prospect:list", "prospect:read"
  475.      * })
  476.      */
  477.     public function getName(): ?string
  478.     {
  479.         return sprintf('%s %s'trim($this->firstname), trim($this->lastname));
  480.     }
  481.     /**
  482.      * @return string|null
  483.      *
  484.      * @Groups({
  485.      *     "contact:list", "contact:read",
  486.      *     "prospect:list", "prospect:read"
  487.      * })
  488.      */
  489.     public function getFullName(): ?string
  490.     {
  491.         return $this->name;
  492.     }
  493.     /**
  494.      * @return bool
  495.      */
  496.     public function isUnknown(): bool
  497.     {
  498.         return $this->getProspect() instanceof Prospect && $this->getProspect()->isUnknown();
  499.     }
  500.     /**
  501.      * @param string|null $name
  502.      *
  503.      * @return Contact
  504.      *
  505.      * @Groups({
  506.      *     "contact:list", "contact:read",
  507.      *     "prospect:list", "prospect:read"
  508.      * })
  509.      */
  510.     public function setName(?string $name): Contact
  511.     {
  512.         $this->name $name;
  513.         return $this;
  514.     }
  515.     /**
  516.      * @return string|null
  517.      */
  518.     public function getId(): ?string
  519.     {
  520.         return $this->id;
  521.     }
  522.     /**
  523.      * @param string|null $id
  524.      *
  525.      * @return $this
  526.      */
  527.     public function setId(?string $id): self
  528.     {
  529.         $this->id $id;
  530.         return $this;
  531.     }
  532.     /**
  533.      * @return Params|null
  534.      */
  535.     public function getCivility(): ?Params
  536.     {
  537.         return $this->civility;
  538.     }
  539.     /**
  540.      * @param Params|null $civility
  541.      *
  542.      * @return $this
  543.      */
  544.     public function setCivility(?Params $civility): self
  545.     {
  546.         $this->civility $civility;
  547.         return $this;
  548.     }
  549.     /**
  550.      * @return string|null
  551.      */
  552.     public function getFirstname(): ?string
  553.     {
  554.         return $this->firstname;
  555.     }
  556.     /**
  557.      * @param string|null $firstname
  558.      *
  559.      * @return $this
  560.      */
  561.     public function setFirstname(?string $firstname): self
  562.     {
  563.         $this->firstname $firstname;
  564.         return $this;
  565.     }
  566.     /**
  567.      * @return string|null
  568.      */
  569.     public function getLastname(): ?string
  570.     {
  571.         return $this->lastname;
  572.     }
  573.     /**
  574.      * @param string|null $lastname
  575.      *
  576.      * @return $this
  577.      */
  578.     public function setLastname(?string $lastname): self
  579.     {
  580.         $this->lastname $lastname;
  581.         return $this;
  582.     }
  583.     /**
  584.      * @return string|null
  585.      */
  586.     public function getJob(): ?string
  587.     {
  588.         return $this->job;
  589.     }
  590.     /**
  591.      * @param string|null $job
  592.      *
  593.      * @return $this
  594.      */
  595.     public function setJob(?string $job): self
  596.     {
  597.         $this->job $job;
  598.         return $this;
  599.     }
  600.     /**
  601.      * @return string|null
  602.      */
  603.     public function getEmail(): ?string
  604.     {
  605.         return $this->email;
  606.     }
  607.     /**
  608.      * @param string|null $email
  609.      *
  610.      * @return $this
  611.      */
  612.     public function setEmail(?string $email): self
  613.     {
  614.         $this->email $email;
  615.         return $this;
  616.     }
  617.     /**
  618.      * @return string|null
  619.      */
  620.     public function getEmailSecond(): ?string
  621.     {
  622.         return $this->emailSecond;
  623.     }
  624.     /**
  625.      * @param string|null $emailSecond
  626.      *
  627.      * @return $this
  628.      */
  629.     public function setEmailSecond(?string $emailSecond): self
  630.     {
  631.         $this->emailSecond $emailSecond;
  632.         return $this;
  633.     }
  634.     /**
  635.      * @return string|null
  636.      */
  637.     public function getPhone(): ?string
  638.     {
  639.         return $this->phone;
  640.     }
  641.     /**
  642.      * @param string|null $phone
  643.      *
  644.      * @return $this
  645.      */
  646.     public function setPhone(?string $phone): self
  647.     {
  648.         $this->phone $phone;
  649.         return $this;
  650.     }
  651.     /**
  652.      * @return string|null
  653.      */
  654.     public function getMobile(): ?string
  655.     {
  656.         return $this->mobile;
  657.     }
  658.     /**
  659.      * @param string|null $mobile
  660.      *
  661.      * @return Contact
  662.      */
  663.     public function setMobile(?string $mobile): Contact
  664.     {
  665.         $this->mobile $mobile;
  666.         return $this;
  667.     }
  668.     /**
  669.      * @return string|null
  670.      */
  671.     public function getFax(): ?string
  672.     {
  673.         return $this->fax;
  674.     }
  675.     /**
  676.      * @param string|null $fax
  677.      *
  678.      * @return $this
  679.      */
  680.     public function setFax(?string $fax): self
  681.     {
  682.         $this->fax $fax;
  683.         return $this;
  684.     }
  685.     /**
  686.      * @return Prospect|null
  687.      */
  688.     public function getProspect(): ?Prospect
  689.     {
  690.         return $this->prospect;
  691.     }
  692.     /**
  693.      * @param Prospect|null $prospect
  694.      *                                #TODO trouver une solution pour empecher le trait ImportableObjectTrait de setter quand on a un IRI
  695.      *
  696.      * @return $this
  697.      */
  698.     public function setProspect($prospect): self
  699.     {
  700.         if ($prospect instanceof Prospect) {
  701.             $this->prospect $prospect;
  702.         }
  703.         return $this;
  704.     }
  705.     /**
  706.      * @return string|null
  707.      */
  708.     public function getCustomerId(): ?string
  709.     {
  710.         return $this->customerId;
  711.     }
  712.     /**
  713.      * @param string|null $customerId
  714.      *
  715.      * @return $this
  716.      */
  717.     public function setCustomerId(?string $customerId): self
  718.     {
  719.         $this->customerId $customerId;
  720.         return $this;
  721.     }
  722.     /**
  723.      * @return Task[]|Collection|null
  724.      */
  725.     public function getTasks(): ?Collection
  726.     {
  727.         return $this->tasks;
  728.     }
  729.     /**
  730.      * @param Task $task
  731.      *
  732.      * @return Contact
  733.      */
  734.     public function addTask(Task $task): self
  735.     {
  736.         if (!$this->tasks->contains($task)) {
  737.             $this->tasks->add($task);
  738.             $task->addContact($this);
  739.         }
  740.         return $this;
  741.     }
  742.     /**
  743.      * @param Task $task
  744.      *
  745.      * @return Contact
  746.      */
  747.     public function removeTask(Task $task): self
  748.     {
  749.         if ($this->tasks->contains($task)) {
  750.             $this->tasks->removeElement($task);
  751.             $task->removeContact($this);
  752.         }
  753.         return $this;
  754.     }
  755.     /**
  756.      * @return Address[]|Collection|null
  757.      *
  758.      * @Groups({"list", "read", "read_contact"})
  759.      */
  760.     public function getAddresses(): ?Collection
  761.     {
  762.         return $this->addresses;
  763.     }
  764.     /**
  765.      * @param Address $address
  766.      *
  767.      * @return $this
  768.      */
  769.     public function addAddress(Address $address): self
  770.     {
  771.         if (!$this->addresses->contains($address)) {
  772.             $this->addresses->add($address);
  773.             $address->setContact($this);
  774.         }
  775.         return $this;
  776.     }
  777.     /**
  778.      * @param Address $address
  779.      *
  780.      * @return $this
  781.      */
  782.     public function removeAddress(Address $address): self
  783.     {
  784.         if (!$this->addresses->contains($address)) {
  785.             $this->addresses->removeElement($address);
  786.             if ($address->getContact() === $this) {
  787.                 $address->setContact(null);
  788.             }
  789.         }
  790.         return $this;
  791.     }
  792.     /**
  793.      * @return Address|null
  794.      */
  795.     public function getMainAddress(): ?Address
  796.     {
  797.         return $this->mainAddress;
  798.     }
  799.     /**
  800.      * @param Address|null $mainAddress
  801.      *
  802.      * @return Contact
  803.      */
  804.     public function setMainAddress(?Address $mainAddress): Contact
  805.     {
  806.         $this->mainAddress $mainAddress;
  807.         return $this;
  808.     }
  809.     /**
  810.      * @return string|null
  811.      */
  812.     public function __toString(): ?string
  813.     {
  814.         return $this->getName();
  815.     }
  816.     /**
  817.      * {@inheritdoc}
  818.      */
  819.     public function getSpecificFields(): Collection
  820.     {
  821.         return $this->specificFields;
  822.     }
  823.     /**
  824.      * {@inheritdoc}
  825.      */
  826.     public function getSpecificFieldByFieldId(string $id): ?SpecificField
  827.     {
  828.         foreach ($this->specificFields as $specificField) {
  829.             if ($specificField->getFieldId() === $id) {
  830.                 return $specificField;
  831.             }
  832.         }
  833.         return null;
  834.     }
  835.     /**
  836.      * @see ImportableObjectTrait::class
  837.      *
  838.      * @param ContactSpecificField $specificField
  839.      *
  840.      * @return $this
  841.      */
  842.     public function addContactSpecificField(ContactSpecificField $specificField): self
  843.     {
  844.         return $this->addSpecificField($specificField);
  845.     }
  846.     /**
  847.      * {@inheritdoc}
  848.      */
  849.     public function addSpecificField($specificField): SpecificFieldsAwareInterface
  850.     {
  851.         $this->specificFields[] = $specificField;
  852.         return $this;
  853.     }
  854.     /**
  855.      * {@inheritdoc}
  856.      */
  857.     public function setSpecificFields(Collection $specificFields): self
  858.     {
  859.         $this->specificFields $specificFields;
  860.         return $this;
  861.     }
  862.     /**
  863.      * @return Params|null
  864.      */
  865.     public function getService(): ?Params
  866.     {
  867.         return $this->service;
  868.     }
  869.     /**
  870.      * @param Params|null $service
  871.      *
  872.      * @return Contact
  873.      */
  874.     public function setService(?Params $service): Contact
  875.     {
  876.         $this->service $service;
  877.         return $this;
  878.     }
  879.     /**
  880.      * @return string|null
  881.      */
  882.     public function getAssistantFullName(): ?string
  883.     {
  884.         return $this->assistantFullName;
  885.     }
  886.     /**
  887.      * @param string|null $assistantFullName
  888.      *
  889.      * @return Contact
  890.      */
  891.     public function setAssistantFullName(?string $assistantFullName): Contact
  892.     {
  893.         $this->assistantFullName $assistantFullName;
  894.         return $this;
  895.     }
  896.     /**
  897.      * @return string|null
  898.      */
  899.     public function getAssistantPhone(): ?string
  900.     {
  901.         return $this->assistantPhone;
  902.     }
  903.     /**
  904.      * @param string|null $assistantPhone
  905.      *
  906.      * @return Contact
  907.      */
  908.     public function setAssistantPhone(?string $assistantPhone): Contact
  909.     {
  910.         $this->assistantPhone $assistantPhone;
  911.         return $this;
  912.     }
  913.     /**
  914.      * @return string|null
  915.      */
  916.     public function getAssistantEmail(): ?string
  917.     {
  918.         return $this->assistantEmail;
  919.     }
  920.     /**
  921.      * @param string|null $assistantEmail
  922.      *
  923.      * @return Contact
  924.      */
  925.     public function setAssistantEmail(?string $assistantEmail): Contact
  926.     {
  927.         $this->assistantEmail $assistantEmail;
  928.         return $this;
  929.     }
  930.     /**
  931.      * @return string|null
  932.      */
  933.     public function getMemo(): ?string
  934.     {
  935.         return $this->memo;
  936.     }
  937.     /**
  938.      * @param string|null $memo
  939.      *
  940.      * @return Contact
  941.      */
  942.     public function setMemo(?string $memo): Contact
  943.     {
  944.         $this->memo $memo;
  945.         return $this;
  946.     }
  947.     /**
  948.      * @return bool|null
  949.      */
  950.     public function getUnSubscribedOfMailing(): bool
  951.     {
  952.         return $this->unSubscribedOfMailing;
  953.     }
  954.     /**
  955.      * @param bool|null $unSubscribedOfMailing
  956.      *
  957.      * @return Contact
  958.      */
  959.     public function setUnSubscribedOfMailing(bool $unSubscribedOfMailing): Contact
  960.     {
  961.         $this->unSubscribedOfMailing $unSubscribedOfMailing;
  962.         return $this;
  963.     }
  964.     /**
  965.      * @return bool|null
  966.      */
  967.     public function getIsProspectContact(): ?bool
  968.     {
  969.         return $this->isProspectContact;
  970.     }
  971.     /**
  972.      * @param bool|null $isProspectContact
  973.      *
  974.      * @return Contact
  975.      */
  976.     public function setIsProspectContact(?bool $isProspectContact): self
  977.     {
  978.         $this->isProspectContact $isProspectContact;
  979.         return $this;
  980.     }
  981.     /**
  982.      * @return string|null
  983.      */
  984.     public function getExternalId(): ?string
  985.     {
  986.         return $this->externalId;
  987.     }
  988.     /**
  989.      * @param string|null $externalId
  990.      *
  991.      * @return Contact
  992.      */
  993.     public function setExternalId(?string $externalId): Contact
  994.     {
  995.         $this->externalId $externalId;
  996.         return $this;
  997.     }
  998.     /**
  999.      * @Groups({"list", "read", "read_contact", "read_prospect", "write_post_prospect", "read_post_prospect", "write_post_contact", "read_post_contact"})
  1000.      *
  1001.      * @return string|null
  1002.      */
  1003.     public function getCreatedBy(): ?string
  1004.     {
  1005.         return $this->createdBy;
  1006.     }
  1007.     /**
  1008.      * @Groups({"list", "read", "read_contact", "read_prospect", "write_post_prospect", "read_post_prospect", "write_post_contact", "read_post_contact"})
  1009.      *
  1010.      * @return string|null
  1011.      */
  1012.     public function getUpdatedBy(): ?string
  1013.     {
  1014.         return $this->updatedBy;
  1015.     }
  1016.     /**
  1017.      * @Groups({"list", "read", "read_contact", "read_prospect", "write_post_prospect", "read_post_prospect", "write_post_contact", "read_post_contact"})
  1018.      *
  1019.      * @return DateTime|null
  1020.      */
  1021.     public function getCreatedAt(): ?DateTime
  1022.     {
  1023.         return $this->createdAt;
  1024.     }
  1025.     /**
  1026.      * @Groups({"list", "read", "read_contact", "read_prospect", "write_post_prospect", "read_post_prospect", "write_post_contact", "read_post_contact"})
  1027.      *
  1028.      * @return DateTime|null
  1029.      */
  1030.     public function getUpdatedAt(): ?DateTime
  1031.     {
  1032.         return $this->updatedAt;
  1033.     }
  1034.     /**
  1035.      * @return Address|null
  1036.      */
  1037.     public function getDeliveryAddress(): ?Address
  1038.     {
  1039.         return $this->deliveryAddress;
  1040.     }
  1041.     /**
  1042.      * @param Address|null $deliveryAddress
  1043.      *
  1044.      * @return Contact
  1045.      */
  1046.     public function setDeliveryAddress(?Address $deliveryAddress): Contact
  1047.     {
  1048.         $this->deliveryAddress $deliveryAddress;
  1049.         return $this;
  1050.     }
  1051.     /**
  1052.      * @return RGPDInfo|null
  1053.      */
  1054.     public function getRGPDInfo(): ?RGPDInfo
  1055.     {
  1056.         return $this->RGPDInfo;
  1057.     }
  1058.     /**
  1059.      * @param RGPDInfo|null $RGPDInfo
  1060.      *
  1061.      * @return Contact
  1062.      */
  1063.     public function setRGPDInfo(?RGPDInfo $RGPDInfo): Contact
  1064.     {
  1065.         $this->RGPDInfo $RGPDInfo;
  1066.         return $this;
  1067.     }
  1068.     /**
  1069.      * @return DateTime|null
  1070.      */
  1071.     public function getEmailRgpdSentAt(): ?DateTime
  1072.     {
  1073.         return $this->emailRgpdSentAt;
  1074.     }
  1075.     /**
  1076.      * @param DateTime|null $emailRgpdSentAt
  1077.      *
  1078.      * @return Contact
  1079.      */
  1080.     public function setEmailRgpdSentAt(?DateTime $emailRgpdSentAt): Contact
  1081.     {
  1082.         $this->emailRgpdSentAt $emailRgpdSentAt;
  1083.         return $this;
  1084.     }
  1085. }