src/Entity/Option.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use Symfony\Component\Serializer\Annotation\Groups;
  5. use App\Repository\OptionRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. /**
  11.  * @ApiResource(
  12.  *     security = "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
  13.  *     normalizationContext = { "groups" = {"option:read"}, "swagger_definition_name" = "Read" },
  14.  *     denormalizationContext = { "groups" = {"option:write"}, "swagger_definition_name" = "Write" },
  15.  *
  16.  *      itemOperations={
  17.  *         "get"
  18.  *      },
  19.  *     collectionOperations = {
  20.  *          "get"
  21.  *      },
  22.  *     attributes={
  23.  *          "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
  24.  *     }
  25.  * )
  26.  *
  27.  * @ORM\Entity(repositoryClass=OptionRepository::class)
  28.  * @ORM\HasLifecycleCallbacks()
  29.  * @UniqueEntity(fields={"name"})
  30.  *
  31.  */
  32. class Option
  33. {
  34.     public const AGENT_PUBLIC_HIDE_PROFILE_NAME 'agent.public.hide.profile';
  35.     public const AGENT_PUBLIC_HIDE_PROFILE_CODE 'AGENT_PUBLIC_HIDE_PROFILE_NAME';
  36.     public const AGENT_INTRANET_ACCESS_MILKIYASCAN_NAME 'agent.intranet.access.milkiyascan';
  37.     public const AGENT_INTRANET_ACCESS_MILKIYASCAN_CODE 'AGENT_INTRANET_ACCESS_MILKIYASCAN';
  38.     public const AGENT_PUBLIC_HIDE_BUSINESS_REQUEST_NAME 'agent.public.hide.business.request';
  39.     public const AGENT_PUBLIC_HIDE_BUSINESS_REQUEST_CODE 'AGENT_PUBLIC_HIDE_BUSINESS_REQUEST';
  40.     public const AGENT_PUBLIC_HIDE_SPONSORSHIP_REQUEST_CODE 'AGENT_PUBLIC_HIDE_SPONSORSHIP_REQUEST';
  41.     public const AGENT_PUBLIC_HIDE_SPONSORSHIP_REQUEST_NAME 'agent.public.hide.sponsorship.request';
  42.     public const ALL_OPTIONS = [
  43.         self::AGENT_PUBLIC_HIDE_PROFILE_CODE => self::AGENT_PUBLIC_HIDE_PROFILE_NAME,
  44.         self::AGENT_INTRANET_ACCESS_MILKIYASCAN_CODE => self::AGENT_INTRANET_ACCESS_MILKIYASCAN_NAME,
  45.         self::AGENT_PUBLIC_HIDE_BUSINESS_REQUEST_CODE => self::AGENT_PUBLIC_HIDE_BUSINESS_REQUEST_NAME,
  46.         self::AGENT_PUBLIC_HIDE_SPONSORSHIP_REQUEST_CODE => self::AGENT_PUBLIC_HIDE_SPONSORSHIP_REQUEST_NAME
  47.     ];
  48.     /**
  49.      * @ORM\Id
  50.      * @ORM\GeneratedValue
  51.      * @ORM\Column(type="integer")
  52.      *
  53.      * @Groups({
  54.      *   "siege:put","siege:write",
  55.      *   "option:read","option:write","option:put",
  56.      *   "agentsOptions:read", "contact:read"
  57.      * })
  58.      */
  59.     private $id;
  60.     /**
  61.      * @ORM\Column(type="string", length=255)
  62.      *
  63.      * @Groups({
  64.      *   "siege:put","siege:write",
  65.      *   "option:read","option:write","option:put",
  66.      *   "agentsOptions:read",
  67.      *   "agent:read",
  68.      *   "directory:collaborator:search",
  69.      *   "milkiya:read",
  70.      *   "AgentsOptions:read",
  71.      *   "contact:read"
  72.      * })
  73.      *
  74.      */
  75.     private $name;
  76.     /**
  77.      * @ORM\Column(type="string", length=50)
  78.      *
  79.      * @Groups({
  80.      *   "siege:put","siege:write",
  81.      *   "option:read","option:write","option:put",
  82.      *   "agentsOptions:read",
  83.      *   "agent:read",
  84.      *   "contact:read",
  85.      *   "directory:collaborator:search",
  86.      * })
  87.      */
  88.     private $type;
  89.     /**
  90.      * @ORM\Column(type="array")
  91.      *
  92.      * @Groups({
  93.      *   "siege:put","siege:write",
  94.      *   "option:read","option:write","option:put",
  95.      * })
  96.      */
  97.     private $values = [];
  98.     /**
  99.      * @ORM\Column(type="string", length=255, nullable=true)
  100.      *
  101.      *
  102.      * @Groups({
  103.      *   "siege:put","siege:write",
  104.      *   "option:read","option:write","option:put",
  105.      * })
  106.      */
  107.     private $defaultValue;
  108.     /**
  109.      * @ORM\Column(type="string", length=255, unique=true)
  110.      *
  111.      * @Groups({
  112.      *   "option:read","option:write","option:put",
  113.      *   "agentsOptions:read",
  114.      *   "agent:read",
  115.      *   "directory:collaborator:search",
  116.      *   "milkiya:read",
  117.      *   "contact:read"
  118.      * })
  119.      */
  120.     private $code;
  121.     /**
  122.      * @ORM\OneToMany(targetEntity=AgentsOptions::class, mappedBy="option")
  123.      */
  124.     private $agentsOptions;
  125.     public function __construct()
  126.     {
  127.         $this->agentsOptions = new ArrayCollection();
  128.     }
  129.     public function getId(): ?int
  130.     {
  131.         return $this->id;
  132.     }
  133.     public function getName(): ?string
  134.     {
  135.         return $this->name;
  136.     }
  137.     public function setName(string $name): self
  138.     {
  139.         $this->name $name;
  140.         return $this;
  141.     }
  142.     public function getType(): ?string
  143.     {
  144.         return $this->type;
  145.     }
  146.     public function setType(string $type): self
  147.     {
  148.         $this->type $type;
  149.         return $this;
  150.     }
  151.     public function getValues(): ?array
  152.     {
  153.         return $this->values;
  154.     }
  155.     public function setValues(array $values): self
  156.     {
  157.         $this->values $values;
  158.         return $this;
  159.     }
  160.     public function getDefaultValue(): ?string
  161.     {
  162.         return $this->defaultValue;
  163.     }
  164.     public function setDefaultValue(?string $defaultValue): self
  165.     {
  166.         $this->defaultValue $defaultValue;
  167.         return $this;
  168.     }
  169.     /**
  170.      * @return Collection<int, AgentsOptions>
  171.      */
  172.     public function getAgentsOptions(): Collection
  173.     {
  174.         return $this->agentsOptions;
  175.     }
  176.     public function addAgentsOption(AgentsOptions $agentsOption): self
  177.     {
  178.         if (!$this->agentsOptions->contains($agentsOption)) {
  179.             $this->agentsOptions[] = $agentsOption;
  180.             $agentsOption->setOption($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeAgentsOption(AgentsOptions $agentsOption): self
  185.     {
  186.         if ($this->agentsOptions->removeElement($agentsOption)) {
  187.             // set the owning side to null (unless already changed)
  188.             if ($agentsOption->getOption() === $this) {
  189.                 $agentsOption->setOption(null);
  190.             }
  191.         }
  192.         return $this;
  193.     }
  194.     public function getCode(): ?string
  195.     {
  196.         return $this->code;
  197.     }
  198.     public function setCode(string $code): self
  199.     {
  200.         $this->code $code;
  201.         return $this;
  202.     }
  203. }