src/V4/Model/RGPDInfo/RGPDInfo.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\V4\Model\RGPDInfo;
  3. use App\Model\Traits\ImportableObjectTrait;
  4. use App\V4\Model\Contact\Contact;
  5. use App\V4\Model\RGPDPermission\RGPDPermission;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Serializer\Annotation\MaxDepth;
  10. class RGPDInfo
  11. {
  12.     use ImportableObjectTrait;
  13.     /**
  14.      * @var string|null
  15.      *
  16.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"})
  17.      */
  18.     private $id;
  19.     /**
  20.      * @var Contact
  21.      *
  22.      * @MaxDepth(1)
  23.      */
  24.     private $contact;
  25.     /**
  26.      * @var bool
  27.      *
  28.      * @Groups({"prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"})
  29.      */
  30.     private $hasPersonalData false;
  31.     /**
  32.      * @var string
  33.      */
  34.     private $customerId;
  35.     /**
  36.      * @var RGPDPermission[]|Collection
  37.      * @MaxDepth(1)
  38.      * @Groups({"list", "read", "list_contact", "read_contact", "list_prospect", "read_prospect", "read_post_prospect", "read_post_contact",  "read_post_task", "sub_listing", "write_rgpd_info"})
  39.      */
  40.     private $rgpdPermissions;
  41.     /**
  42.      * @param string $key
  43.      *
  44.      * @return RGPDPermission|null
  45.      */
  46.     public function getPermissionByKey(string $key): ?RGPDPermission
  47.     {
  48.         foreach ($this->getRgpdPermissions() as $permission) {
  49.             if ($permission->getKey() === $key) {
  50.                 return $permission;
  51.             }
  52.         }
  53.         return null;
  54.     }
  55.     public function __construct()
  56.     {
  57.         $this->rgpdPermissions = new ArrayCollection();
  58.     }
  59.     /**
  60.      * @return string|null
  61.      */
  62.     public function getId(): ?string
  63.     {
  64.         return $this->id;
  65.     }
  66.     /**
  67.      * @param string|null $id
  68.      *
  69.      * @return RGPDInfo
  70.      */
  71.     public function setId(?string $id): RGPDInfo
  72.     {
  73.         $this->id $id;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return Contact|null
  78.      */
  79.     public function getContact(): ?Contact
  80.     {
  81.         return $this->contact;
  82.     }
  83.     /**
  84.      * @param Contact|null $contact
  85.      *
  86.      * @return RGPDInfo
  87.      */
  88.     public function setContact($contact): RGPDInfo
  89.     {
  90.         if ($contact instanceof Contact) {
  91.             $this->contact $contact;
  92.         }
  93.         return $this;
  94.     }
  95.     /**
  96.      * @return bool
  97.      */
  98.     public function getHasPersonalData(): bool
  99.     {
  100.         return $this->hasPersonalData;
  101.     }
  102.     /**
  103.      * @param bool $hasPersonalData
  104.      *
  105.      * @return RGPDInfo
  106.      */
  107.     public function setHasPersonalData(?bool $hasPersonalData): RGPDInfo
  108.     {
  109.         $this->hasPersonalData $hasPersonalData ?? false;
  110.         return $this;
  111.     }
  112.     /**
  113.      * @return string|null
  114.      */
  115.     public function getCustomerId(): ?string
  116.     {
  117.         return $this->customerId;
  118.     }
  119.     /**
  120.      * @param string|null $customerId
  121.      *
  122.      * @return RGPDInfo
  123.      */
  124.     public function setCustomerId(?string $customerId): RGPDInfo
  125.     {
  126.         $this->customerId $customerId;
  127.         return $this;
  128.     }
  129.     /**
  130.      * @return RGPDPermission[]|Collection
  131.      */
  132.     public function getRgpdPermissions(): Collection
  133.     {
  134.         return $this->rgpdPermissions;
  135.     }
  136.     /**
  137.      * @param RGPDPermission $RGPDPermission
  138.      *
  139.      * @return RGPDInfo
  140.      */
  141.     public function addRgpdPermission(RGPDPermission $RGPDPermission): RGPDInfo
  142.     {
  143.         if (!$this->rgpdPermissions->contains($RGPDPermission)) {
  144.             $RGPDPermission->setRGPDInfo($this);
  145.             $this->rgpdPermissions->add($RGPDPermission);
  146.         }
  147.         return $this;
  148.     }
  149.     /**
  150.      * @param RGPDPermission $RGPDPermission
  151.      *
  152.      * @return RGPDInfo
  153.      */
  154.     public function removeRGPDPermission(RGPDPermission $RGPDPermission): RGPDInfo
  155.     {
  156.         if ($this->rgpdPermissions->contains($RGPDPermission)) {
  157.             $RGPDPermission->setRGPDInfo(null);
  158.             $this->rgpdPermissions->removeElement($RGPDPermission);
  159.         }
  160.         return $this;
  161.     }
  162. }