src/Domain/Entity/Sector.php line 13

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