src/Entity/Institution.php line 33

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Entity\Mapped\NamedEntity;
  6. use App\Repository\InstitutionRepository;
  7. use App\Validator\Constraint as CustomValidator;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(
  12.     repositoryClassInstitutionRepository::class
  13. )]
  14. #[ORM\Table(
  15.     name'institution'
  16. )]
  17. #[ApiResource(
  18.     collectionOperations: [],
  19.     itemOperations: ['get']
  20. )]
  21. #[CustomValidator\OIBFormat(
  22.     message'institution.oib.format',
  23.     groups: ['action']
  24. )]
  25. #[CustomValidator\OIBInstitutionUnique(
  26.     message'institution.oib.unique',
  27.     groups: ['action']
  28. )]
  29. class Institution extends NamedEntity implements DocumentOwnerInterface
  30. {
  31.     #[ORM\Column(
  32.         name'label',
  33.         type'string',
  34.         length191,
  35.         nullabletrue
  36.     )]
  37.     #[Assert\NotBlank(
  38.         groups: ['action']
  39.     )]
  40.     #[Assert\Length(
  41.         max3,
  42.         groups: ['action']
  43.     )]
  44.     private ?string $label null;
  45.     #[ORM\Column(
  46.         name'color',
  47.         type'string',
  48.         length191,
  49.         nullabletrue
  50.     )]
  51.     #[Assert\NotBlank(
  52.         groups: ['action']
  53.     )]
  54.     #[Assert\Length(
  55.         max100,
  56.         groups: ['action']
  57.     )]
  58.     private ?string $color null;
  59.     #[ORM\Column(
  60.         name'oib',
  61.         type'string',
  62.         length191,
  63.         nullabletrue
  64.     )]
  65.     #[Assert\NotBlank(
  66.         groups: ['action']
  67.     )]
  68.     private ?string $oib null;
  69.     #[ORM\Column(
  70.         name'address',
  71.         type'string',
  72.         length191,
  73.         nullabletrue
  74.     )]
  75.     private ?string $address null;
  76.     #[ORM\Column(
  77.         name'place',
  78.         type'string',
  79.         length191,
  80.         nullabletrue
  81.     )]
  82.     private ?string $place null;
  83.     #[ORM\Column(
  84.         name'country',
  85.         type'string',
  86.         length191,
  87.         nullabletrue
  88.     )]
  89.     private ?string $country null;
  90.     #[ORM\Column(
  91.         name'contact_phone',
  92.         type'string',
  93.         length191,
  94.         nullabletrue
  95.     )]
  96.     private ?string $contactPhone null;
  97.     #[ORM\Column(
  98.         name'contact_email',
  99.         type'string',
  100.         length191,
  101.         nullabletrue
  102.     )]
  103.     private ?string $contactEmail null;
  104.     #[ORM\Column(
  105.         name'web_page',
  106.         type'string',
  107.         length191,
  108.         nullabletrue
  109.     )]
  110.     private ?string $webPage null;
  111.     #[ORM\Column(
  112.         name'additional_data',
  113.         type'text',
  114.         nullabletrue
  115.     )]
  116.     private ?string $additionalData null;
  117.     #[ORM\Column(
  118.         name'is_pdv',
  119.         type'boolean',
  120.         nullabletrue
  121.     )]
  122.     private ?bool $isPdv false;
  123.     #[ORM\ManyToOne(
  124.         targetEntityLegalEntity::class
  125.     )]
  126.     #[ORM\JoinColumn(
  127.         name'legal_entity'
  128.     )]
  129.     #[Assert\NotBlank(
  130.         groups: ['action']
  131.     )]
  132.     #[Assert\NotBlank(
  133.         groups: ['action']
  134.     )]
  135.     private ?LegalEntity $legalEntity null;
  136.     #[ORM\OneToMany(
  137.         mappedBy'institution',
  138.         targetEntityInstitutionContactPerson::class,
  139.         cascade: ['persist'],
  140.         fetch'EXTRA_LAZY',
  141.         orphanRemovaltrue
  142.     )]
  143.     #[Assert\Valid(
  144.         groups: ['action']
  145.     )]
  146.     private iterable $contactPerson;
  147.     #[ORM\OneToMany(
  148.         mappedBy'institution',
  149.         targetEntityInstitutionResponsiblePerson::class,
  150.         cascade: ['persist'],
  151.         fetch'EXTRA_LAZY',
  152.         orphanRemovaltrue
  153.     )]
  154.     #[Assert\Valid(
  155.         groups: ['action']
  156.     )]
  157.     private iterable $responsiblePerson;
  158.     #[ORM\OneToMany(
  159.         mappedBy'institution',
  160.         targetEntityInstitutionDocument::class,
  161.         cascade: ['persist'],
  162.         fetch'EXTRA_LAZY',
  163.         orphanRemovaltrue
  164.     )]
  165.     #[Assert\Valid(
  166.         groups: ['action']
  167.     )]
  168.     private iterable $document;
  169.     #[ORM\OneToMany(
  170.         mappedBy'institution',
  171.         targetEntityUserInstitution::class,
  172.         cascade: ['persist'],
  173.         fetch'EXTRA_LAZY',
  174.         orphanRemovaltrue
  175.     )]
  176.     private iterable $userInstitution;
  177.     public function __construct()
  178.     {
  179.         $this->contactPerson = new ArrayCollection();
  180.         $this->responsiblePerson = new ArrayCollection();
  181.         $this->document = new ArrayCollection();
  182.         $this->userInstitution = new ArrayCollection();
  183.     }
  184.     public function getLabel(): ?string
  185.     {
  186.         return $this->label;
  187.     }
  188.     public function setLabel(?string $label): self
  189.     {
  190.         $this->label $label;
  191.         return $this;
  192.     }
  193.     public function getColor(): ?string
  194.     {
  195.         return $this->color;
  196.     }
  197.     public function setColor(?string $color): self
  198.     {
  199.         $this->color $color;
  200.         return $this;
  201.     }
  202.     public function getOib(): ?string
  203.     {
  204.         return $this->oib;
  205.     }
  206.     public function setOib(?string $oib): self
  207.     {
  208.         $this->oib $oib;
  209.         return $this;
  210.     }
  211.     public function getAddress(): ?string
  212.     {
  213.         return $this->address;
  214.     }
  215.     public function setAddress(?string $address): self
  216.     {
  217.         $this->address $address;
  218.         return $this;
  219.     }
  220.     public function getPlace(): ?string
  221.     {
  222.         return $this->place;
  223.     }
  224.     public function setPlace(?string $place): self
  225.     {
  226.         $this->place $place;
  227.         return $this;
  228.     }
  229.     public function getCountry(): ?string
  230.     {
  231.         return $this->country;
  232.     }
  233.     public function setCountry(?string $country): self
  234.     {
  235.         $this->country $country;
  236.         return $this;
  237.     }
  238.     public function getContactPhone(): ?string
  239.     {
  240.         return $this->contactPhone;
  241.     }
  242.     public function setContactPhone(?string $contactPhone): self
  243.     {
  244.         $this->contactPhone $contactPhone;
  245.         return $this;
  246.     }
  247.     public function getContactEmail(): ?string
  248.     {
  249.         return $this->contactEmail;
  250.     }
  251.     public function setContactEmail(?string $contactEmail): self
  252.     {
  253.         $this->contactEmail $contactEmail;
  254.         return $this;
  255.     }
  256.     public function getWebPage(): ?string
  257.     {
  258.         return $this->webPage;
  259.     }
  260.     public function setWebPage(?string $webPage): self
  261.     {
  262.         $this->webPage $webPage;
  263.         return $this;
  264.     }
  265.     public function getAdditionalData(): ?string
  266.     {
  267.         return $this->additionalData;
  268.     }
  269.     public function setAdditionalData(?string $additionalData): self
  270.     {
  271.         $this->additionalData $additionalData;
  272.         return $this;
  273.     }
  274.     public function getIsPdv(): ?bool
  275.     {
  276.         return $this->isPdv;
  277.     }
  278.     public function setIsPdv(?bool $isPdv): self
  279.     {
  280.         $this->isPdv $isPdv;
  281.         return $this;
  282.     }
  283.     public function getUserInstitution(): iterable
  284.     {
  285.         return $this->userInstitution;
  286.     }
  287.     public function getLegalEntity(): ?LegalEntity
  288.     {
  289.         return $this->legalEntity;
  290.     }
  291.     public function setLegalEntity(?LegalEntity $legalEntity): self
  292.     {
  293.         $this->legalEntity $legalEntity;
  294.         return $this;
  295.     }
  296.     public function getContactPerson(): iterable
  297.     {
  298.         return $this->contactPerson;
  299.     }
  300.     public function addContactPerson(InstitutionContactPerson $contactPerson): void
  301.     {
  302.         if ($this->contactPerson->contains($contactPerson)) {
  303.             return;
  304.         }
  305.         $this->contactPerson[] = $contactPerson;
  306.         $contactPerson->setInstitution($this);
  307.     }
  308.     public function removeContactPerson(InstitutionContactPerson $contactPerson): void
  309.     {
  310.         if (!$this->contactPerson->contains($contactPerson)) {
  311.             return;
  312.         }
  313.         $this->contactPerson->removeElement($contactPerson);
  314.         $contactPerson->setInstitution(null);
  315.     }
  316.     public function getResponsiblePerson(): iterable
  317.     {
  318.         return $this->responsiblePerson;
  319.     }
  320.     public function addResponsiblePerson(InstitutionResponsiblePerson $responsiblePerson): void
  321.     {
  322.         if ($this->responsiblePerson->contains($responsiblePerson)) {
  323.             return;
  324.         }
  325.         $this->responsiblePerson[] = $responsiblePerson;
  326.         $responsiblePerson->setInstitution($this);
  327.     }
  328.     public function removeResponsiblePerson(InstitutionResponsiblePerson $responsiblePerson): void
  329.     {
  330.         if (!$this->responsiblePerson->contains($responsiblePerson)) {
  331.             return;
  332.         }
  333.         $this->responsiblePerson->removeElement($responsiblePerson);
  334.         $responsiblePerson->setInstitution(null);
  335.     }
  336.     public function getDocument(): iterable
  337.     {
  338.         return $this->document;
  339.     }
  340.     public function addDocument(DocumentInterface $document): void
  341.     {
  342.         if ($this->document->contains($document)) {
  343.             return;
  344.         }
  345.         $this->document[] = $document;
  346.         $document->setInstitution($this);
  347.     }
  348.     public function removeDocument(DocumentInterface $document): void
  349.     {
  350.         if (!$this->document->contains($document)) {
  351.             return;
  352.         }
  353.         $this->document->removeElement($document);
  354.         $document->setInstitution(null);
  355.     }
  356. }