src/Domain/Entity/Empresa.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Domain\Entity;
  3. use App\Shared\Domain\ApplicationCore\Interfaces\EntityInterface;
  4. use App\Shared\Domain\NestedSet\Interfaces\NestedSetInterface;
  5. use App\Shared\Domain\Validator as CRLAssert;
  6. use DateTime;
  7. use DateTimeInterface;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\DBAL\Types\Types;
  11. use Doctrine\ORM\PersistentCollection;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. class Empresa extends Interviniente implements EntityInterface//, NestedSetInterface
  14. {
  15.     /**
  16.      * @var string|null
  17.      * @Assert\Length( max=9, maxMessage="max_length {{ limit }}")
  18.      * @CRLAssert\ConstraintCIF()
  19.      * @Assert\NotBlank(message="not_blank")
  20.      */
  21.     private ?string $cif;
  22.     /**
  23.      * @var Collection|ArrayCollection
  24.      * @Assert\Valid()
  25.      */
  26.     private Collection $centrosTrabajo;
  27.     /**
  28.      * @var string|null
  29.      * @Assert\NotBlank(message="not_blank")
  30.      */
  31.     private ?string $razonSocial;
  32.     /**
  33.      * @var int|null
  34.      * @Assert\NotBlank(message="not_blank")
  35.      */
  36.     private ?int $hombres;
  37.     /**
  38.      * @var int|null
  39.      * @Assert\NotBlank(message="not_blank")
  40.      */
  41.     private ?int $mujeres;
  42.     /**
  43.      * @var int|null
  44.      * @Assert\NotBlank(message="not_blank")
  45.      */
  46.     private ?int $trabajadores;
  47.     /**
  48.      * @var string|null
  49.      * @Assert\NotBlank(message="not_blank")
  50.      */
  51.     private ?string $cp;
  52.     private ?string $changedObservaciones;
  53.     private ?DateTimeInterface $changedAt;
  54.     /**
  55.      * @var Ccaa|null
  56.      */
  57.     private ?Ccaa $ccaa;
  58.     /**
  59.      * @var Cnae|null
  60.      * @Assert\NotBlank(message="not_blank")
  61.      */
  62.     private ?Cnae $cnae;
  63.     /**
  64.      * @var Provincia|null
  65.      * @Assert\NotBlank(message="not_blank")
  66.      */
  67.     private ?Provincia $provincia;
  68.     /**
  69.      * @var Municipio|null
  70.      * @Assert\NotBlank(message="not_blank")
  71.      */
  72.     private ?Municipio $municipio;
  73.     private ?Empresa $padre;
  74.     private ?Empresa $padrehijo;
  75.     private ?Empresa $hijo;
  76.     private ?Empresa $hijopadre;
  77.     private Collection $organosRepresentacion;
  78.     private Collection $personasContacto;
  79.     public function __construct()
  80.     {
  81.         $this->hijo null;
  82.         $this->padre null;
  83.         $this->cif null;
  84.         $this->razonSocial null;
  85.         $this->centrosTrabajo = new ArrayCollection();
  86.         $this->organosRepresentacion = new ArrayCollection();
  87.         $this->personasContacto = new ArrayCollection();
  88.     }
  89.     public function __clone(): void
  90.     {
  91.         $centrosTrabajo $this->getCentrosTrabajo();
  92.         foreach ($centrosTrabajo??[] as $centroTrabajo)
  93.         {
  94.             $centroTrabajoClone = clone ($centroTrabajo);
  95.             $this->addCentrosTrabajo($centroTrabajoClone);
  96.             $this->removeCentrosTrabajo($centroTrabajo);
  97.         }
  98.         parent::setCreatedAt(new DateTime('now'));
  99.         parent::setUpdatedAt(new DateTime('now'));
  100.     }
  101.     public function __toString(): string
  102.     {
  103.         return $this->getRazonSocial()??'Empresa Sin Definir';
  104.     }
  105.     public function getCif(): ?string
  106.     {
  107.         return $this->cif;
  108.     }
  109.     public function setCif(?string $cif): static
  110.     {
  111.         $this->cif $cif;
  112.         return $this;
  113.     }
  114.     public function getRazonSocial(): ?string
  115.     {
  116.         return $this->razonSocial;
  117.     }
  118.     public function setRazonSocial(?string $razonSocial): static
  119.     {
  120.         $this->razonSocial $razonSocial;
  121.         return $this;
  122.     }
  123.     public function getHombres(): ?int
  124.     {
  125.         return $this->hombres;
  126.     }
  127.     public function setHombres(?int $hombres): static
  128.     {
  129.         $this->hombres $hombres;
  130.         return $this;
  131.     }
  132.     public function getMujeres(): ?int
  133.     {
  134.         return $this->mujeres;
  135.     }
  136.     public function setMujeres(?int $mujeres): static
  137.     {
  138.         $this->mujeres $mujeres;
  139.         return $this;
  140.     }
  141.     public function getTrabajadores(): ?int
  142.     {
  143.         return $this->trabajadores;
  144.     }
  145.     public function setTrabajadores(?int $trabajadores): static
  146.     {
  147.         $this->trabajadores $trabajadores;
  148.         return $this;
  149.     }
  150.     public function getCp(): ?string
  151.     {
  152.         return $this->cp;
  153.     }
  154.     public function setCp(?string $cp): static
  155.     {
  156.         $this->cp $cp;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection<int, CentroTrabajo>
  161.      */
  162.     public function getCentrosTrabajo(): Collection
  163.     {
  164.         return $this->centrosTrabajo;
  165.     }
  166.     public function setCentrosTrabajo(PersistentCollection $centrosTrabajo): static
  167.     {
  168.         $this->centrosTrabajo $centrosTrabajo;
  169.         return $this;
  170.     }
  171.     public function addCentrosTrabajo(CentroTrabajo $centrosTrabajo): static
  172.     {
  173.         if (!$this->centrosTrabajo->contains($centrosTrabajo)) {
  174.             $this->centrosTrabajo->add($centrosTrabajo);
  175.             $centrosTrabajo->setEmpresa($this);
  176.         }
  177.         return $this;
  178.     }
  179.     public function removeCentrosTrabajo(CentroTrabajo $centrosTrabajo): static
  180.     {
  181.         if ($this->centrosTrabajo->removeElement($centrosTrabajo)) {
  182.             // set the owning side to null (unless already changed)
  183.             if ($centrosTrabajo->getEmpresa() === $this) {
  184.                 $centrosTrabajo->setEmpresa(null);
  185.             }
  186.         }
  187.         return $this;
  188.     }
  189.     public function getCcaa(): ?Ccaa
  190.     {
  191.         return $this->ccaa;
  192.     }
  193.     public function setCcaa(?Ccaa $ccaa): static
  194.     {
  195.         $this->ccaa $ccaa;
  196.         return $this;
  197.     }
  198.     public function getCnae(): ?Cnae
  199.     {
  200.         return $this->cnae;
  201.     }
  202.     public function setCnae(?Cnae $cnae): static
  203.     {
  204.         $this->cnae $cnae;
  205.         return $this;
  206.     }
  207.     public function getProvincia(): ?Provincia
  208.     {
  209.         return $this->provincia;
  210.     }
  211.     public function setProvincia(?Provincia $provincia): static
  212.     {
  213.         $this->provincia $provincia;
  214.         return $this;
  215.     }
  216.     public function getMunicipio(): ?Municipio
  217.     {
  218.         return $this->municipio;
  219.     }
  220.     public function setMunicipio(?Municipio $municipio): static
  221.     {
  222.         $this->municipio $municipio;
  223.         return $this;
  224.     }
  225.     public function getHistorico(): Collection
  226.     {
  227.         $historico = new ArrayCollection();
  228.         $current $this;
  229.         while ($current $current->getPadre())
  230.         {
  231.             $historico->add($current);
  232.         }
  233.         return $historico;
  234.     }
  235.     public function getChangedAt(): ?DateTimeInterface
  236.     {
  237.         return $this->changedAt;
  238.     }
  239.     public function setChangedAt(?DateTimeInterface $changedAt): static
  240.     {
  241.         $this->changedAt $changedAt;
  242.         return $this;
  243.     }
  244.     public function getPadre(): ?self
  245.     {
  246.         return $this->padre;
  247.     }
  248.     public function setPadre(?self $padre): static
  249.     {
  250.         $this->padre $padre;
  251.         return $this;
  252.     }
  253.     public function getHijo(): ?self
  254.     {
  255.         return $this->hijo;
  256.     }
  257.     public function setHijo(?self $hijo): static
  258.     {
  259.         // unset the owning side of the relation if necessary
  260.         if ($hijo === null && $this->hijo !== null) {
  261.             $this->hijo->setPadre(null);
  262.         }
  263.         // set the owning side of the relation if necessary
  264.         if ($hijo !== null && $hijo->getPadre() !== $this) {
  265.             $hijo->setPadre($this);
  266.         }
  267.         $this->hijo $hijo;
  268.         return $this;
  269.     }
  270.     public function getChangedObservaciones(): ?string
  271.     {
  272.         return $this->changedObservaciones;
  273.     }
  274.     public function setChangedObservaciones(?string $changedObservaciones): static
  275.     {
  276.         $this->changedObservaciones $changedObservaciones;
  277.         return $this;
  278.     }
  279.     public function getPadrehijo(): ?self
  280.     {
  281.         return $this->padrehijo;
  282.     }
  283.     public function setPadrehijo(?self $padrehijo): static
  284.     {
  285.         // unset the owning side of the relation if necessary
  286.         if ($padrehijo === null && $this->padrehijo !== null) {
  287.             $this->padrehijo->setPadre(null);
  288.         }
  289.         // set the owning side of the relation if necessary
  290.         if ($padrehijo !== null && $padrehijo->getPadre() !== $this) {
  291.             $padrehijo->setPadre($this);
  292.         }
  293.         $this->padrehijo $padrehijo;
  294.         return $this;
  295.     }
  296.     public function getHijopadre(): ?self
  297.     {
  298.         return $this->hijopadre;
  299.     }
  300.     public function setHijopadre(?self $hijopadre): static
  301.     {
  302.         // unset the owning side of the relation if necessary
  303.         if ($hijopadre === null && $this->hijopadre !== null) {
  304.             $this->hijopadre->setHijo(null);
  305.         }
  306.         // set the owning side of the relation if necessary
  307.         if ($hijopadre !== null && $hijopadre->getHijo() !== $this) {
  308.             $hijopadre->setHijo($this);
  309.         }
  310.         $this->hijopadre $hijopadre;
  311.         return $this;
  312.     }
  313.     /**
  314.      * @return Collection<int, OrganoRepresentacion>
  315.      */
  316.     public function getOrganosRepresentacion(): Collection
  317.     {
  318.         return $this->organosRepresentacion;
  319.     }
  320.     public function addOrganosRepresentacion(OrganoRepresentacion $organosRepresentacion): static
  321.     {
  322.         if (!$this->organosRepresentacion->contains($organosRepresentacion)) {
  323.             $this->organosRepresentacion->add($organosRepresentacion);
  324.             $organosRepresentacion->setEmpresa($this);
  325.         }
  326.         return $this;
  327.     }
  328.     public function removeOrganosRepresentacion(OrganoRepresentacion $organosRepresentacion): static
  329.     {
  330.         if ($this->organosRepresentacion->removeElement($organosRepresentacion)) {
  331.             // set the owning side to null (unless already changed)
  332.             if ($organosRepresentacion->getEmpresa() === $this) {
  333.                 $organosRepresentacion->setEmpresa(null);
  334.             }
  335.         }
  336.         return $this;
  337.     }
  338.     /**
  339.      * @return Collection<int, Persona>
  340.      */
  341.     public function getPersonasContacto(): Collection
  342.     {
  343.         return $this->personasContacto;
  344.     }
  345.     public function addPersonasContacto(Persona $personasContacto): static
  346.     {
  347.         if (!$this->personasContacto->contains($personasContacto)) {
  348.             $this->personasContacto->add($personasContacto);
  349.         }
  350.         return $this;
  351.     }
  352.     public function removePersonasContacto(Persona $personasContacto): static
  353.     {
  354.         $this->personasContacto->removeElement($personasContacto);
  355.         return $this;
  356.     }
  357. }//class