<?phpnamespace App\Domain\Entity;use App\Shared\Domain\ApplicationCore\Interfaces\EntityInterface;use App\Shared\Domain\NestedSet\Interfaces\NestedSetInterface;use App\Shared\Domain\Validator as CRLAssert;use DateTime;use DateTimeInterface;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\PersistentCollection;use Symfony\Component\Validator\Constraints as Assert;class Empresa extends Interviniente implements EntityInterface//, NestedSetInterface{ /** * @var string|null * @Assert\Length( max=9, maxMessage="max_length {{ limit }}") * @CRLAssert\ConstraintCIF() * @Assert\NotBlank(message="not_blank") */ private ?string $cif; /** * @var Collection|ArrayCollection * @Assert\Valid() */ private Collection $centrosTrabajo; /** * @var string|null * @Assert\NotBlank(message="not_blank") */ private ?string $razonSocial; /** * @var int|null * @Assert\NotBlank(message="not_blank") */ private ?int $hombres; /** * @var int|null * @Assert\NotBlank(message="not_blank") */ private ?int $mujeres; /** * @var int|null * @Assert\NotBlank(message="not_blank") */ private ?int $trabajadores; /** * @var string|null * @Assert\NotBlank(message="not_blank") */ private ?string $cp; private ?string $changedObservaciones; private ?DateTimeInterface $changedAt; /** * @var Ccaa|null */ private ?Ccaa $ccaa; /** * @var Cnae|null * @Assert\NotBlank(message="not_blank") */ private ?Cnae $cnae; /** * @var Provincia|null * @Assert\NotBlank(message="not_blank") */ private ?Provincia $provincia; /** * @var Municipio|null * @Assert\NotBlank(message="not_blank") */ private ?Municipio $municipio; private ?Empresa $padre; private ?Empresa $padrehijo; private ?Empresa $hijo; private ?Empresa $hijopadre; private Collection $organosRepresentacion; private Collection $personasContacto; public function __construct() { $this->hijo = null; $this->padre = null; $this->cif = null; $this->razonSocial = null; $this->centrosTrabajo = new ArrayCollection(); $this->organosRepresentacion = new ArrayCollection(); $this->personasContacto = new ArrayCollection(); } public function __clone(): void { $centrosTrabajo = $this->getCentrosTrabajo(); foreach ($centrosTrabajo??[] as $centroTrabajo) { $centroTrabajoClone = clone ($centroTrabajo); $this->addCentrosTrabajo($centroTrabajoClone); $this->removeCentrosTrabajo($centroTrabajo); } parent::setCreatedAt(new DateTime('now')); parent::setUpdatedAt(new DateTime('now')); } public function __toString(): string { return $this->getRazonSocial()??'Empresa Sin Definir'; } public function getCif(): ?string { return $this->cif; } public function setCif(?string $cif): static { $this->cif = $cif; return $this; } public function getRazonSocial(): ?string { return $this->razonSocial; } public function setRazonSocial(?string $razonSocial): static { $this->razonSocial = $razonSocial; 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 getCp(): ?string { return $this->cp; } public function setCp(?string $cp): static { $this->cp = $cp; return $this; } /** * @return Collection<int, CentroTrabajo> */ public function getCentrosTrabajo(): Collection { return $this->centrosTrabajo; } public function setCentrosTrabajo(PersistentCollection $centrosTrabajo): static { $this->centrosTrabajo = $centrosTrabajo; return $this; } public function addCentrosTrabajo(CentroTrabajo $centrosTrabajo): static { if (!$this->centrosTrabajo->contains($centrosTrabajo)) { $this->centrosTrabajo->add($centrosTrabajo); $centrosTrabajo->setEmpresa($this); } return $this; } public function removeCentrosTrabajo(CentroTrabajo $centrosTrabajo): static { if ($this->centrosTrabajo->removeElement($centrosTrabajo)) { // set the owning side to null (unless already changed) if ($centrosTrabajo->getEmpresa() === $this) { $centrosTrabajo->setEmpresa(null); } } return $this; } public function getCcaa(): ?Ccaa { return $this->ccaa; } public function setCcaa(?Ccaa $ccaa): static { $this->ccaa = $ccaa; return $this; } public function getCnae(): ?Cnae { return $this->cnae; } public function setCnae(?Cnae $cnae): static { $this->cnae = $cnae; return $this; } public function getProvincia(): ?Provincia { return $this->provincia; } public function setProvincia(?Provincia $provincia): static { $this->provincia = $provincia; return $this; } public function getMunicipio(): ?Municipio { return $this->municipio; } public function setMunicipio(?Municipio $municipio): static { $this->municipio = $municipio; return $this; } public function getHistorico(): Collection { $historico = new ArrayCollection(); $current = $this; while ($current = $current->getPadre()) { $historico->add($current); } return $historico; } public function getChangedAt(): ?DateTimeInterface { return $this->changedAt; } public function setChangedAt(?DateTimeInterface $changedAt): static { $this->changedAt = $changedAt; return $this; } public function getPadre(): ?self { return $this->padre; } public function setPadre(?self $padre): static { $this->padre = $padre; return $this; } public function getHijo(): ?self { return $this->hijo; } public function setHijo(?self $hijo): static { // unset the owning side of the relation if necessary if ($hijo === null && $this->hijo !== null) { $this->hijo->setPadre(null); } // set the owning side of the relation if necessary if ($hijo !== null && $hijo->getPadre() !== $this) { $hijo->setPadre($this); } $this->hijo = $hijo; return $this; } public function getChangedObservaciones(): ?string { return $this->changedObservaciones; } public function setChangedObservaciones(?string $changedObservaciones): static { $this->changedObservaciones = $changedObservaciones; return $this; } public function getPadrehijo(): ?self { return $this->padrehijo; } public function setPadrehijo(?self $padrehijo): static { // unset the owning side of the relation if necessary if ($padrehijo === null && $this->padrehijo !== null) { $this->padrehijo->setPadre(null); } // set the owning side of the relation if necessary if ($padrehijo !== null && $padrehijo->getPadre() !== $this) { $padrehijo->setPadre($this); } $this->padrehijo = $padrehijo; return $this; } public function getHijopadre(): ?self { return $this->hijopadre; } public function setHijopadre(?self $hijopadre): static { // unset the owning side of the relation if necessary if ($hijopadre === null && $this->hijopadre !== null) { $this->hijopadre->setHijo(null); } // set the owning side of the relation if necessary if ($hijopadre !== null && $hijopadre->getHijo() !== $this) { $hijopadre->setHijo($this); } $this->hijopadre = $hijopadre; return $this; } /** * @return Collection<int, OrganoRepresentacion> */ public function getOrganosRepresentacion(): Collection { return $this->organosRepresentacion; } public function addOrganosRepresentacion(OrganoRepresentacion $organosRepresentacion): static { if (!$this->organosRepresentacion->contains($organosRepresentacion)) { $this->organosRepresentacion->add($organosRepresentacion); $organosRepresentacion->setEmpresa($this); } return $this; } public function removeOrganosRepresentacion(OrganoRepresentacion $organosRepresentacion): static { if ($this->organosRepresentacion->removeElement($organosRepresentacion)) { // set the owning side to null (unless already changed) if ($organosRepresentacion->getEmpresa() === $this) { $organosRepresentacion->setEmpresa(null); } } return $this; } /** * @return Collection<int, Persona> */ public function getPersonasContacto(): Collection { return $this->personasContacto; } public function addPersonasContacto(Persona $personasContacto): static { if (!$this->personasContacto->contains($personasContacto)) { $this->personasContacto->add($personasContacto); } return $this; } public function removePersonasContacto(Persona $personasContacto): static { $this->personasContacto->removeElement($personasContacto); return $this; }}//class