src/Entity/Adherent/MagasinCoordonnees.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Adherent;
  3. use App\Repository\Adherent\MagasinCoordonneesRepository;
  4. use DateTimeImmutable;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. #[ORM\Table(name'magasin_coordonnees')]
  8. #[ORM\Entity(repositoryClassMagasinCoordonneesRepository::class)]
  9. #[ORM\HasLifecycleCallbacks]
  10. class MagasinCoordonnees
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\Column(type'string'length255)]
  14.     private string $K_ADHERENT;
  15.     #[ORM\Id]
  16.     #[ORM\Column(type'string'length255)]
  17.     private string $TYPE;
  18.     #[ORM\Column(type'string'length255)]
  19.     #[Assert\NotBlank]
  20.     private string $LIB;
  21.     #[ORM\Column(type'integer')]
  22.     private int|null $ID_ANNUAIRE_PROGRESS;
  23.     #[ORM\Column(type'string'length255nullabletrue)]
  24.     private string|null $VOIE_NUM;
  25.     #[ORM\Column(type'string'length255nullabletrue)]
  26.     private string|null $VOIE_CPLT;
  27.     #[ORM\Column(type'string'length255nullabletrue)]
  28.     private string|null $VOIE_TYPE;
  29.     #[ORM\Column(type'string'length255nullabletrue)]
  30.     private string|null $VOIE_LIB;
  31.     #[ORM\Column(type'string'length255nullabletrue)]
  32.     private string|null $VOIE_LIB2;
  33.     #[ORM\Column(type'string'length255nullabletrue)]
  34.     private string|null $BAT;
  35.     #[ORM\Column(type'string'length255nullabletrue)]
  36.     private string|null $ENTREE;
  37.     #[ORM\Column(type'string'length255nullabletrue)]
  38.     private string|null $ETAGE;
  39.     #[ORM\Column(type'string'length255nullabletrue)]
  40.     private string|null $APPART;
  41.     #[ORM\Column(type'string'length255nullabletrue)]
  42.     private string|null $BP;
  43.     #[ORM\Column(type'string'length255nullabletrue)]
  44.     private string|null $CEDEX_CP;
  45.     #[ORM\Column(type'string'length255nullabletrue)]
  46.     private string|null $CEDEX_NUM;
  47.     #[ORM\Column(type'string'length255nullabletrue)]
  48.     private string|null $LAT;
  49.     #[ORM\Column(type'string'length255nullabletrue)]
  50.     private string|null $LON;
  51.     #[ORM\Column(type'string'length255)]
  52.     private string $K_CP;
  53.     #[ORM\Column(type'string'length255)]
  54.     private string $K_VILLE;
  55.     #[ORM\Column(type'string'length255)]
  56.     private string $K_PAYS;
  57.     #[ORM\Column(type'datetime_immutable')]
  58.     private DateTimeImmutable $createdAt;
  59.     #[ORM\ManyToOne(targetEntityMagasin::class, inversedBy'magasinCoordonnees')]
  60.     #[ORM\JoinColumn(name'magasin'referencedColumnName'k_adherent')]
  61.     private Magasin $magasin;
  62.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  63.     private DateTimeImmutable|null $updatedAt;
  64.     public function __construct()
  65.     {
  66.         $this->createdAt = new DateTimeImmutable("now");
  67.         $this->updatedAt = new DateTimeImmutable("now");
  68.     }
  69.     public function __toString(): string
  70.     {
  71.         $parts = [];
  72.         // Partie principale de l'adresse
  73.         if (!empty($this->VOIE_NUM)) {
  74.             $parts[] = $this->VOIE_NUM;
  75.         }
  76.         if (!empty($this->VOIE_CPLT)) {
  77.             $parts[] = $this->VOIE_CPLT;
  78.         }
  79.         if (!empty($this->VOIE_TYPE)) {
  80.             $parts[] = $this->VOIE_TYPE;
  81.         }
  82.         if (!empty($this->VOIE_LIB)) {
  83.             $parts[] = $this->VOIE_LIB;
  84.         }
  85.         if (!empty($this->VOIE_LIB2)) {
  86.             $parts[] = $this->VOIE_LIB2;
  87.         }
  88.         // Compléments (bâtiment, étage, appartement)
  89.         $complements = [];
  90.         if (!empty($this->BAT)) {
  91.             $complements[] = "Bât. " $this->BAT;
  92.         }
  93.         if (!empty($this->ENTREE)) {
  94.             $complements[] = "Entrée " $this->ENTREE;
  95.         }
  96.         if (!empty($this->ETAGE)) {
  97.             $complements[] = "Étage " $this->ETAGE;
  98.         }
  99.         if (!empty($this->APPART)) {
  100.             $complements[] = "App. " $this->APPART;
  101.         }
  102.         if (!empty($complements)) {
  103.             $parts[] = implode(', '$complements);
  104.         }
  105.         // BP et CEDEX
  106.         if (!empty($this->BP)) {
  107.             $parts[] = "BP " $this->BP;
  108.         }
  109.         if (!empty($this->CEDEX_CP) && !empty($this->CEDEX_NUM)) {
  110.             $parts[] = "CEDEX " $this->CEDEX_CP " " $this->CEDEX_NUM;
  111.         }
  112.         // Code postal, ville et pays
  113.         if (!empty($this->K_CP)) {
  114.             $parts[] = $this->K_CP;
  115.         }
  116.         if (!empty($this->K_VILLE)) {
  117.             $parts[] = $this->K_VILLE;
  118.         }
  119.         if (!empty($this->K_PAYS)) {
  120.             $parts[] = $this->K_PAYS;
  121.         }
  122.         return implode(' '$parts);
  123.     }
  124.     #[ORM\PreUpdate]
  125.     public function onPreUpdateEntity(): void
  126.     {
  127.         $this->updatedAt = new DateTimeImmutable("now");
  128.     }
  129.     public function getCreatedAt(): ?DateTimeImmutable
  130.     {
  131.         return $this->createdAt;
  132.     }
  133.     public function setCreatedAt(DateTimeImmutable $createdAt): self
  134.     {
  135.         $this->createdAt $createdAt;
  136.         return $this;
  137.     }
  138.     /**
  139.      * @return string
  140.      */
  141.     public function getKADHERENT(): string
  142.     {
  143.         return $this->K_ADHERENT;
  144.     }
  145.     public function setKADHERENT(mixed $K_ADHERENT): void
  146.     {
  147.         $this->K_ADHERENT $K_ADHERENT;
  148.     }
  149.     /**
  150.      * @return string
  151.      */
  152.     public function getTYPE(): string
  153.     {
  154.         return $this->TYPE;
  155.     }
  156.     public function setTYPE(mixed $TYPE): void
  157.     {
  158.         $this->TYPE $TYPE;
  159.     }
  160.     /**
  161.      * @return string
  162.      */
  163.     public function getLIB(): string
  164.     {
  165.         return $this->LIB;
  166.     }
  167.     public function setLIB(mixed $LIB): void
  168.     {
  169.         $this->LIB $LIB;
  170.     }
  171.     /**
  172.      * @return int|null
  173.      */
  174.     public function getIDANNUAIREPROGRESS(): ?int
  175.     {
  176.         return $this->ID_ANNUAIRE_PROGRESS;
  177.     }
  178.     public function setIDANNUAIREPROGRESS(int $ID_ANNUAIRE_PROGRESS): void
  179.     {
  180.         $this->ID_ANNUAIRE_PROGRESS $ID_ANNUAIRE_PROGRESS;
  181.     }
  182.     /**
  183.      * @return string|null
  184.      */
  185.     public function getVOIENUM(): ?string
  186.     {
  187.         return $this->VOIE_NUM;
  188.     }
  189.     public function setVOIENUM(mixed $VOIE_NUM): void
  190.     {
  191.         $this->VOIE_NUM $VOIE_NUM;
  192.     }
  193.     /**
  194.      * @return string|null
  195.      */
  196.     public function getVOIECPLT(): ?string
  197.     {
  198.         return $this->VOIE_CPLT;
  199.     }
  200.     public function setVOIECPLT(mixed $VOIE_CPLT): void
  201.     {
  202.         $this->VOIE_CPLT $VOIE_CPLT;
  203.     }
  204.     /**
  205.      * @return string|null
  206.      */
  207.     public function getVOIETYPE(): ?string
  208.     {
  209.         return $this->VOIE_TYPE;
  210.     }
  211.     public function setVOIETYPE(mixed $VOIE_TYPE): void
  212.     {
  213.         $this->VOIE_TYPE $VOIE_TYPE;
  214.     }
  215.     /**
  216.      * @return string|null
  217.      */
  218.     public function getVOIELIB(): ?string
  219.     {
  220.         return $this->VOIE_LIB;
  221.     }
  222.     public function setVOIELIB(mixed $VOIE_LIB): void
  223.     {
  224.         $this->VOIE_LIB $VOIE_LIB;
  225.     }
  226.     /**
  227.      * @return string|null
  228.      */
  229.     public function getVOIELIB2(): ?string
  230.     {
  231.         return $this->VOIE_LIB2;
  232.     }
  233.     public function setVOIELIB2(mixed $VOIE_LIB2): void
  234.     {
  235.         $this->VOIE_LIB2 $VOIE_LIB2;
  236.     }
  237.     public function getBAT(): ?string
  238.     {
  239.         return $this->BAT;
  240.     }
  241.     public function setBAT(mixed $BAT): void
  242.     {
  243.         $this->BAT $BAT;
  244.     }
  245.     public function getENTREE(): ?string
  246.     {
  247.         return $this->ENTREE;
  248.     }
  249.     public function setENTREE(mixed $ENTREE): void
  250.     {
  251.         $this->ENTREE $ENTREE;
  252.     }
  253.     public function getETAGE(): ?string
  254.     {
  255.         return $this->ETAGE;
  256.     }
  257.     public function setETAGE(mixed $ETAGE): void
  258.     {
  259.         $this->ETAGE $ETAGE;
  260.     }
  261.     public function getAPPART(): ?string
  262.     {
  263.         return $this->APPART;
  264.     }
  265.     public function setAPPART(mixed $APPART): void
  266.     {
  267.         $this->APPART $APPART;
  268.     }
  269.     public function getBP(): ?string
  270.     {
  271.         return $this->BP;
  272.     }
  273.     public function setBP(mixed $BP): void
  274.     {
  275.         $this->BP $BP;
  276.     }
  277.     public function getCEDEXCP(): ?string
  278.     {
  279.         return $this->CEDEX_CP;
  280.     }
  281.     public function setCEDEXCP(mixed $CEDEX_CP): void
  282.     {
  283.         $this->CEDEX_CP $CEDEX_CP;
  284.     }
  285.     public function getCEDEXNUM(): ?string
  286.     {
  287.         return $this->CEDEX_NUM;
  288.     }
  289.     public function setCEDEXNUM(mixed $CEDEX_NUM): void
  290.     {
  291.         $this->CEDEX_NUM $CEDEX_NUM;
  292.     }
  293.     public function getLAT(): ?string
  294.     {
  295.         return $this->LAT;
  296.     }
  297.     public function setLAT(mixed $LAT): void
  298.     {
  299.         $this->LAT $LAT;
  300.     }
  301.     public function getLON(): ?string
  302.     {
  303.         return $this->LON;
  304.     }
  305.     public function setLON(mixed $LON): void
  306.     {
  307.         $this->LON $LON;
  308.     }
  309.     public function getKCP(): ?string
  310.     {
  311.         return $this->K_CP;
  312.     }
  313.     public function setKCP(mixed $K_CP): void
  314.     {
  315.         $this->K_CP $K_CP;
  316.     }
  317.     public function getKVILLE(): ?string
  318.     {
  319.         return $this->K_VILLE;
  320.     }
  321.     public function setKVILLE(mixed $K_VILLE): void
  322.     {
  323.         $this->K_VILLE $K_VILLE;
  324.     }
  325.     public function getKPAYS(): string
  326.     {
  327.         return $this->K_PAYS;
  328.     }
  329.     public function setKPAYS(mixed $K_PAYS): void
  330.     {
  331.         $this->K_PAYS $K_PAYS;
  332.     }
  333.     public function getMagasin(): ?Magasin
  334.     {
  335.         return $this->magasin;
  336.     }
  337.     public function setMagasin(?Magasin $magasin): self
  338.     {
  339.         $this->magasin $magasin;
  340.         return $this;
  341.     }
  342.     public function getUpdatedAt(): ?DateTimeImmutable
  343.     {
  344.         return $this->updatedAt;
  345.     }
  346.     public function setUpdatedAt(DateTimeImmutable $updatedAt): void
  347.     {
  348.         $this->updatedAt $updatedAt;
  349.     }
  350.     public function toArray(): array
  351.     {
  352.         return [
  353.             'k_adherent' => $this->K_ADHERENT,
  354.             'type' => $this->TYPE,
  355.             'id_annuaire_progress' => $this->ID_ANNUAIRE_PROGRESS,
  356.             'magasin' => $this->magasin->getKAdherent(),
  357.             'lib' => $this->LIB,
  358.             'voie_num' => $this->VOIE_NUM,
  359.             'voie_cplt' => $this->VOIE_CPLT,
  360.             'voie_type' => $this->VOIE_TYPE,
  361.             'voie_lib' => $this->VOIE_LIB,
  362.             'voie_lib2' => $this->VOIE_LIB2,
  363.             'bat' => $this->BAT,
  364.             'entree' => $this->ENTREE,
  365.             'etage' => $this->ETAGE,
  366.             'appart' => $this->APPART,
  367.             'bp' => $this->BP,
  368.             'cedex_cp' => $this->CEDEX_CP,
  369.             'cedex_num' => $this->CEDEX_NUM,
  370.             'lat' => $this->LAT,
  371.             'lon' => $this->LON,
  372.             'k_cp' => $this->K_CP,
  373.             'k_ville' => $this->K_VILLE,
  374.             'k_pays' => $this->K_PAYS
  375.         ];
  376.     }
  377.     public function updateForm(MagasinCoordonnees $magasinCoordonnee): self
  378.     {
  379.         $this->setLIB($magasinCoordonnee->getLIB());
  380.         $this->setVOIENUM($magasinCoordonnee->getVOIENUM());
  381.         $this->setVOIECPLT($magasinCoordonnee->getVOIECPLT());
  382.         $this->setVOIELIB2($magasinCoordonnee->getVOIELIB2());
  383.         $this->setVOIETYPE($magasinCoordonnee->getVOIETYPE());
  384.         $this->setVOIELIB($magasinCoordonnee->getVOIELIB());
  385.         $this->setBAT($magasinCoordonnee->getBAT());
  386.         $this->setENTREE($magasinCoordonnee->getENTREE());
  387.         $this->setETAGE($magasinCoordonnee->getETAGE());
  388.         $this->setAPPART($magasinCoordonnee->getAPPART());
  389.         $this->setBP($magasinCoordonnee->getBP());
  390.         $this->setCEDEXCP($magasinCoordonnee->getCEDEXCP());
  391.         $this->setCEDEXNUM($magasinCoordonnee->getCEDEXNUM());
  392.         $this->setKCP($magasinCoordonnee->getKCP());
  393.         $this->setKVILLE($magasinCoordonnee->getKVILLE());
  394.         return $this;
  395.     }
  396. }