src/Entity/Reference/ReferenceMandateType.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Reference;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Entity\Mandate;
  5. use App\Repository\Reference\ReferenceMandateTypeRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. /**
  11.  * @ApiResource(
  12.  *     security= "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
  13.  *     normalizationContext={"groups"={"reference-mandate-type:read"}, "swagger_definition_name"="Read"},
  14.  *     denormalizationContext={"groups"={"reference-mandate-type:write"}, "swagger_definition_name"="Write"},
  15.  *     itemOperations={
  16.  *          "get"
  17.  *     },
  18.  *     collectionOperations={
  19.  *           "get",
  20.  *
  21.  *     },
  22.  *     attributes={
  23.  *          "pagination_items_per_page"=10,
  24.  *          "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
  25.  *     }
  26.  * )
  27.  * @ORM\Entity(repositoryClass=ReferenceMandateTypeRepository::class)
  28.  */
  29. class ReferenceMandateType
  30. {
  31.     public const TRANSLATION_DOMAIN 'reference_mandate';
  32.     public const REFERENCE_MANDATE_TYPE_SIMPLE 'reference.mandate.type.SIMPLE';
  33.     public const REFERENCE_MANDATE_TYPE_EXCLUSIVE 'reference.mandate.type.EXCLUSIVE';
  34.     public const CODE_REFERENCE_MANDATE_TYPE_SIMPLE =  '0';
  35.     public const CODE_REFERENCE_MANDATE_TYPE_EXCLUSIVE '-1';
  36.     public const ALL_REFERENCE_MANDATE_TYPE = [self::REFERENCE_MANDATE_TYPE_SIMPLEself::REFERENCE_MANDATE_TYPE_EXCLUSIVE];
  37.     public const ALL_CODE_REFERENCE_MANDATE_TYPE = [self::CODE_REFERENCE_MANDATE_TYPE_SIMPLE,self::CODE_REFERENCE_MANDATE_TYPE_EXCLUSIVE];
  38.     /**
  39.      * @ORM\Id
  40.      * @ORM\GeneratedValue
  41.      * @ORM\Column(type="integer")
  42.      *
  43.      * @Groups({
  44.      *   "mandate:read",
  45.      *   "transaction-item:read",
  46.      *   "reference-mandate-type:read"
  47.      * })
  48.      */
  49.     private $id;
  50.     /**
  51.      * @ORM\Column(type="string", length=255)
  52.      *
  53.      * @Groups({
  54.      *   "mandate:read",
  55.      *   "transaction-item:read",
  56.      *   "reference-mandate-type:read"
  57.      * })
  58.      */
  59.     private ?string $name;
  60.     /**
  61.      * @ORM\Column(type="string", length=255)
  62.      *
  63.      * @Groups({
  64.      *   "mandate:read",
  65.      *   "transaction-item:read",
  66.      *   "reference-mandate-type:read"
  67.      * })
  68.      */
  69.     private ?string $code;
  70.     /**
  71.      * @ORM\OneToMany(targetEntity=Mandate::class, mappedBy="referenceMandateType")
  72.      */
  73.     private $mandates;
  74.     public function __construct()
  75.     {
  76.         $this->mandates = new ArrayCollection();
  77.     }
  78.     public function getId(): ?int
  79.     {
  80.         return $this->id;
  81.     }
  82.     public function getName(): ?string
  83.     {
  84.         return $this->name;
  85.     }
  86.     public function setName(string $name): self
  87.     {
  88.         $this->name $name;
  89.         return $this;
  90.     }
  91.     public function getCode(): ?string
  92.     {
  93.         return $this->code;
  94.     }
  95.     public function setCode(string $code): self
  96.     {
  97.         $this->code $code;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection|Mandate[]
  102.      */
  103.     public function getMandates(): Collection
  104.     {
  105.         return $this->mandates;
  106.     }
  107.     public function addMandate(Mandate $mandate): self
  108.     {
  109.         if (!$this->mandates->contains($mandate)) {
  110.             $this->mandates[] = $mandate;
  111.             $mandate->setReferenceMandateType($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeMandate(Mandate $mandate): self
  116.     {
  117.         if ($this->mandates->removeElement($mandate)) {
  118.             // set the owning side to null (unless already changed)
  119.             if ($mandate->getReferenceMandateType() === $this) {
  120.                 $mandate->setReferenceMandateType(null);
  121.             }
  122.         }
  123.         return $this;
  124.     }
  125. }