src/Domain/Entity/Sector.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Domain\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Uid\Uuid;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. class Sector
  10. {
  11.     /**
  12.      * @var string|null
  13.      * @Assert\NotBlank(message="not_blank")
  14.      */
  15.     private ?string $nombre null;
  16.     private ?Uuid $id null;
  17.     /**
  18.      * @var string|null
  19.      * @Assert\NotBlank(message="not_blank")
  20.      */
  21.     private ?string $ambitoGeografico null;
  22.     private ?int $hombres null;
  23.     private ?int $mujeres null;
  24.     private ?bool $active null;
  25.     /**
  26.      * @var int|null
  27.      * @Assert\NotBlank(message="not_blank")
  28.      */
  29.     private ?int $trabajadores null;
  30.     private ?\DateTimeInterface $createdAt null;
  31.     private ?\DateTimeInterface $updatedAt null;
  32.     private ?\DateTimeInterface $deletedAt null;
  33.     /**
  34.      * @Assert\Valid()
  35.      * @Assert\Count(min=1, minMessage="count_invalid.sector.asociaciones_empresariales {{ limit }}")
  36.      */
  37.     private Collection $asociacionesEmpresariales;
  38.     /**
  39.      * @Assert\Valid()
  40.      * @Assert\Count(min=1, minMessage="count_invalid.sector.organizaciones_sindicales {{ limit }}")
  41.      */
  42.     private Collection $organizacionesSindicales;
  43.     /**
  44.      * @var $cnae|null
  45.      * @Assert\NotBlank(message="not_blank")
  46.      */
  47.     private ?Cnae $cnae null;
  48.     private Collection $documentacionSectores;
  49.     public function __construct()
  50.     {
  51.         $this->asociacionesEmpresariales = new ArrayCollection();
  52.         $this->organizacionesSindicales = new ArrayCollection();
  53.         $this->documentacionSectores = new ArrayCollection();
  54.     }
  55.     public function __toString(): string
  56.     {
  57.         return $this->getNombre()??'Sector Sin Definir';
  58.     }
  59.     public function getNombre(): ?string
  60.     {
  61.         return $this->nombre;
  62.     }
  63.     public function setNombre(?string $nombre): static
  64.     {
  65.         $this->nombre $nombre;
  66.         return $this;
  67.     }
  68.     public function getId(): ?Uuid
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getAmbitoGeografico(): ?string
  73.     {
  74.         return $this->ambitoGeografico;
  75.     }
  76.     public function setAmbitoGeografico(?string $ambitoGeografico): static
  77.     {
  78.         $this->ambitoGeografico $ambitoGeografico;
  79.         return $this;
  80.     }
  81.     public function getHombres(): ?int
  82.     {
  83.         return $this->hombres;
  84.     }
  85.     public function setHombres(?int $hombres): static
  86.     {
  87.         $this->hombres $hombres;
  88.         return $this;
  89.     }
  90.     public function getMujeres(): ?int
  91.     {
  92.         return $this->mujeres;
  93.     }
  94.     public function setMujeres(?int $mujeres): static
  95.     {
  96.         $this->mujeres $mujeres;
  97.         return $this;
  98.     }
  99.     public function getTrabajadores(): ?int
  100.     {
  101.         return $this->trabajadores;
  102.     }
  103.     public function setTrabajadores(?int $trabajadores): static
  104.     {
  105.         $this->trabajadores $trabajadores;
  106.         return $this;
  107.     }
  108.     public function getCreatedAt(): ?\DateTimeInterface
  109.     {
  110.         return $this->createdAt;
  111.     }
  112.     public function setCreatedAt(\DateTimeInterface $createdAt): static
  113.     {
  114.         $this->createdAt $createdAt;
  115.         return $this;
  116.     }
  117.     public function getUpdatedAt(): ?\DateTimeInterface
  118.     {
  119.         return $this->updatedAt;
  120.     }
  121.     public function setUpdatedAt(\DateTimeInterface $updatedAt): static
  122.     {
  123.         $this->updatedAt $updatedAt;
  124.         return $this;
  125.     }
  126.     public function getDeletedAt(): ?\DateTimeInterface
  127.     {
  128.         return $this->deletedAt;
  129.     }
  130.     public function setDeletedAt(?\DateTimeInterface $deletedAt): static
  131.     {
  132.         $this->deletedAt $deletedAt;
  133.         return $this;
  134.     }
  135.     /**
  136.      * @return Collection<int, SectorHasAsociacionEmpresarial>
  137.      */
  138.     public function getAsociacionesEmpresariales(): Collection
  139.     {
  140.         return $this->asociacionesEmpresariales;
  141.     }
  142.     public function addAsociacionesEmpresariale(SectorHasAsociacionEmpresarial $asociacionesEmpresariale): static
  143.     {
  144.         if (!$this->asociacionesEmpresariales->contains($asociacionesEmpresariale)) {
  145.             $this->asociacionesEmpresariales->add($asociacionesEmpresariale);
  146.             $asociacionesEmpresariale->setSector($this);
  147.         }
  148.         return $this;
  149.     }
  150.     public function removeAsociacionesEmpresariale(SectorHasAsociacionEmpresarial $asociacionesEmpresariale): static
  151.     {
  152.         if ($this->asociacionesEmpresariales->removeElement($asociacionesEmpresariale)) {
  153.             // set the owning side to null (unless already changed)
  154.             if ($asociacionesEmpresariale->getSector() === $this) {
  155.                 $asociacionesEmpresariale->setSector(null);
  156.             }
  157.         }
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return Collection<int, SectorHasOrganizacionSindical>
  162.      */
  163.     public function getOrganizacionesSindicales(): Collection
  164.     {
  165.         return $this->organizacionesSindicales;
  166.     }
  167.     public function addOrganizacionesSindicale(SectorHasOrganizacionSindical $organizacionesSindicale): static
  168.     {
  169.         if (!$this->organizacionesSindicales->contains($organizacionesSindicale)) {
  170.             $this->organizacionesSindicales->add($organizacionesSindicale);
  171.             $organizacionesSindicale->setSector($this);
  172.         }
  173.         return $this;
  174.     }
  175.     public function removeOrganizacionesSindicale(SectorHasOrganizacionSindical $organizacionesSindicale): static
  176.     {
  177.         if ($this->organizacionesSindicales->removeElement($organizacionesSindicale)) {
  178.             // set the owning side to null (unless already changed)
  179.             if ($organizacionesSindicale->getSector() === $this) {
  180.                 $organizacionesSindicale->setSector(null);
  181.             }
  182.         }
  183.         return $this;
  184.     }
  185.     public function getCnae(): ?Cnae
  186.     {
  187.         return $this->cnae;
  188.     }
  189.     public function setCnae(?Cnae $cnae): static
  190.     {
  191.         $this->cnae $cnae;
  192.         return $this;
  193.     }
  194.     public function isActive(): ?bool
  195.     {
  196.         return $this->active;
  197.     }
  198.     public function setActive(?bool $active): static
  199.     {
  200.         $this->active $active;
  201.         return $this;
  202.     }
  203.     /**
  204.      * @return Collection<int, DocumentacionSector>
  205.      */
  206.     public function getDocumentacionSectores(): Collection
  207.     {
  208.         return $this->documentacionSectores;
  209.     }
  210.     public function addDocumentacionSectore(DocumentacionSector $documentacionSectore): static
  211.     {
  212.         if (!$this->documentacionSectores->contains($documentacionSectore)) {
  213.             $this->documentacionSectores->add($documentacionSectore);
  214.             $documentacionSectore->setSector($this);
  215.         }
  216.         return $this;
  217.     }
  218.     public function removeDocumentacionSectore(DocumentacionSector $documentacionSectore): static
  219.     {
  220.         if ($this->documentacionSectores->removeElement($documentacionSectore)) {
  221.             // set the owning side to null (unless already changed)
  222.             if ($documentacionSectore->getSector() === $this) {
  223.                 $documentacionSectore->setSector(null);
  224.             }
  225.         }
  226.         return $this;
  227.     }
  228.     public function getPersonasContacto():Collection
  229.     {
  230.         $personas = new ArrayCollection();
  231.         foreach($this->getAsociacionesEmpresariales() as $asociacionesEmpresarial)
  232.         {
  233.             foreach ($asociacionesEmpresarial?->getAsociacionEmpresarial()->getPersonasContacto() as $persona)
  234.             {
  235.                 if(!$personas->contains($persona))
  236.                 {
  237.                     $personas->add($persona);
  238.                 }
  239.             }
  240.         }
  241.         foreach($this->getOrganizacionesSindicales() as $organizacionSindical)
  242.         {
  243.             foreach ($organizacionSindical->getOrganizacionSindical()->getPersonasContacto() as $persona)
  244.             {
  245.                 if(!$personas->contains($persona))
  246.                 {
  247.                     $personas->add($persona);
  248.                 }
  249.             }
  250.         }
  251.         return $personas;
  252.     }
  253. }