<?php
namespace App\V4\Model\RGPDInfo;
use App\Model\Traits\ImportableObjectTrait;
use App\V4\Model\Contact\Contact;
use App\V4\Model\RGPDPermission\RGPDPermission;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
class RGPDInfo
{
use ImportableObjectTrait;
/**
* @var string|null
*
* @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"})
*/
private $id;
/**
* @var Contact
*
* @MaxDepth(1)
*/
private $contact;
/**
* @var bool
*
* @Groups({"prospect:read", "prospect:write", "prospect:update", "individual:write", "individual:update"})
*/
private $hasPersonalData = false;
/**
* @var string
*/
private $customerId;
/**
* @var RGPDPermission[]|Collection
* @MaxDepth(1)
* @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"})
*/
private $rgpdPermissions;
/**
* @param string $key
*
* @return RGPDPermission|null
*/
public function getPermissionByKey(string $key): ?RGPDPermission
{
foreach ($this->getRgpdPermissions() as $permission) {
if ($permission->getKey() === $key) {
return $permission;
}
}
return null;
}
public function __construct()
{
$this->rgpdPermissions = new ArrayCollection();
}
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
/**
* @param string|null $id
*
* @return RGPDInfo
*/
public function setId(?string $id): RGPDInfo
{
$this->id = $id;
return $this;
}
/**
* @return Contact|null
*/
public function getContact(): ?Contact
{
return $this->contact;
}
/**
* @param Contact|null $contact
*
* @return RGPDInfo
*/
public function setContact($contact): RGPDInfo
{
if ($contact instanceof Contact) {
$this->contact = $contact;
}
return $this;
}
/**
* @return bool
*/
public function getHasPersonalData(): bool
{
return $this->hasPersonalData;
}
/**
* @param bool $hasPersonalData
*
* @return RGPDInfo
*/
public function setHasPersonalData(?bool $hasPersonalData): RGPDInfo
{
$this->hasPersonalData = $hasPersonalData ?? false;
return $this;
}
/**
* @return string|null
*/
public function getCustomerId(): ?string
{
return $this->customerId;
}
/**
* @param string|null $customerId
*
* @return RGPDInfo
*/
public function setCustomerId(?string $customerId): RGPDInfo
{
$this->customerId = $customerId;
return $this;
}
/**
* @return RGPDPermission[]|Collection
*/
public function getRgpdPermissions(): Collection
{
return $this->rgpdPermissions;
}
/**
* @param RGPDPermission $RGPDPermission
*
* @return RGPDInfo
*/
public function addRgpdPermission(RGPDPermission $RGPDPermission): RGPDInfo
{
if (!$this->rgpdPermissions->contains($RGPDPermission)) {
$RGPDPermission->setRGPDInfo($this);
$this->rgpdPermissions->add($RGPDPermission);
}
return $this;
}
/**
* @param RGPDPermission $RGPDPermission
*
* @return RGPDInfo
*/
public function removeRGPDPermission(RGPDPermission $RGPDPermission): RGPDInfo
{
if ($this->rgpdPermissions->contains($RGPDPermission)) {
$RGPDPermission->setRGPDInfo(null);
$this->rgpdPermissions->removeElement($RGPDPermission);
}
return $this;
}
}