<?phpnamespace App\Domain\Entity;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Uid\Uuid;use Symfony\Component\Validator\Constraints as Assert;class Sector{ /** * @var string|null * @Assert\NotBlank(message="not_blank") */ private ?string $nombre = null; private ?Uuid $id = null; /** * @var string|null * @Assert\NotBlank(message="not_blank") */ private ?string $ambitoGeografico = null; private ?int $hombres = null; private ?int $mujeres = null; private ?bool $active = null; /** * @var int|null * @Assert\NotBlank(message="not_blank") */ private ?int $trabajadores = null; private ?\DateTimeInterface $createdAt = null; private ?\DateTimeInterface $updatedAt = null; private ?\DateTimeInterface $deletedAt = null; /** * @Assert\Valid() * @Assert\Count(min=1, minMessage="count_invalid.sector.asociaciones_empresariales {{ limit }}") */ private Collection $asociacionesEmpresariales; /** * @Assert\Valid() * @Assert\Count(min=1, minMessage="count_invalid.sector.organizaciones_sindicales {{ limit }}") */ private Collection $organizacionesSindicales; /** * @var $cnae|null * @Assert\NotBlank(message="not_blank") */ private ?Cnae $cnae = null; private Collection $documentacionSectores; public function __construct() { $this->asociacionesEmpresariales = new ArrayCollection(); $this->organizacionesSindicales = new ArrayCollection(); $this->documentacionSectores = new ArrayCollection(); } public function __toString(): string { return $this->getNombre()??'Sector Sin Definir'; } public function getNombre(): ?string { return $this->nombre; } public function setNombre(?string $nombre): static { $this->nombre = $nombre; return $this; } public function getId(): ?Uuid { return $this->id; } public function getAmbitoGeografico(): ?string { return $this->ambitoGeografico; } public function setAmbitoGeografico(?string $ambitoGeografico): static { $this->ambitoGeografico = $ambitoGeografico; return $this; } public function getHombres(): ?int { return $this->hombres; } public function setHombres(?int $hombres): static { $this->hombres = $hombres; return $this; } public function getMujeres(): ?int { return $this->mujeres; } public function setMujeres(?int $mujeres): static { $this->mujeres = $mujeres; return $this; } public function getTrabajadores(): ?int { return $this->trabajadores; } public function setTrabajadores(?int $trabajadores): static { $this->trabajadores = $trabajadores; return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(\DateTimeInterface $createdAt): static { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(\DateTimeInterface $updatedAt): static { $this->updatedAt = $updatedAt; return $this; } public function getDeletedAt(): ?\DateTimeInterface { return $this->deletedAt; } public function setDeletedAt(?\DateTimeInterface $deletedAt): static { $this->deletedAt = $deletedAt; return $this; } /** * @return Collection<int, SectorHasAsociacionEmpresarial> */ public function getAsociacionesEmpresariales(): Collection { return $this->asociacionesEmpresariales; } public function addAsociacionesEmpresariale(SectorHasAsociacionEmpresarial $asociacionesEmpresariale): static { if (!$this->asociacionesEmpresariales->contains($asociacionesEmpresariale)) { $this->asociacionesEmpresariales->add($asociacionesEmpresariale); $asociacionesEmpresariale->setSector($this); } return $this; } public function removeAsociacionesEmpresariale(SectorHasAsociacionEmpresarial $asociacionesEmpresariale): static { if ($this->asociacionesEmpresariales->removeElement($asociacionesEmpresariale)) { // set the owning side to null (unless already changed) if ($asociacionesEmpresariale->getSector() === $this) { $asociacionesEmpresariale->setSector(null); } } return $this; } /** * @return Collection<int, SectorHasOrganizacionSindical> */ public function getOrganizacionesSindicales(): Collection { return $this->organizacionesSindicales; } public function addOrganizacionesSindicale(SectorHasOrganizacionSindical $organizacionesSindicale): static { if (!$this->organizacionesSindicales->contains($organizacionesSindicale)) { $this->organizacionesSindicales->add($organizacionesSindicale); $organizacionesSindicale->setSector($this); } return $this; } public function removeOrganizacionesSindicale(SectorHasOrganizacionSindical $organizacionesSindicale): static { if ($this->organizacionesSindicales->removeElement($organizacionesSindicale)) { // set the owning side to null (unless already changed) if ($organizacionesSindicale->getSector() === $this) { $organizacionesSindicale->setSector(null); } } return $this; } public function getCnae(): ?Cnae { return $this->cnae; } public function setCnae(?Cnae $cnae): static { $this->cnae = $cnae; return $this; } public function isActive(): ?bool { return $this->active; } public function setActive(?bool $active): static { $this->active = $active; return $this; } /** * @return Collection<int, DocumentacionSector> */ public function getDocumentacionSectores(): Collection { return $this->documentacionSectores; } public function addDocumentacionSectore(DocumentacionSector $documentacionSectore): static { if (!$this->documentacionSectores->contains($documentacionSectore)) { $this->documentacionSectores->add($documentacionSectore); $documentacionSectore->setSector($this); } return $this; } public function removeDocumentacionSectore(DocumentacionSector $documentacionSectore): static { if ($this->documentacionSectores->removeElement($documentacionSectore)) { // set the owning side to null (unless already changed) if ($documentacionSectore->getSector() === $this) { $documentacionSectore->setSector(null); } } return $this; } public function getPersonasContacto():Collection { $personas = new ArrayCollection(); foreach($this->getAsociacionesEmpresariales() as $asociacionesEmpresarial) { foreach ($asociacionesEmpresarial?->getAsociacionEmpresarial()->getPersonasContacto() as $persona) { if(!$personas->contains($persona)) { $personas->add($persona); } } } foreach($this->getOrganizacionesSindicales() as $organizacionSindical) { foreach ($organizacionSindical->getOrganizacionSindical()->getPersonasContacto() as $persona) { if(!$personas->contains($persona)) { $personas->add($persona); } } } return $personas; }}