<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
use App\Repository\OptionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ApiResource(
* security = "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
* normalizationContext = { "groups" = {"option:read"}, "swagger_definition_name" = "Read" },
* denormalizationContext = { "groups" = {"option:write"}, "swagger_definition_name" = "Write" },
*
* itemOperations={
* "get"
* },
* collectionOperations = {
* "get"
* },
* attributes={
* "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
* }
* )
*
* @ORM\Entity(repositoryClass=OptionRepository::class)
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity(fields={"name"})
*
*/
class Option
{
public const AGENT_PUBLIC_HIDE_PROFILE_NAME = 'agent.public.hide.profile';
public const AGENT_PUBLIC_HIDE_PROFILE_CODE = 'AGENT_PUBLIC_HIDE_PROFILE_NAME';
public const AGENT_INTRANET_ACCESS_MILKIYASCAN_NAME = 'agent.intranet.access.milkiyascan';
public const AGENT_INTRANET_ACCESS_MILKIYASCAN_CODE = 'AGENT_INTRANET_ACCESS_MILKIYASCAN';
public const AGENT_PUBLIC_HIDE_BUSINESS_REQUEST_NAME = 'agent.public.hide.business.request';
public const AGENT_PUBLIC_HIDE_BUSINESS_REQUEST_CODE = 'AGENT_PUBLIC_HIDE_BUSINESS_REQUEST';
public const AGENT_PUBLIC_HIDE_SPONSORSHIP_REQUEST_CODE = 'AGENT_PUBLIC_HIDE_SPONSORSHIP_REQUEST';
public const AGENT_PUBLIC_HIDE_SPONSORSHIP_REQUEST_NAME = 'agent.public.hide.sponsorship.request';
public const ALL_OPTIONS = [
self::AGENT_PUBLIC_HIDE_PROFILE_CODE => self::AGENT_PUBLIC_HIDE_PROFILE_NAME,
self::AGENT_INTRANET_ACCESS_MILKIYASCAN_CODE => self::AGENT_INTRANET_ACCESS_MILKIYASCAN_NAME,
self::AGENT_PUBLIC_HIDE_BUSINESS_REQUEST_CODE => self::AGENT_PUBLIC_HIDE_BUSINESS_REQUEST_NAME,
self::AGENT_PUBLIC_HIDE_SPONSORSHIP_REQUEST_CODE => self::AGENT_PUBLIC_HIDE_SPONSORSHIP_REQUEST_NAME
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Groups({
* "siege:put","siege:write",
* "option:read","option:write","option:put",
* "agentsOptions:read", "contact:read"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "siege:put","siege:write",
* "option:read","option:write","option:put",
* "agentsOptions:read",
* "agent:read",
* "directory:collaborator:search",
* "milkiya:read",
* "AgentsOptions:read",
* "contact:read"
* })
*
*/
private $name;
/**
* @ORM\Column(type="string", length=50)
*
* @Groups({
* "siege:put","siege:write",
* "option:read","option:write","option:put",
* "agentsOptions:read",
* "agent:read",
* "contact:read",
* "directory:collaborator:search",
* })
*/
private $type;
/**
* @ORM\Column(type="array")
*
* @Groups({
* "siege:put","siege:write",
* "option:read","option:write","option:put",
* })
*/
private $values = [];
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
*
* @Groups({
* "siege:put","siege:write",
* "option:read","option:write","option:put",
* })
*/
private $defaultValue;
/**
* @ORM\Column(type="string", length=255, unique=true)
*
* @Groups({
* "option:read","option:write","option:put",
* "agentsOptions:read",
* "agent:read",
* "directory:collaborator:search",
* "milkiya:read",
* "contact:read"
* })
*/
private $code;
/**
* @ORM\OneToMany(targetEntity=AgentsOptions::class, mappedBy="option")
*/
private $agentsOptions;
public function __construct()
{
$this->agentsOptions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getValues(): ?array
{
return $this->values;
}
public function setValues(array $values): self
{
$this->values = $values;
return $this;
}
public function getDefaultValue(): ?string
{
return $this->defaultValue;
}
public function setDefaultValue(?string $defaultValue): self
{
$this->defaultValue = $defaultValue;
return $this;
}
/**
* @return Collection<int, AgentsOptions>
*/
public function getAgentsOptions(): Collection
{
return $this->agentsOptions;
}
public function addAgentsOption(AgentsOptions $agentsOption): self
{
if (!$this->agentsOptions->contains($agentsOption)) {
$this->agentsOptions[] = $agentsOption;
$agentsOption->setOption($this);
}
return $this;
}
public function removeAgentsOption(AgentsOptions $agentsOption): self
{
if ($this->agentsOptions->removeElement($agentsOption)) {
// set the owning side to null (unless already changed)
if ($agentsOption->getOption() === $this) {
$agentsOption->setOption(null);
}
}
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
}